It seems that you need to define your contacts twice. One definition to be notified only by email and another definition to be notified by both email and phone.
define contact{
name generic-contact-high
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email,notify-service-by-phone
host_notification_commands notify-host-by-email
register 0
}
define contact{
name generic-contact-med
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
register 0
}
Your contacts should be defined according to these two types of contacts:
define contact{
contact_name sam-high
use generic-contact-high
alias Sam
email sam[...]
address1 +44[...]
}
define contact{
contact_name sam-med
use generic-contact-med
alias Sam
email sam[...]
address1 +44[...]
}
It works and I can send SMS from terminal.
Have you tested as root
?
output=Error opening device, it doesn't exist.
Make sure that nagios
(and apache
if you want) has write permission on /dev/rfcomm0
.
Check this first:
# ls -l /dev/rfcomm0
Assumming you get:
crw-rw---- 1 root dialout 216, 0 2012-08-10 23:15 /dev/rfcomm0
then add the nagios
user to the dialout
group:
$ sudo usermod -a -G dialout nagios
and try again.
UPDATE Mon Aug 13 17:57:59 ICT 2012
Set the SUID bit on the command to allow nagios
execute gammu on behalf of the root
:
# chmod 4755 /usr/bin/gammu
and try again:
# su - nagios -s /bin/bash
$ echo "test" | gammu –sendsms TEXT 0123456789
Best Answer
Sure. Here's an example using Skype for notification.
Generally, you define a command that will execute the python script, then use that command for the host_notification_commands or service_notification_commands options in the contact definition.