nagios custom notifications do not work
Posted: Wed Sep 04, 2013 9:15 am
Hi,
I'm trying to make nagios send notifications via usb modem as text messages. This is not a part of the issue, because I have a working bash script that takes care of it and if I run it (via sudo as nagios user) it works flawlessy.
I have configured the user object (in contacts.cfg) like so:
These notification commands are configured in the main configuration file (/etc/nagios3/commands.cfg):
and finally, the /usr/lib/nagios/plugins/send_sms is a bash script starting with:
which never gets written unless I run the script manually.
It seems to me that nagios has some kind of a problem with executing the script, which is very very weird. I repeat, logging in as user 'nagios' i can exec the script just fine, and any contents passed via stdin is properly received on the mobile.
I am also monitoring the nagios log file (/var/lib/nagios3/nagios.log) and some events do appear frequently (I ocasionally just pull a plug here and there to generate some events if needed).
One more remark - before the transition to sms notifications I did have working email notifications.
It's driving me nuts already. So please could someone actually shed some light on what is really wrong here?
I'm trying to make nagios send notifications via usb modem as text messages. This is not a part of the issue, because I have a working bash script that takes care of it and if I run it (via sudo as nagios user) it works flawlessy.
I have configured the user object (in contacts.cfg) like so:
Code: Select all
define contact{
.......
service_notification_commands notify-service-by-sms
host_notification_commands notify-host-by-sms
.......
}Code: Select all
# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/lib/nagios/plugins/send_sms $CONTACTPAGER$
}Code: Select all
# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/lib/nagios/plugins/send_sms $CONTACTPAGER$
}Code: Select all
#!/bin/bash
date >/tmp/smssend.logIt seems to me that nagios has some kind of a problem with executing the script, which is very very weird. I repeat, logging in as user 'nagios' i can exec the script just fine, and any contents passed via stdin is properly received on the mobile.
I am also monitoring the nagios log file (/var/lib/nagios3/nagios.log) and some events do appear frequently (I ocasionally just pull a plug here and there to generate some events if needed).
One more remark - before the transition to sms notifications I did have working email notifications.
It's driving me nuts already. So please could someone actually shed some light on what is really wrong here?