Talk:ZoneMinder CCTV Camera Monitoring Software
Contents
alarm thru sound card or bulid in speaker on server
ZM can play an alarm sound but only through the web interface and only when monitoring a camera. However it should be a fairly trivial task write a script maybe by adapting one of the ZM scripts which checks the shared memory status or event count and making that do something, or but just calling zmu to check the status.
run mplayer to play sound on alarm
Location of sound files
cd /usr/share/zoneminder/www/sounds
zmtrack.pl
perl zmtrack.pl -m 9 zmtrack.pl -m id_camera
error
perl -T /usr/bin/zmtrack.pl -m 9 Tracker daemon 9 (experimental) starting at 08/04/12 03:24:59 Monitor '9' is not controllable
record when there is motion to trigger an alarm event.
detect alarm event.
filters.
Filtering Events
The other columns on the main console window contain various event totals for your monitors over the last hour, day, week and month as well as a grand total and a total for events that you may have archived for safekeeping.
Instant Notification
mplayer /usr/share/zoneminder/www/sounds/redalert.wav
How can I use ZoneMinder to trigger something else when there is an alarm?
ZoneMinder includes a perl API which means you can create a script to interact with the ZM shared memory data and use it in your own scripts to react to ZM alarms or to trigger ZM to generate new alarms. Full details are in the README or by doing 'perdoc ZoneMinder', 'perldoc ZoneMinder::SharedMem' etc. Below is an example script that checks all monitors for alarms and when one occurs, prints a message to the screen. You can add in your own code to make this reaction a little more useful.
#!/usr/bin/perl -w use strict; use ZoneMinder; $| = 1; zmDbgInit( "myscript", level=>0, to_log=>0, to_syslog=>0, to_term=>1 ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); my $sql = "select M.*, max(E.Id) as LastEventId from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Function != 'None' group by (M.Id)"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() ); my @monitors; while ( my $monitor = $sth->fetchrow_hashref() ) { push( @monitors, $monitor ); } while( 1 ) { foreach my $monitor ( @monitors ) { next if ( !zmShmVerify( $monitor ) ); if ( my $last_event_id = zmHasAlarmed( $monitor, $monitor->{LastEventId} ) ) { $monitor->{LastEventId} = $last_event_id; print( "Monitor ".$monitor->{Name}." has alarmed\n" ); # # Do your stuff here # } } sleep( 1 ); }
variables and arrays
$monitor->{Id} $monitor->{Device} $monitor->{Name} $monitor->{MaxFPS} $monitor->{Function}
$event->{Id} $event->{MonitorId} $event->{MonitorHeight} $event->{MonitorWidth}