Live events counter on my website

Forum for questions and support relating to the 1.30.x releases only.
rockedge
Posts: 1177
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: Live events counter on my website

Post by rockedge »

the name of the triggering zone is in table "Events" field "Notes"
Baylink
Posts: 338
Joined: Sun Jun 19, 2005 3:19 am

Re: Live events counter on my website

Post by Baylink »

Ah. But's not the foreign key, right?
rockedge
Posts: 1177
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: Live events counter on my website

Post by rockedge »

what is the foreign key?
Baylink
Posts: 338
Joined: Sun Jun 19, 2005 3:19 am

Re: Live events counter on my website

Post by Baylink »

The non-primary key used to search in conjunction with a foreign table.
rockedge
Posts: 1177
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: Live events counter on my website

Post by rockedge »

I think you could extract the foreign key from the event table once the search for matches in the "comments" field is positive?? I am just starting to really look at this scenario due to time constraints....
Baylink
Posts: 338
Joined: Sun Jun 19, 2005 3:19 am

Re: Live events counter on my website

Post by Baylink »

Probably.

The OP's problem appeared to be that he was trying to find events by the name of the zone, and I don't think the name of the zone is *in* the event, just the ID# of the zone, and possibly of the monitor.

So to select by name, he'll need to join in the zone definition table, and possibly add some indexes judiciously.

I'm speaking very broadly, as I haven't spent any time with the schema.

Has anyone done an ER diagram of it?
kmg454
Posts: 58
Joined: Tue Apr 11, 2017 7:43 am

Re: Live events counter on my website

Post by kmg454 »

I'm the owner of the system so nobody can change zone names or other setting to break the system, now I'm counting one zone and I will try to count two zones at once making the selection on the zone name.
rockedge
Posts: 1177
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: Live events counter on my website

Post by rockedge »

why not just look at the newly created event and check the comments field and if the zone name matches the one your looking for extract the rest of the information from that event table? I have scripts that do this in a rough way. I have worked with triggering ZM to record an event with wireless remote X10 motion detectors....works fantastic...no CPU overhead running motion detection internally and darkness is no problem. A daemon sends a signal to zmTrigger.pl after polling a USB X10 transceiver. One of the if then statements in the logic of the script uses a "cause" field to determine if the event has been triggered by "motion" or by "signal"....I use this also in Filters to filter out signal loss events.
kmg454
Posts: 58
Joined: Tue Apr 11, 2017 7:43 am

Re: Live events counter on my website

Post by kmg454 »

So far as I know X10 motion detectors works only on a local system because you use a USB port, and our Zoneminder runs on a server in my data center 50 miles from here..
rockedge
Posts: 1177
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: Live events counter on my website

Post by rockedge »

still possible to use X10 detector...you just need a transceiver to be connected to the net...to send a trigger to zmTrigger.pl via telnet or a URL via the API. The X10 detector can be on site and send a motion detect trigger to other side of the planet. A tiny little computer or some old box to run the x10 transceiver and remote wifi x10 motion detectors. I did it for a proof of concept and it ran really well using some PERL and PHP. Plus X10 equipment is really inexpensive these days. Not perfect but works.
rockedge
Posts: 1177
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: Live events counter on my website

Post by rockedge »

code with improved query.
set $which_monitor to your monitor id.

Code: Select all

<?php
$which_monitor = 2;
$link = mysqli_connect("localhost", "zmuser", "zmpass", "zm");  

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
} 

if ($result = mysqli_query($link, "SELECT * FROM `Events` WHERE `MonitorId`=$which_monitor AND `StartTime` >= DATE_SUB(CURDATE(), INTERVAL 0 DAY)"))  {

    echo "Total # of Events :".mysqli_num_rows($result);
    
    /* free result set */
    mysqli_free_result($result);
}
?>
Locked