How can I configure icinga/nagios to alert via sms?
Using a 3rd-party SMS service, or (even better) using a GSM device as Craig suggests, is going to be much more reliable/robust.
If you're dead set on using the provider's email->SMS gateway, you can use slimmed-down contact commands like this:
define command {
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "$NOTIFICATIONTYPE$\n$HOSTNAME$ is $HOSTSTATE$\n$HOSTOUTPUT$\n" | /usr/bin/mail -s "[Nagios] ($HOSTNAME$ $HOSTSTATE$)" $CONTACTEMAIL$
}
define command {
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "$NOTIFICATIONTYPE$\n$SERVICEDESC$ ($HOSTNAME$) is $SERVICESTATE$\n$SERVICEOUTPUT$" | /usr/bin/mail -s "[Nagios] ($HOSTNAME$/$SERVICEDESC$)" $CONTACTEMAIL$
If any of these end up being too long, you can remove or substitute different macros in several places, as necessary. See the macro list for info on what's available in a notification command.
In contacts_nagios2.cfg
:
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members user
}
define contact{
contact_name name
alias name
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-sms
email mail
pager MOBILENUMBER
}
And in commands.cfg
define command{
command_name notify-by-sms
command_line script-to-sms-service
}
define command{
command_name host-notify-by-sms
command_line script-to-sms-service
}