Nagios SMS Gateway



I have setup nagios 1.2 on a linux box on my network. I have another server that has a GSM modem and I am able to send SMS messages using this GSM modem. is there a way that i can get nagios to send notifications using this modem?




in my nagios setup, I have created some things myself using open source Java components.

What you need to do is:

  1. Have SMS Server software, that is installed on the machine on which your modem is connected. You could use gsmlib ( ) for that purpose. For our purpose, we wrote a simple TCP-server using the jSMSEngine library to send message, so we could use telnet and a very simple protocol to send messages.

  2. On your Nagios machine, have some software or script that can pass messages to the SMS server on the other machine. With jSMSServer that reads files from a directory you could use a simple ftp/nfs/smb copy script.
    In our setup, we used a Beanshell script ( ) that connects over TCP to our SMS server.

  3. You have to configure Nagios to use your script whenever notifications have to be sent.
    In Nagios, you have to add an extra notification path, and that should be done like this:

In misccommands.cfg:

‘notify-by-sms’ command definition

define command{
command_name notify-by-sms
command_line java -Xmx16m -Xnoclassgc -noverify -cp /export/home/beanshell/lib/bsh-1.3.0.jar bsh.Interpreter /export/home/beanshell/script/send_ace.bsh $CONTACTPAGER$ “$SERVICEDESC$ - $HOSTNAME$ - $HOSTADDRESS$ - $SERVICESTATE$ - $OUTPUT$ - $DATETIME$” smsserver.myhost 6666

‘host-notify-by-sms’ command definition

define command{
command_name host-notify-by-sms
command_line java -Xmx16m -Xnoclassgc -noverify -cp /export/home/beanshell/lib/bsh-1.3.0.jar bsh.Interpreter /export/home/beanshell/script/send_ace.bsh $CONTACTPAGER$ “Host ‘$HOSTALIAS$’ is $HOSTSTATE$ - Info: $OUTPUT$ - Time: $DATETIME$” smsserver.myhost 6666

And you refer to these commands in contacts.cfg:

‘Nightly support’ contact definition

define contact{
contact_name nightly_support
alias Nightly Support
service_notification_period 24x7
host_notification_period 24x7
service_notification_options u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-sms
pager +32xxxxxxxxxx

So, this is not a complete solution, although if you’re skilled in Java very easy to build. Probably there are other ( and maybe better ) solutions, but this one did it for us and has acted flawlessly for the pas months.