To make your box squeak when there is an alarm event:
sudo apt-get install mpg321 alsamixer
Adjust volume: alsamixer
To trigger the alarm on the very moment of the event based on this how to
Install perl
Create perl script to monitor DB (alarm_loop.pl)
#!/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 );
}
$sql = "select * from Events where Id = ?";
$sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
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" );
$res = $sth->execute( $last_event_id ) or die( "Can't execute '$sql': ".$sth->errstr() );
my $event = $sth->fetchrow_hashref();
if ( $event->{Id} ) {
# print( "EventID= ".$event->{Id} );
my $command = "./alarm1.sh"
# ." --monitor=" .$monitor->{Id}
." --event=" .$event->{Id}
." --starttime=\"" .$event->{StartTime} ."\"";
my $output = qx( $command );
my $status = $? >> 8;
# print ("Output(" .$status ."):" .$output);
# Print output if required
# Check status if required
#
# Do your stuff here
#
}
}
}
sleep( 1 );
}
Create bash script with link to alrm file (alarm1.sh)
#!/bin/bash
echo "1=$1 2=$2 3=$3 4=$4"
mpg123 /home/boxuser/www/wav/alarm.mp3
Run perl script:
sudo ./alarm_loop.pl\
Activate 640×480 streamingYou should be able to use a similar procedure with other distributions to modify the shared memory pool without kernel recompilations though in some cases this may be necessary. Note, this error also sometimes occurs if you have an old shared memory segment lying around from a previous run that is too small. Use the ipcs and ipcrm system commands to check and remove it if necessary.'"
You can often find out how much shared memory is available by typing the following :-
cat /proc/sys/kernel/shmall
and the most you can allocate in one go :-
cat /proc/sys/kernel/shmmax
To change these values type (for example) :-
echo 134217728 >/proc/sys/kernel/shmall
echo 134217728 >/proc/sys/kernel/shmmax
Be sure to restart ZoneMinder after this.However be aware that sometimes you will only need to change the shmmax value as shmall is often large enough. Also changing these values in this way is only effective until your machine is rebooted.
To change them permanently you will need to edit /etc/sysctl.conf and add the following lines (for example) :-
kernel.shmall = 134217728
kernel.shmmax = 134217728
To load these settings in the sysctl.conf file type:
sysctl -p
To check your shared memory settings type:
ipcs -l
These changes will now also be set the next time your machine is restarted.
To send an email on event
- install the exim4 according to https://help.ubuntu.com/community/Exim4
- my /etc/exim4/update-exim4.conf.conf looks like this (using the normal smtp server of my provider)
dc_eximconfig_configtype='smarthost'restart the system.
dc_other_hostnames='nerd.alert'
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='true'
dc_relay_nets=''
dc_smarthost='mail.bluewin.ch::25'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
sudo update-exim4.conf
sudo /etc/init.d/exim4 restart
test if you can mail:
echo test | mail -s test_mail yourmail@yourprovider.com
To send an email on event with video included
chnage in the options sections of ZM
ZM_OPT_MPEG to ffmpeg
ZM_PATH_FFMPEG to /usr/bin/ffmpeg
add the %EV% in the e-mail text: will attach the movie as mail
Check in zmvideo.pl and change ">& ffmpeg.log" to "&> /tmp/ffmpeg.log"To do:
1 Kommentar:
fo sending mails with exim and gmail
http://www.cooldown.com.ar/2007/09/22/howto-using-exim4-to-send-messages-through-gmail/
Kommentar veröffentlichen