Bagaimana Mengirim SMS dari NAGIOS

Kami sangat beruntung, karena kami adalah reseller dari kedua produk ini, yaitu NAGIOS dan OZEKI. Kedua produk ini bila digabungkan akan dapat digunakan untuk memberikan solusi yang tepat untuk monitoring perangkat jaringan dan server di tempat Anda. Silahkan hubungi kami apabila ada kebutuhan terkait dengan implementasinya.

 

How to send SMS from Nagios

If you would like to improve the features of Nagios, send SMS notifications from your system to mobile phones. With SMS functionality the generated reports of Nagios can be sent directly to the technical staff to make immediate intervention possible. To achieve this function you need a stable SMS gateway such as Ozeki NG SMS Gateway. Ozeki NG SMS Gateway is a software product that can be installed on your computer. It forwards messages to the mobile network either with GSM modem or IP SMS connection. If you implement this solution you will gain a secure, well-functioning and reliable SMS system based on Ozeki NG SMS Gateway. In this article you will find further information on this solution.
Download: sms_send.sh (259 bytes)


Video: Send SMS from Nagios (part 1/2, configure your modem)
Video: Send SMS from Nagios (part 2/2, configure your system)

Fields of application

As IT infrastructures of companies are becoming more and more complex and complicated, monitoring applications, such as Nagios, are widely used. These monitoring systems help identify and resolve IT problems in a way that they generate reports about these system failures. These reports usually can be forwarded to multiple recipients as email messages. The disadvantage of this method is that it is not sure that the recipient is sitting in front of his computer in the critical moment. So if you wish to improve your monitoring system, first you need to ensure that alerts reach the attention of the technical staff.

SMS technology can be a solution as it makes it possible to send SMS notifications from your IT environment to mobile phones. In this way, you can be sure that the intended person receives the message alert in real time and he can make the necessary steps to solve IT issues in time. It is also possible to send these SMS alerts to multiple recipients so the members of the IT staff and management can be informed about events occur in the IT system at the same time. You can receive a notification message even if you are on the move to be well-informed and up-to-date about the condition of your system.

To achieve these excellent features you need to install a powerful SMS gateway such as Ozeki NG SMS Gateway on your computer. Ozeki NG SMS Gateway provides the SMS functionality for Nagios. It has a unique capacity on the market. The SMS messages can be sent with a GSM modem attached to the computer or the SMS gateway connects directly to the SMS center of the mobile service provider over the Internet. With this solution you can build a stable SMS system to improve your monitoring application while you save time and money. In this article a step by step configuration guide will be provided, as well.

Benefits

If you decide to implement this solution you will gain a stable and effective SMS system with several advantages. The most important one is that you can ensure continuous availability. Therefore, the intended person will always be notified if an error occurs in the system. SMS alerts can be forwarded even in cases when the recipient is on the move. In this way, you do not need to check your emails all the time as you will be alerted on your mobile phone. This solution does not require internet connectivity to forward SMS notifications and can be implemented for other SMS solutions beside Nagios. With SMS solution all the problems can be solved in the right time before they affect your customers and business partners.

Prerequisites

In order to setup this solution you need to find a way to connect your system to the mobile network. You can do this by using an Internet connection or you can setup a wireless connection by attaching a GSM phone/GSM modem to your computer. To help you make a decision, we have prepared a webpage for you: Internet based SMS connections vs. GSM modem based (wireless) SMS connections. Depending on what you select, you need the following prerequisites.

Prerequisites for Internet based connection to the Mobile network
If you wish to connect your system to an SMS service provider over the Internet you need the following components:
Figure 1/a - Prerequisites for Ozeki NG SMS Gateway IP SMS connection
In this case you need to find an SMS service provider who can reach the mobile phones in your area. This SMS service provider should be able to provide SMS service through the Internet. To find such a provider, you can check our website where we list some of them: SMPP SMS Service providers. Once you have found such a provider, you need to sign up for their service to get the connection parameters. You can use these parameters to configure your Ozeki NG SMS Gateway software.

Prerequisites for wireless (GSM modem) connection to the Mobile network
If you wish to connect your system to the mobile network wirelessly, you need a GSM modem or GSM phone, that you can attach to your computer with a data cable. In this case your Ozeki NG SMS Gateway software will operate this phone and will send and receive SMS messages wirelessly. To setup this connection method, you need the following components:
Figure 1/b - Prerequisites for Ozeki NG SMS Gateway GSM modem connection
Your checklist (for GSM modem connection):

SIM Card - You can get this from your local mobile network operator.*
Modem - Use a Wavecom, Siemens or Multitech modem.
Data cable - Comes with the modem
Computer - Recommended: Intel P4 3Ghz, 2GB RAM, 500Mb HDD, Windows OS
Ozeki NG SMS Gateway - Download it from http://www.sms-integration.com
Nagios

*The SIM card will come with a plan, that will determine how much money you will spend on each SMS.
<="" td=""> Ozeki NG SMS Gateway can be obtained by
opening the download page:
Download Ozeki NG SMS Gateway!

System architecture

If you meet all the system requirements of Ozeki NG SMS Gateway you can build your SMS system that will function as follows: If an error occurs in your IT environment Nagios will detect it and generate a report about this malfunction. This generated report will be forwarded to Ozeki NG SMS Gateway with a HTTP request through a shell file. The SMS gateway processes the message and sends out as an SMS text message to a predefined cellphone (Figure 2).
Figure 2 - Ozeki NG SMS Gateway - solution for SMS sending in Nagios
As it was mentioned above Ozeki NG SMS Gateway forwards messages to the mobile network over GSM modem or IP SMS connection. Please note that GSM modem connection is highly recommended as it is more secure than IP SMS connectivity. If you wish to increase capacity you need to attach more than one GSM modem to your computer or you can still switch to IP SMS connection if it is required.

