Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
TetraWiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
SMS Integration on NAGIOS for sms19.info with HTTP API
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[[category:Nagios]] [[Category:SMS]] ==OBJECTIVE== SMS Integration on NAGIOS for sms19.info with HTTP API == Details Required == * HTTP API - http://www.sms19.info/ComposeSMS.aspx?username=username&password=password&sender=MPEDIA&to=Number&message=actualmessage&priority=1&dnd=1&unicode=0 * Username and Password * Working PHP on Nagios Server ( which should be available by Default ) == Basic SMS Sending Script for SMS19.INFO == /usr/local/nagios/libexec/sms.php <html> <body> <?php $user = 'Username'; $pass = 'Password'; $num = $argv[1]; $message = $argv[2]; $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.sms19.info/ComposeSMS.aspx?username=".urlencode($user)."&password=".urlencode($pass)."&sender=MPEDIA&to=".urlencode($num)."&message=".urlencode($message)."&priority=1&dnd=1&unicode=0"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?> </body> </html> ==Testing of basic Script == On Linux Command prompt and in the /usr/local/nagios/libexec/ ( directory ) php sms.php 9810030018 "Test from Nagios" Where sms.php is the script , 9810030018 is the mobile to which sms needs to be send and then "Test from Nagios" is the message This test will send the SMS on the Mobile == Nagios Integration== Create /usr/local/nagios/libexec/sms.sh #!/bin/sh cd /usr/local/nagios/libexec/ php sms.php 9810030018 "$1" php sms.php 9810077506 "$1" Then chmod 755 /usr/local/nagios/libexec/sms.sh chown nagios.nagios /usr/local/nagios/libexec/sms.sh Add the following in command.cfg # 'notify-service-by-sms' command definition define command{ command_name notify-service-by-sms command_line /usr/local/nagios/libexec/sms.sh "--Nagios Service Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$ Service $SERVICEDESC$ Description: $SERVICESTATE$ Time: $LONGDATETIME$ Service_output: $SERVICEOUTPUT$" } # 'notify-host-by-sms' command definition define command{ command_name notify-host-by-sms command_line /usr/local/nagios/libexec/sms.sh "--Nagios Host Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$" } Add the SMS contact in contact.cfg define contact{ contact_name '''biswajit-mm-sms''' ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias SMS-to-BB-MM ; Full name of user service_notification_commands notify-service-by-sms host_notification_commands notify-host-by-sms } Make it part of some contact Group to get the SMS ( contact.cfg) define contactgroup{ contactgroup_name escalation alias Escalation Contact Group members biswajitmail, mailamit,'''biswajit-mm-sms''' } Check the Nagios configuration via /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Reload the Nagios to have the changes reflected /etc/init.d/nagios reload Once Any alert is generated the SMS will be in the following sample text From: LM-MPEDIA Received: Dec 17, 2013 11:24 --Nagios Service Notification-- Host: arihant.arihanteletricals.com, State: UP Service Cpu Utilization Description: CRITICAL Time: Tue Dec 17 11:23:55 I ST 2013 Service_output: CRITICAL - user: 21.08, nice: 0.50, sys: 5.40, iowait: 73.04, irq: 0.50, softirq: 2.46 idle: 0.50
Summary:
Please note that all contributions to TetraWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TetraWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)