Contents
Todays post is actually going to be a guest post of sorts… Bob was Kind enough to write very detailed documentation on how to Setup SMS Alerts in Nagios via SMSTools. And since existing documentation on the process from start to finish is scarce at best – I thought I would share it here. It should be noted however that if you wish to use this method, you will need to have a GSM modem or qualifying mobile Device attached to your Nagios Server.~Enjoy
Before We Get Started…
Before we Dive in and start setting up SMSTools or Centreon Notifications, There are a number of prerequisites that need to be satisfied first. Bob has tried to make this process as easy as possible to follow – however if you run into any issues along the way, please comment below and we will do our best to get you up and running.
( Bob is pretty much a genius when it comes to Nagios! 😀 )
Download & Install CMake for CentOS-5
1 2 3 4 5 6 |
#Install Prerequisites... yum -y install xmlrpc-c xmlrpc-c-client #Now you should be able to install Cmake cd /tmp wget ftp://ftp.muug.mb.ca/mirror/centos/5.9/os/i386/CentOS/cmake-2.6.4-5.el5.4.i386.rpm rpm -ivh cmake-2.6.4-5.el5.4.i386.rpm |
Install GCC
1 2 |
yum install gcc yum install gcc gcc-c++ autoconf automake |
Install eject
1 |
yum install eject |
Install comget
1 2 3 4 |
cd /tmp wget http://kaz.dl.sourceforge.net/project/comgt/comgt/0.32/comgt.0.32.tgz make make install |
.
Configuring Your GSM Modem
1.) Insert gsm modem in usb port
2.) Run
1 |
dmesg | grep tty |
3.) Check which modem Port it’s connected to
1 |
ls -l /dev | grep '\->' |
4.) Eject the Cd-rom sro & sr1 as per your setup
1 |
eject /dev/sr0 or sr1 |
5.) Connect gsm modem to usb port ( USB0 in my case )
1 |
comgt -x -d /dev/ttyUSB0 |
6.) When the modem is connected you will get a message with your service provider name
7.) Create symbolic link to /dev/modem
1 |
ln -s /dev/ttyUSB0 /dev/modem |
TO TEST THAT THE USB MODEM IS ON USB0
1 |
dmesg | grep ttyUSB0 |
.
Installing & Configuring SMSTools
1.) Install SMS Tools
1 |
Yum install smstools |
-or-
1 2 3 |
cd /tmp wget http://pkgs.org/centos-5-rhel-5/epel-i386/smstools-3.0.10-4.el5.i386.rpm/download/ rpm -Uvh smstools-3.0.10-4.el5.i386.rpm |
2.) Make Sure you have the Following SMSTOOLS3 SERVER Files and Folders Installed
- incoming = /var/spool/sms/incoming
- outgoing = /var/spool/sms/outgoing
- checked = /var/spool/sms/checked
- failed = /var/spool/sms/failed
- sent = /var/spool/sms/sent
- logfile = /var/log/smsd.log
- Configuration = /etc/smsd.conf
3.) Make sure that SMSTools has the Right Configuration Setting for your modem in: /etc/smsd.conf
( GSM Modem is on USB0 in this example)
device = /dev/ttyUSB0
HOW TO START or STOP THE SMSTOOLS3 SERVER
1 2 3 4 5 |
# start smsd in background /etc/init.d/sms3 start # to stop smsd /etc/init.d/sms3 stop |
To Setup SMS Tools to AutoStart on Server Boot….
1 |
Chkconfig smsd start |
To Test your SMSTools Install:
1 |
sendsms 12128675309 'Hello, how are you' |
Centreon Setup for SMS Notifications
1.) First, we need to grant the necessary rights to Nagios:
1 2 |
chown -R nagios:nagios /var/spool/sms chmod -R 755 /var/spool/sms |
2.) Next We Need to Create 2 new notification Commands in Centreon:
Host-Notify-by-smstools
/usr/bin/printf “%b” ” hostname : $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Date/Time: $DATE$ ” | smssend $CONTACTPAGER$
Service-Notify-by-smstools
/usr/bin/printf “%b” ” $SERVICEDESC$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ ” | smssend $CONTACTPAGER$
3.) Next, add the mobile numbers for those involved under: Configuration > Users > Pager
Additional Resources
Nagios(FAN) – A Beginners Guide
http://smstools3.kekekasvi.com/index.php?p=fa
http://nerazan.blogspot.com/2013/07/how-to-configure-gsm-modem-in-linux.html
http://www.marcoach.nl/nagios-sms-notificaties/http://alexnogard.com/notifications-sms-pour-nagios-centreon/