Tas Kertas Unik dan Kreatif

Implementation SMS Gateway to Send SMS Alerts in Nagios Core

An SMS Alerts is sms gateway to allows a computer  send or receive Short Message Service (SMS) transmissions to or from a telecommunications network. Most messages are eventually routed into the mobile phone networks. Many SMS gateways support media conversion from email and other formats.

Gammu is the name of the project as well as name of command line utility, which you can use to control your phone. It is written in C and built on top of libGammu.

In this tutorial, we will to implementation sms gateway to send sms alerts in Nagios when server is down, unreacheable, and warning.

Step 1. Install Gammu-SMS

Installation gammu-sms from ports

$ cd /usr/ports/comms/gammu
$ make config

And then appears blue screen

Figure 1. Install gammu sms
Figure 1. Install gammu sms

Check BASH and press OK

$ make install clean

Step 2. Configuration Gammu SMS

Before we start config nagios, we must config gammu in below which type command

$ gammu-config

Then, appears blue screen

Figure 2. Config gammu sms
Figure 2. Config gammu sms

Set port which modem is connected. Default port modem in freeBSD is cuau0.0

Figure 3. Port modem
Figure 3. Port modem

Select type connection, in modem default baudrate connection is at115200 from type serial

Figure 4. Type Connection
Figure 4. Type Connection

Define log error for gammu and format writting. Example log in /var/log/gammu.log and format is textall

Figure 5. Format and Log
Figure 5. Format and Log

Save all configuration and Exit

sms-alerts
Figure 6. Save and Exit

After that, check configuration with type

$ gammu identify

Then appears screen like below

Figure 7. Gammu Identify
Figure 7. Gammu Identify

Check connection sms from modem to pager, type this command

$ echo "test sms to admin" | gammu sendsms text +6285747015***

Then, check from pager

Figure 8. Check SMS
Figure 8. Check SMS

Step 3. Configuration in Nagios

In configuration please add script command in nagios so daemon process can execute. Daemon in /usr/local/bin/gammu

define command {
 command_name notify-host-by-sms
 command_line /usr/bin/printf "%b" "Alert $HOSTNAME$ is $HOSTSTATE$" | /usr/local/bin/gammu sendsms TEXT $CONTACTPAGER$
}
define command {
 command_name notify-service-by-sms
 command_line /usr/bin/printf "%b" "Alert service $SERVICEDESC$ on $HOSTNAME$" is $SERVICESTAT$ | /usr/local/bin/gammu sendsms TEXT $CONTACTPAGER$
}

Create contact in file contact.cfg

define contact {
 contact_name nagiosadmin
 use generic-contact
 alias Nagios Admin
 email admin@nagios.com.if
 pager +628574791241
}

After that, add service in contact.cfg where “notify-host-by-sms ” and “notify-service-by-sms”

define contact{
 name generic-contact 
 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-host-by-sms 
 host_notification_commands notify-host-by-email, notify-service-by-sms 
 register 0 
}

After all finished, please check configuration of nagios and restart services

$ nagios -v /usr/local/etc/nagios/nagios.cfg
$ service nagios restart

Sample if server conditions is OK

Figure 9. SMS Alert
Figure 9. SMS Alert

Sources : en.doc.centreon.com and http://www.thegeekstuff.com/

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s