Security Cameras Scripts
Maintenance
Sometimes the build of ZoneMinder that we're using (1.34.1--old, but historically upgrading has had mixed results, and nothing's currently broken...) has a bug where the process that writes the diskspace used per event to the database breaks, leaving NULL in place of the real value. This is problematic as summing the diskspace used by all events then returns the wrong total, which breaks some things. It's normal to have some events showing NULL diskspace since the process doesn't run constantly, so this script runs as a cron job once an hour which is often enough to fix things before there are any problems. It seems to be triggered on average once a day.
#!/bin/bash # Checks if the update disk use filter in ZoneMinder has broken and if so kills it # Query how many events have NULL disk use. The filter should run once per minute # so depending on activity level, the query should return values in the range of 5-50 # If the value is too large, search for the filter's PID and kill it. NULLCOUNT=$(mysql --user=username --password=password --database=zm -s -N -e "select count(*) from Events where DiskSpace is NULL") echo $(date)" Null events count: "$NULLCOUNT if [[ "$NULLCOUNT" -gt 200 ]] then echo "Killing filter" kill $(ps aux | grep '[/]usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=14 --daemon' | awk '{print $2}') fi |