Académique Documents
Professionnel Documents
Culture Documents
Mohammed Aijaz Ahmed Network Administrator IST Dept. Amana Steel Buildings and Contracting Co. (www.amanabuildings.com) aijazahmedece@gmail.com aijaz.ahmed@amanabuildings.com
NagiosSMSAlertingSystem
Table of contents:
Introduction........................................................................................................
Target audience, assumptions and recommendations. Acknowledgements .......
3 3 3
Installation
Install CentOS 5.4 .. Manual installation of Nagios XI. Install SMS server tools ... 6 6 6
Configuration
Integrate Nagios with SMS server . Create commands. Create SMS contacts. Associating SMS contact to a service. 7 8 10 12
NagiosSMSAlertingSystem
NagiosSMSAlertingSystem
Objective: To monitor the network and services like SMTP, backup, VPN connectivity, etc. and to get notified via SMS on failure of these services. Solution: This can be attained by using NagiosXI monitoring system on a Linux server which can monitor servers in data center and remote branch offices. By connecting a GSM modem to the server and configure it to work with Nagios you can receive alerts on your mobile phone. Hardware consideration 1. 2. 3. 4. 5. 6. HP DL360 G6 Server HDD : 146 GBx2 HDD (Raid 1) RAM : 6 GB RAM CPU : Quad corex2 @ 2.27 Ghz SMPS : Redundant power supply GSM modem : Telular XS5D GSM / FAX modem
Software consideration 1. CentOS release 5.4 2. Nagios XI 2009R1.3G 3. SMS server tools Installation Stages Stage 1: Install CentOS 5.4 Stage 2: Manual installation of Nagios XI Stage 3: Install SMS server tools Configuration Stages Stage 4: Integrate Nagios with SMS server Stage 5: Create commands Stage 6: Create SMS contacts
NagiosSMSAlertingSystem
NagiosSMSAlertingSy M ystem
Stage 1: Install CentOS 5.4 final release with server option. Select all server packages and deselect Graphical desktop environment (Gnome/KDE/etc.). No additional packages required. Stage 2: Manual installation of Nagios XI is basically done by running a set of shell scripts. Please refer to the document Manual_Installation_Nagios_XI_Instructions.pdf available at Nagios library. Stage 3: Install SMS server tools utility to send alerts via SMS to mobile phones. Connect a GSM modem (Telular XS5D GSM/FAX modem) with a valid SIM card to the server via serial cable. By configuring it to work with Nagios we can receive Nagios alerts on mobile phone 24x7. All you need is to install SMS server tools and then create customized commands and contacts in Nagios to enable it to send alerts via SMS. Download smstools-2.2.20.tar.gz from http://stefanfrings.de/smstools/index-en.html Run the following command # tar -xvzf smstools-2.2.20.tar.gz Enter the newly created directory #cd sms #./install.sh Normally, the default configuration file /etc/smsd.conf should work fine. Starting SMS server #/etc/init.d/sms start Send a test SMS by running the following command #sendsms 0507295873 Last night was exciting, when can we meet again? You can check for any errors in /var/log/smsd.log
AddingSMSservertostartindefaultrunlevel
#echo /etc/init.d/sms start >> /etc/rc.d/rc.local
NagiosSMSAlertingSystem
Stage 4: Integrate Nagios with SMS server tools to send SMS alerts. The SMS Server Tools have been made to send and receive short messages using GSM modems or mobile phones. It may be used for text messages with 7, 8 and 16 Bit character set as well as for binary messages. To send short messages, you need to create a simple text file in a spool directory. The program monitors that directory and sends new files automatically. Received messages are stored into text files in another spool directory (http://stefanfrings.de/smstools/index-en.html) Ive named this section as Integration of SMS server tools with Nagios because here we allow Nagios to write messages into SMS spool directory. The SMS tools program then sends the messages accordingly. All you need is to give nagios user ownership to the spool directories. #chown R nagios.nagios /var/spool/sms To verify the ownership information execute the following command. #ls la /var/spool/sms The result should be as follows drwxr-xr-x 5 nagios nagios 4096 Aug 8 11:59 . drwxr-xr-x 17 root root 4096 Aug 8 11:59 .. drwxr-xr-x 2 nagios nagios 4096 Oct 13 23:36 checked drwxr-xr-x 2 nagios nagios 4096 Oct 11 11:44 incoming drwxr-xr-x 2 nagios nagios 4096 Oct 13 23:36 outgoing With the help of custom commands and services, Nagios can send the short customized messages as SMS. The custom commands/services are discussed in later sections. Note: The SMS server tools manual can be found at http://stefanfrings.de/smstools/SMS_Applications.pdf
NagiosSMSAlertingSystem
Stage 5: Create Commands: Host Command for SMS: E-mail alert is usually longer which contains the banner of the monitoring system, extra lines and spaces. Commands for sending e-mail alerts are present in the system by default. An SMS alert is intended to be smaller in order to accommodate the information in a single SMS. Commands for sending SMS alerts are not present in the system by default and should be created as follows: E.g. host command to send SMS alert: (To send host down/recovery alert by SMS) Go to nagios core config manager commands add new enter command name enter command line select command type as misc command. notify-host-by-sms: /usr/bin/printf "%b" "Nagios Says: $HOSTNAME$ is $HOSTSTATE$ Info is: $HOSTOUTPUT$ $LONGDATETIME$" | /usr/local/bin/sendsms $CONTACTPAGER$
Click on save and then click on apply configuration. Tip: Copy the above command (notify-host-by-sms) and paste in the command line as shown above.
NagiosSMSAlertingSystem
Service Command for SMS: A service command is created to send service alerts by SMS. E.g. service command to send SMS alert: Go to nagios core config manager commands add new enter command name enter command line select command type as misc command. notify-service-by-sms: /usr/bin/printf "%b" "Nagios Says: $SERVICEDESC$ on $HOSTALIAS$ is: $SERVICESTATE$ $LONGDATETIME$ Info is: $SERVICEOUTPUT$" | /usr/local/bin/sendsms $CONTACTPAGER$ In the above examples the following macros are used and their description is as follows: $HOSTNAME$ $SERVICEDESC$ $HOSTOUTPUT$ $HOSTSTATE$ $SERVICEOUTPUT$ : fetches the host name of the monitored server from the system. : fetches the service description from the system. : fetches the output of the host check. : fetches the current state of the host down/up/flapping. : fetches the output result of the service check i.e. service stopped/ok or the numeric output value of the service check e.g. disk usage is 600 MB, etc. : fetches the current state of the service based on the thresholds set. The output is warning/critical/flapping. : fetches the current date and time from the system e.g. 14/10/2010 12:47:31 : fetches the mobile no. specified in the SMS contact. (We enter mobile no. in place of pager no in the template)
$SERVICESTATE$
$LONGDATETIME$ $CONTACTPAGER$
NagiosSMSAlertingSystem
Enterthecontactname,description,timeperiodhosts,timeperiodservicesandcheckonActive.
NagiosSMSAlertingSystem
10
Selectthecustomhostandservicecommandbyclickingontheeditbuttonasfollows:
Similarly,selecttheproperservicecommandandclickonSave.ThenclickonApplyconfiguration. NagiosSMSAlertingSystem
11
Stage 7: Associating SMS contact to a service: Its the show time! Now, since you have successfully installed the SMS server tools, created appropriate check commands, contacts, etc. you will need to assign the SMS contacts to those services for which you want to receive SMS alerts. To associate a SMS contact to a service go to core config manager services select the required service select Alert settings tab select the newly created SMS contact click on save click on Apply configuration
HurrayYoucannowreceiveyourfavoriteNagiosalertsonyourmobilephoneevenwhenthe Exchangeserver/Firewall/Routerinyourdatacenteraredown.
NagiosSMSAlertingSystem
12