LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-03-2011, 09:27 AM   #1
sysmanz
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Rep: Reputation: Disabled
Nagios Notification by SMS


Hello,
We have a sms getaway for sending sms and it written by PHP.
The file contain just 5 line.
I want to use it for notification by sms for nagios.
when i run file in command line like this : php /usr/local/nagios/etc/objects/sms.php "test"
it send me sms contain test word.
also when i run this command in SSH it sending me an emtpy sms :

# /usr/bin/printf "%b" "Svc:$SERVICEDESC$ Host:$HOSTALIAS$ Addr:$HOSTADDRESS$ State:$SERVICESTATES$ Date:$SHORTDATETIME$" | php /usr/local/nagios/etc/objects/sms.php "$CONTACTPAGER$
Array
(
[0] => 2250972535
)

so i put this in the commands.cfg and restarted the nagios but it doesn't send me any alert

define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "Svc:$SERVICEDESC$ Host:$HOSTALIAS$ Addr:$HOSTADDRESS$ State:$SERVICESTATES$ Date:$SHORTDATETIME$" | php /usr/local/nagios/etc/objects/sms.php "$CONTACTPAGER$
}

Should i add anything else in any other files ?!
What is the problem with that ?!

Regards
 
Old 08-04-2011, 08:50 AM   #2
omgs
Member
 
Registered: Dec 2010
Posts: 64

Rep: Reputation: 6
I suggest to manually run the command line (and any other tests you can think of) as nagios user, and see yourself the results in order to debug.
 
Old 08-04-2011, 11:00 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Instead of just | php use | /full/path/to/php or check that the context that Nagios is running in has access to the php executable.
 
Old 08-04-2011, 05:12 PM   #4
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
did you set your contact to use the notify-service-by-sms command?
 
Old 08-05-2011, 10:13 AM   #5
sysmanz
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
Instead of just | php use | /full/path/to/php or check that the context that Nagios is running in has access to the php executable.
I tried but didn't work
 
Old 08-05-2011, 10:18 AM   #6
sysmanz
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by trey85stang View Post
did you set your contact to use the notify-service-by-sms command?
The contact and phone number and everything is set into that file and also i tried like this using curl to the sms getway url but it didn't work in nagios but it work in command line and send a empty message :

| curl "http://big_url_into_sms_getway_website_contain_user&pass&myphonenumber=$CONTACTPAGER$"

Last edited by sysmanz; 08-05-2011 at 02:39 PM.
 
Old 08-08-2011, 07:03 AM   #7
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
Hi sysmanz,

To help you debug your command, here is what you can do:
At the end of your command in your command.cfg add the following red part
Code:
 command_line    echo "NAGIOS $NOTIFICATIONTYPE$ ($DATE$ $TIME$) Host: $HOSTNAME$ is $HOSTSTATE$ $HOSTOUTPUT$ | /usr/bin/gnokii --sendsms $CONTACTPAGER$" >> /tmp/nagios.notification
if you don't get anything in /tmp/nagios.notification with >> try with tee
Code:
 command_line    echo "NAGIOS $NOTIFICATIONTYPE$ ($DATE$ $TIME$) Host: $HOSTNAME$ is $HOSTSTATE$ $HOSTOUTPUT$ | /usr/bin/gnokii --sendsms $CONTACTPAGER$" tee /tmp/nagios.notification
Quote:
it work in command line and send a empty message
This is normal as you didn't specify any message to be send.

Best regards,
Angel.

Last edited by angel115; 08-08-2011 at 07:05 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios Alerts via SMS PankajRasuni Linux - Server 3 03-31-2011 01:51 AM
Nagios SMS gateway sci3ntist Linux - Server 3 09-27-2009 04:24 PM
Few questions about Nagios - reboot notification, value=x notification. marccmile Linux - Software 5 06-04-2009 06:44 PM
E-Mail notification to users via SMS (gateway script ok, but notification script?!?) Riku2015 Linux - Networking 10 03-08-2002 10:16 AM
E-Mail notification to users via SMS Riku2015 Linux - General 0 03-06-2002 02:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration