Files to work with Zoneminder.

Your Name 4a2cfa89c8 EVEMTS should be EVENTS 6 years ago
LICENSE 1e910bba81 Initial commit 6 years ago
README.md 4a2cfa89c8 EVEMTS should be EVENTS 6 years ago
ZMRestartDaemon.sh 4a2cfa89c8 EVEMTS should be EVENTS 6 years ago

README.md

ZMRestart Daemon

A bash script to have API disable/re-enable a camera, should a monitor become unresponsive and zmwatch.pl unable to restore it. Used in production with FI9805E cameras and Zoneminder 1.29 Devuan Jessie. It will disable/re-enable cameras, as if you had disabled and re-enabled them from the GUI (same functions). Whether it restarts them or not is based on the CURL API request (which returns numbers of events for a given time frame), and whether the results are missing a camera or not. When a camera is absent from the results, then it will disable / re-enable that camera. You specify the camera monitor IDs to search for. You will also get an email notification that a camera was restarted.

This means if you have a quiet modect/nodect camera, it's not as practical (you'd have to set the curl time range to a long/wide time range). But any camera that is expected to record an event every 10 minutes, will be disabled/ re-enabled by this within 15 minutes (with default settings).

It also doubles as email notifications for any 'downed' cameras, because if a camera is unresponsive even after being disabled/re-enabled, you will get multiple emails for the same camera. This can be handy, say if a PSU for a camera fails.

I've set a limit to 7 emails per day. This will keep your inbox from filling up, should cameras truly be down.

For more details: see Zoneminder Wiki: Dummies Guide And the forum post here

git clone http://notabug.org/monitor/ZM_Scripts.git

By default the script is set for 1.29 (which provides JSON with line breaks. If you have 1.30.4 switch the comments here.

# For 1.29
grep -Po ^[^:]*  $EVENTSFILE | tail -n +3 | head -n -2 | cut -d \" -f 2 > $PARSEFILE

# For 1.30.4
#cat $EVENTSFILE  | cut -d \{ -f3 |  rev | cut -c 3- | rev | sed 's/,/\'$'\n/g'|   cut -d \" -f2 > $PARSEFILE

Cron Example

Here's what I have for my cronjob. You don't need to blank the email counter if you are not sending notification emails.

This is put in /etc/crontab (if you use crontab -e, remove the username)

*/5 * * * *    root      /root/scripts/ZMRestartDaemon.sh
0   1 * * *    root	 echo " " > /root/emailcounter.dat