Skip to content
Permalink
Browse files

Error handling if nems-mailtest run as non-root

  • Loading branch information...
NEMS Linux
NEMS Linux committed Apr 12, 2019
1 parent aa8a40b commit 66a82665535a03fe6eb70ef0c0014ce066e31efd
Showing with 8 additions and 2 deletions.
  1. +4 −1 data/1.5/nagios/plugins/nems_sendmail_host
  2. +4 −1 data/1.5/nagios/plugins/nems_sendmail_service
@@ -541,7 +541,10 @@ if(!$mail->send()) {
echo 'Message could not be sent.' . PHP_EOL;
echo 'Mailer Error: ' . $mail->ErrorInfo . PHP_EOL;
$error = '[' . strtotime('now') . '] NEMS EMAILER: ' . $mail->ErrorInfo . PHP_EOL;
file_put_contents('/var/log/nagios/nagios.log',$error,FILE_APPEND);
if (!file_put_contents('/var/log/nagios/nagios.log',$error,FILE_APPEND)) {
echo 'Could not save log as you are not running as a privileged user.' . PHP_EOL . 'Next time use sudo if this matters to you.';
echo PHP_EOL . $error . PHP_EOL;
}
} else {
echo 'Message has been sent' . PHP_EOL;
}
@@ -568,7 +568,10 @@ if(!$mail->send()) {
echo 'Message could not be sent.' . PHP_EOL;
echo 'Mailer Error: ' . $mail->ErrorInfo . PHP_EOL;
$error = '[' . strtotime('now') . '] NEMS EMAILER: ' . $mail->ErrorInfo . PHP_EOL;
file_put_contents('/var/log/nagios/nagios.log',$error,FILE_APPEND);
if (!file_put_contents('/var/log/nagios/nagios.log',$error,FILE_APPEND)) {
echo 'Could not save log as you are not running as a privileged user.' . PHP_EOL . 'Next time use sudo if this matters to you.';
echo PHP_EOL . $error . PHP_EOL;
}
} else {
echo 'Message has been sent' . PHP_EOL;
}

0 comments on commit 66a8266

Please sign in to comment.
You can’t perform that action at this time.