Cmdline arg 'script' for zmonvif-trigger.pl
This commit is contained in:
parent
4a39b3215b
commit
2e68fa4b34
|
@ -69,6 +69,7 @@ use constant MONITOR_RELOAD_INTERVAL => 3600;
|
|||
# Globals
|
||||
|
||||
my $verbose = 0;
|
||||
my $script;
|
||||
my $daemon_pid;
|
||||
|
||||
my $monitor_reload_time = 0;
|
||||
|
@ -219,11 +220,12 @@ sub xs_duration
|
|||
my $res = $sth->execute() or Fatal( "Can't execute: ".$sth->errstr() );
|
||||
while( my $monitor = $sth->fetchrow_hashref() )
|
||||
{
|
||||
if(!defined $script) {
|
||||
if ( !zmMemVerify( $monitor ) ) { # Check shared memory ok
|
||||
zmMemInvalidate( $monitor );
|
||||
next if ( !zmMemVerify( $monitor ) );
|
||||
}
|
||||
|
||||
}
|
||||
#$monitor->{MMapAddr} = undef;
|
||||
#memAttach( $monitor, 896 );
|
||||
#next if ( !zmMemVerify( $monitor ) );
|
||||
|
@ -275,11 +277,16 @@ sub xs_duration
|
|||
print "On: $monitorId, $score, $cause, $text, $showtext\n";
|
||||
my %monitors = $self->monitors();
|
||||
my $monitor = $monitors{$monitorId};
|
||||
if(defined $script) {
|
||||
system($script, 'On', $monitor->{Name}, $monitor->{Path}, $cause);
|
||||
}
|
||||
else {
|
||||
# encode() ensures that no utf-8 is written to mmap'ed memory.
|
||||
zmTriggerEventOn( $monitor, $score, encode("utf-8", $cause), encode("utf-8", $text) );
|
||||
zmTriggerShowtext( $monitor, encode("utf-8", $showtext) ) if defined($showtext);
|
||||
# main::dump_mapped($monitor);
|
||||
}
|
||||
}
|
||||
|
||||
sub eventOff
|
||||
{
|
||||
|
@ -287,6 +294,10 @@ sub xs_duration
|
|||
print "Off: $monitorId, $score, $cause, $text, $showtext\n";
|
||||
my %monitors = $self->monitors();
|
||||
my $monitor = $monitors{$monitorId};
|
||||
if(defined $script) {
|
||||
system($script, 'Off', $monitor->{Name}, $monitor->{Path}, $cause);
|
||||
}
|
||||
else {
|
||||
my $last_event = zmGetLastEvent( $monitor );
|
||||
zmTriggerEventOff( $monitor );
|
||||
# encode() ensures that no utf-8 is written to mmap'ed memory.
|
||||
|
@ -299,7 +310,8 @@ sub xs_duration
|
|||
usleep( 100000 );
|
||||
}
|
||||
zmTriggerEventCancel( $monitor );
|
||||
# main::dump_mapped($monitor);
|
||||
# main::dump_mapped($monitor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -656,6 +668,7 @@ sub HELP_MESSAGE
|
|||
Parameters:
|
||||
-v - increase verbosity
|
||||
-l|local-addr - listen on address (host[:port])
|
||||
-s|script - run script instead of generating ZM events
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -669,6 +682,7 @@ logSetSignal();
|
|||
|
||||
if(!GetOptions(
|
||||
'local-addr|l=s' => \$localaddr,
|
||||
'script|s=s' => \$script,
|
||||
'verbose|v=s' => \$verbose,
|
||||
)) {
|
||||
HELP_MESSAGE(\*STDOUT);
|
||||
|
|
Loading…
Reference in New Issue