Page 1 of 1

Trying to send SMS (e.g. @vtext.com) for alerts in nagios.

Posted: Tue Oct 25, 2016 2:50 pm
by rjb905
I have successfully gotten the email notifications nailed down and they are sending out without any issues.

I need to now be able to send out SMS messages as well as the email alerts. We have the option to send out @vtext.com (for Verizon) and @txt.att.net for our AT&T phones (they are the two provider our organization uses. I have setup a test .php page, sent out an email to both providers using this test page on the same server I'm using for nagios and it is working without an issue.

I try to tie the cell phone numbers as second emails or separate contacts in the contacts.cfg file and its a no go. The email sends out no issues, however the text is no where to be found.

I'm using the notify-host-by-email and notify-service-by-email commands for both items and I'm putting in <number>@vtext.com as my contacts email address.

If anyone has any ideas please throw them over - I've searched and tried multiple things that have not worked for me over the last two days and I have to get this rolling.

Thanks for everyones help in advance - much appreciated.

RJB

Re: Trying to send SMS (e.g. @vtext.com) for alerts in nagio

Posted: Tue Oct 25, 2016 3:00 pm
by dwhitfield
There is a tutorial on using a SMS gateway at https://exchange.nagios.com/directory/M ... ns/details

However, it sounds like you are able to use the carrier email addresses. I am a little confused. Are you just saying that you can send SMS emails but you can't send SMS emails from Nagios? Thanks in advance for the clarification.

Re: Trying to send SMS (e.g. @vtext.com) for alerts in nagio

Posted: Tue Nov 01, 2016 9:55 am
by rjb905
dwhitfield - thanks for the reply:

Just to clear up the confusion:

- I can run the notify-host-by-email / notify-service-by-email commands - no issues -- the emails are going through no problem.

- With the SMS / Texting, while troubleshooting what was happening. I created a php file - sendsms.php -- the contents of that file is:

ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "[email protected]";
$to = "[email protected]";
$subject = "Nagios Alert";
$message = "Test Message";
mail($to,$subject,$message, $headers);
echo $message;

- When I incorporate the file (sendsms) - into the notify-service-by-sms it kicks off a text message, however it just obviously prints out "Test Message" for the message and nothing about the service or host that the issue is happening on.

How can I get the variables that these items are tied to incorporated into this simple php script, as this is the only way that I have found to kick off SMS / Text messages.

Thanks.

RJB.

Re: Trying to send SMS (e.g. @vtext.com) for alerts in nagio

Posted: Tue Nov 01, 2016 10:01 am
by rkennedy
You could either take your $1 $2 $3, or create variables in PHP and pass this over the CLI. You can pass any of the macros from this URL - https://assets.nagios.com/downloads/nag ... olist.html

For example -

Code: Select all

my-notification-command
$USER1$/myscript.php $HOSTNAME$ $HOSTADDRESS$
This would pass those two variables to your PHP script as $1 and $2 which you could then pass in the $message field.

At a quick glance, the usual rejection by @vtext.com is due to an invalid FQDN, but your /var/log/maillog would tell you more information about it.