Page 5 of 5

Re: SMS Notifications with Custom script

Posted: Thu Dec 22, 2016 3:54 pm
by avandemore
Yes I did bring the server down then up again to test it
This doesn't necessarily equate to a state change from Nagios's POV.

Much easier and more foolproof to submit a passive check result with a different state.

Re: SMS Notifications with Custom script

Posted: Fri Dec 23, 2016 8:40 am
by mindspring
Ok great, so it is logging to the text file.

So what do you think I should do next?

Thanks

Re: SMS Notifications with Custom script

Posted: Tue Dec 27, 2016 3:01 pm
by rkennedy
You would need to build the logic for what you want done with the variables at this point. If they're populating in the file correctly, then the world is now yours. This depends if you're hitting an API, or using a modem to send the message, but from Nagios the variables are parsing correctly.

Re: SMS Notifications with Custom script

Posted: Wed Jan 04, 2017 3:23 am
by mindspring
Thanks, I will ask our developer to look at this again. It is using an API which works on Nagios Core Version 2.

Could you tell me what other method you guys recommend using to send SMS alerts if we can't get this to work?

Re: SMS Notifications with Custom script

Posted: Wed Jan 04, 2017 9:44 am
by avandemore
It should work, it's essentially the same mechanism everyone uses.

If you are interested, we do offer custom development for a fee. Please contact [email protected].

Re: SMS Notifications with Custom script

Posted: Fri Jan 06, 2017 11:43 am
by jomann
I actually got this working without editing the original PHP file that was given in the original post. I had to do the following and you can adjust as necessary:

1. Edit the /etc/php.ini and find the variables_order section and set it to:

Code: Select all

variables_order = "EGPCS"
* Note you should restart apache *

2. Enabled enable_environment_macros which can be done in in the CCM > Core Configs (you need to restart core but it will do that upon apply config at the end of this)

3. Downloaded the original script you sent in the original post (which includes NAGIOS_CONTACTPAGER) and saved it to:

Code: Select all

/tmp/sms-notification
4. Gave the sms-notification script nagios:nagios ownership and set +x so it could be executed

5. Created a command in the CCM called notify_special_sms which was a misc command with the following command line:

Code: Select all

/tmp/sms-notification host
6. Added a new contact with pager set to 5558109100 and gave that contact the notify_special_sms notification command for host in the CCM - I also had to set the notifications enabled, and what to notify on

7. Added the new contact to a host

8. Apply config

9. I dumped the output of the sms-notification script to a file before it actually sent the values out anywhere so I checked to make sure the pager number was being added

As a small side note - XI has SMS capabilities built in by using the SMS texting email addresses provided by mobile carriers, but it uses the global event/notification handlers that are a part of XI, so you need to have an actual XI user to be able to do that.

Re: SMS Notifications with Custom script

Posted: Mon Jan 16, 2017 6:30 am
by mindspring
Wow thanks Jomann.

It's working perfectly now! I really appreciate your help.

I actually had all the bits and pieces you suggested in place but perhaps with all the changes I made to the script, we got a bit side tracked.

I reverted back to the original script as you suggested and the messages started coming through.

Using this script is much better for us because the SMS service is much faster than Email to SMS.

Once again, thanks! I've been trying to get this to work for the last 3 months.

regards
Waleed

Re: SMS Notifications with Custom script

Posted: Mon Jan 16, 2017 10:19 am
by dwhitfield
Glad to hear it is resolved. I am going to lock the thread. Please feel free to post again if you have you another issue. Thank you for using the Nagios forums!