inotifywait

Low Bandwidth Zoneminder Webcam Stills Using Inotifywait

This bash script will get the latest Zoneminder webcam images using inotifywait and copy it to a local or remote folder every 5 seconds. Implement this script when streaming is unnecessary and you don't want to expose your Zoneminder systems to the internet (low bandwidth monitoring and low disk space archival).

Notes: You must have inotify-tools installed: yum install inotify-tools. I use sshfs to automatically mount remote system folders.

#!/bin/bash

CAMDIR='/var/www/html/zm/events/1'

cd $CAMDIR

while LINE=$(inotifywait -rq --format %f -e create "$CAMDIR");
do
        CUREVENTDIR=`ls -r | head -n1`
        # Low bandwidth monitoring
        cp $CUREVENTDIR/$LINE /var/www/web1/webcam1_last.jpg
        # Archive to /home/webcam1
        cp $CUREVENTDIR/$LINE /home/webcam1
        # Archive using scp to user@192.168.3.2:/home/webcam1
        # scp $CUREVENTDIR/$LINE user@192.168.3.2:/home/webcam1
        echo "$CAMDIR/$CUREVENTDIR/$LINE"
        sleep 5
done
Syndicate content

© 2008-2011 Red Audit LLC.
Page generated in: 0.000146 seconds.