How to configure this solution

To configure your system to send SMS from Nagios with Ozeki NG SMS Gateway please follow the steps of this installation guide and watch the video tutorial on this solution:
Video: Send SMS from Nagios (configure your system)

First I have installed NSClient++ program on the computer to be monitored. The IP address of this computer is "192.168.91.144" (Figure 3).
Figure 3 - Monitored computer's IP address
I have also installed Nagios on Fedora Linux, and the IP address of this computer is "192.168.91.124" (Figure 4).
Figure 4 - Nagios computer's IP address
First open "nagios.cfg" file to edit. Start "Terminal" and login as administrator then open "nagios.cfg" file with "vi" editor. To do so type in the follows (Figure 5):

vi /usr/local/nagios/etc/nagios.cfg

Figure 5 - Edit Nagios' configuration file
Find the following row:
# Definitions for monitoring Windows machine
Press "i" to enter Insert mode and in the row below it, delete the comment mark. The final row will look like as follows (Figure 6):

cfg_file=/usr/local/nagios/etc/objects/windows.cfg

Then press "Escape" and type the follows to exit and save the file:

:wq

Figure 6 - Remove comment from configuration file
Now open "windows.cfg" file with "vi" editor. You can do this if you type in the following command (Figure 7):

vi /usr/local/nagios/etc/objects/windows.cfg

Figure 7 - Edit windows configuration file
Press "i" to enter Insert mode, then find the row beginning with "address". Now type the IP address of the computer you wish to monitor. In our example the row will look like as follows (Figure 8):

address           192.168.91.144
Figure 8 - Insert monitored computer's IP address
Then press "Escape" and type the follows to exit and save the file:

:wq


I have already downloaded "sms_send.sh" shell script to the desktop. Now I copy it to "libexec" directory of Nagios (Figure 9):

cp /home/ozekisms/Desktop/sms_send.sh /usr/local/nagios/libexec/
Please note that "ozekisms" username is only for test purposes, so provide your username instead of it.
Figure 9 - Copy the shell script
You can customize the "send_sms.sh" if you change "url1". In our example it is customized in the following way:
#!/bin/bash
url1="http://127.0.0.1:9501/api?action=sendmessage&username=admin&password= abc123&recipient=06203105366&messagetype=SMS:TEXT&messagedata="
url2="$@"
url2+=$(php -r "echo rawurlencode('$(sed "s/'/\\\\'/g" <<< )');")
url=$url1+$url2
wget -O- "$url"
You can customize url1 variable in the following way:
http://127.0.0.1:9501    is the computer on which Ozeki NG SMS Gateway has been installed
username=admin            is the username you use to log into Ozeki NG SMS Gateway
password=abc123          is the password of the user
recipient=06203105366  recipient's phone number
Now open "commands.cfg" file with "vi" editor (Figure 10):

vi /usr/local/nagios/etc/objects/commands.cfg

Figure 10 - Edit commands configuration file
Press "i" to enter Insert mode and insert a new row after "notify-service-by-email" and "notify-host-by-email" and provide the following commands (Figure 11):

# 'notify-service-by-sms' command definition
define command{
command_name    notify-service-by-sms
command_line      /usr/local/nagios/libexec/sms_send.sh "--Nagios Service Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$ Service $SERVICEDESC$ Description: $SERVICESTATE$ Time: $LONGDATETIME$"

} # 'notify-host-by-sms' command definition
define command{
command_name    notify-host-by-sms
command_line      /usr/local/nagios/libexec/sms_send.sh "--Nagios Host Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$"
}

Then press "Escape" and type the follows to exit and save the file:

:wq

Figure 11 - Notification commands
Open "contacts.cfg" file with "vi" editor (Figure 12):

vi /usr/local/nagios/etc/objects/contacts.cfg

Figure 12 - Edit contacts file
Press "i" to enter Insert mode and insert a new row before the one beginning with "e-mail". Type the follows (Figure 13):

service_notification_commands    notify-service-by-sms host_notification_commands       notify-host-by-sms

Figure 13 - Notification commands for admin
Then press "Escape" and type the follows to exit and save the file:

:wq


Then restart Nagios service to have changes come into operation. Type in the following command (Figure 14):

service nagios restart
Figure 14 - Restart Nagios service
After Nagios has been restarted, start your web browser and type in the follows:

http://localhost/nagios

Login with the default username which has been created during the installation (nagiosadmin), and with your provided password. Now you can see that there is a critical error on the monitored computer. The Explorer service reports this error. You can see at "Last Notification" row that Nagios has already sent the notification (Figure 15).
Figure 15 - Critical error in Nagios
If you take a look at Ozeki NG SMS Gateway you can see that the message has been sent out (Figure 16).
Figure 16 - Sent message

Conclusion

To summarize the above mentioned Nagios with Ozeki NG SMS Gateway is the best solution if you want to ensure continuous availability. With this solution you will gain a reliable, stable and very effective monitoring system as SMS alerts will be forwarded to the recipient even if he is on the move. In this way further problems and harms can be foregone and critical problems can be solved before they affect your business processes. It will result in considerable time and money savings and you can satisfy your customers and business partners in an efficient way furthermore you can attract new ones.

Popular posts from this blog

Dunia Aplikasi OpenSource

Mengenal Fungsi Dan Komponen Panel Listrik

Membangun Ruang Server (1)