SMS Notifications with Custom script

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: SMS Notifications with Custom script

Post 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.
Previous Nagios employee
mindspring
Posts: 117
Joined: Thu Jul 19, 2012 10:24 am

Re: SMS Notifications with Custom script

Post by mindspring »

Ok great, so it is logging to the text file.

So what do you think I should do next?

Thanks
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: SMS Notifications with Custom script

Post 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.
Former Nagios Employee
mindspring
Posts: 117
Joined: Thu Jul 19, 2012 10:24 am

Re: SMS Notifications with Custom script

Post 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?
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: SMS Notifications with Custom script

Post 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].
Previous Nagios employee
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: SMS Notifications with Custom script

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mindspring
Posts: 117
Joined: Thu Jul 19, 2012 10:24 am

Re: SMS Notifications with Custom script

Post 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
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: SMS Notifications with Custom script

Post 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!
Locked