Live events counter on my website
Re: Live events counter on my website
the name of the triggering zone is in table "Events" field "Notes"
Re: Live events counter on my website
Ah. But's not the foreign key, right?
Re: Live events counter on my website
what is the foreign key?
Re: Live events counter on my website
The non-primary key used to search in conjunction with a foreign table.
Re: Live events counter on my website
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....
Re: Live events counter on my website
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?
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?
Re: Live events counter on my website
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.
Re: Live events counter on my website
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.
Re: Live events counter on my website
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..
Re: Live events counter on my website
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.
Re: Live events counter on my website
code with improved query.
set $which_monitor to your monitor id.
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);
}
?>