I'm trying to configure Nagios 3 to monitor a server via HTTP by searching for a certain string by using the check_http
command as follows.
define command {
command_name check_http-mysite
command_line /usr/lib/nagios/plugins/check_http -H mysite.example.com -s "Some text" }
The HTTP check for a particular string works fine after I tested it. I have been trying unsuccessfully to configure the email-to-SMS notification by using the Clickatell SMTP API. How can I make it work?
I have come across an example in Tweak - Nagios SMS Messaging, though I seem to miss something.
Edit:
I guess my explanation before was very vague. I am trying to monitor a web server in such a way that I want to search for a particular string on a page via HTTP. The command is defined in command.cfg as follows
# 'check_http-mysite command definition'
define command {
command_name check_http-mysite
command_line /usr/lib/nagios/plugins/check_http -H mysite.example.com -s "Some text"
}
# 'notify-host-by-sms' command definition
define command {
command_name notify-host-by-sms
command_line /usr/bin/send_sms $CONTACTPAGER$ "Nagios - $NOTIFICATIONTYPE$ :Host$HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)"
}
# 'notify-service-by-sms' command definition
define command {
command_name notify-service-by-sms
command_line /usr/bin/send_sms $CONTACTPAGER$ "Nagios - $NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)"
}
Now if Nagios doesn't find "Some text" on the home page mysite.example.com
, Nagios should notify a contact via SMS through the Clickatell HTTP API which I have a script for that I have tested and found that it works fine.
Whenever I change the command definition to search for a string which is not on the page, and restart Nagios, I can see on the web interface that the string was not found. What I don't understand is why isn't the notification sent though I have defined the host, hostgroup, contact, contactgroup, service and so forth. What I'm missing, these are my definitions,
host.cfg
define host {
use generic-host
host_name HAL
alias IBM-1
address xxx.xxx.xxx.xxx
check_command check_http-mysite
}
hostgroups_nagios2.cfg
# my website
define hostgroup{
hostgroup_name my-servers
alias All My Servers
members HAL
}
contacts_nagios2.cfg
define contact {
contact_name colin
alias Colin Y
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-sms
host_notification_commands notify-host-by-email,notify-host-by-sms
email [email protected]
pager +254xxxxxxxxx
}
define contactgroup {
contactgroup_name site_admin
alias Site Administrator
members colin
}
services_nagios2.cfg
# Check for particular string in page via HTTP.
define service {
hostgroup_name my-servers
service_description STRING CHECK
check_command check_http-mysite
use generic-service
notification_interval 0 ; Set > 0 if you want to be renotified.
contacts colin
contact_groups site_admin
}
I hope I've explained my problem clearly this time :-)