From 7855ec28e45cc0f045d6b42da9cde51a4253a2d9 Mon Sep 17 00:00:00 2001 From: "Jason D. McCormick" Date: Tue, 7 Apr 2020 15:23:31 -0400 Subject: fix bad use of exec() --- allstar/allstar-monitor | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'allstar/allstar-monitor') diff --git a/allstar/allstar-monitor b/allstar/allstar-monitor index f3be769..2e4be6a 100755 --- a/allstar/allstar-monitor +++ b/allstar/allstar-monitor @@ -3,6 +3,9 @@ use strict; use File::Temp qw/tempfile/; +use Sys::Hostname; + +my $host = hostname; my $lastline = qx(/usr/bin/tail -n 1 /var/log/asterisk/messages); chomp($lastline); @@ -60,17 +63,17 @@ if( sleep 1; unlink "/var/run/asterisk.ctl"; unlink "/var/run/asterisk.pid"; - exec("/usr/local/sbin/astup.sh > /dev/null 2>&1"); + system("/usr/local/sbin/astup.sh > /dev/null 2>&1"); } my $msg; $msg .= "From: Asterisk \n"; $msg .= "To: zabbix\@megalink.network\n"; - $msg .= "Subject: Restarted Asterisk on pi-echo39\n"; + $msg .= "Subject: Restarted Asterisk on $host\n"; $msg .= "\n"; - $msg .= "This is the iax_monitor program on pi-echo39.\n"; + $msg .= "This is the allstar-monitor program on $host.\n"; $msg .= "\n"; - $msg .= "Asterisk was cycled at " . qx(/usr/bin/date) . " due to the IAX Max Retries bug.\n"; + $msg .= "Asterisk was cycled at " . qx(/usr/bin/date) . " due to a hang condition.\n"; $msg .= "\n"; $msg .= "Last Log:\n"; $msg .= " " . $lastline . "\n"; @@ -79,9 +82,7 @@ if( (my $ofh , my $outfile ) = tempfile( UNLINK => 1 ); - print $ofh $msg; system( sprintf("/usr/bin/cat %s | /usr/bin/ssmtp -oi -oem %s", $outfile, "zabbix\@megalink.network") ); - } } exit 0; -- cgit v1.2.3