Phone notification only for specific hosts|services

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
AlexSavVl
Posts: 38
Joined: Wed Oct 24, 2018 5:50 am

Phone notification only for specific hosts|services

Post by AlexSavVl »

We have hundreds of hosts and thousands of services, but only some of them should have SMS notifications. How can I do that?
Separate contact for SMS notifications is a bad option, since in this case, the user will not be able to manage notifications.

Is it possible to add a variable to a host/service and check it in xi_host_notification_handler (/usr/local/nagiosxi/scripts/handle_nagioscore_notification.php) before sending SMS notifications?

For example

Code: Select all

if ( sms_notification == 1)
     send_sms()
Could you point to the part of the code responsible for sending SMS, or suggest another solution?
AlexSavVl
Posts: 38
Joined: Wed Oct 24, 2018 5:50 am

Re: Phone notification only for specific hosts|services

Post by AlexSavVl »

Maybe someone is trying to solve a similar problem.
I made it by adding a variable

Code: Select all

_sendsms	on
to "Free Variable" in required service, changing xi_service_notification_handler in "Commands" from

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" ...
to

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service sendsms=$_SERVICESENDSMS$ ...
(change _SERVICESENDSMS$ to HOSTSENDSMS$ in host case)
Changing email-to-sms subject to

Code: Select all

sms %sendsms%
In than case if I will add variable "_sendsms on" in "free variavle" of a service, the subject of e-mail will be "sms on", if not -> "sms $"
And removing all messages with subject "sms $" by Postfix ba adding

Code: Select all

/^Subject: sms \$/ DISCARD
to /etc/postfix/header_checks (dont foget uncomment header_checks from main.cf)

So postfix deletes unnecessary messages.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Phone notification only for specific hosts|services

Post by cdienger »

Thanks for following up with your solution!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked