Page 1 of 1

Notifications without changing the service status

Posted: Thu Apr 22, 2021 8:03 am
by meolic
We have a service in NagiosXI which is implemented via bash script. The script produces exit code 0, 1, or 2. It is called every minute. We want to get a notification if the bash script find something wrong. This works OK for the first time, the script just set exit status 2. But, in some cases, the situation in the observed system get worse and we want to send another notification to the operators. We have already set status to 2 (CRITICAL), so there is not much we can do. What is the best way to solve this?

BTW, we have a hack. When we want an additional notification, we change status to 1 (WARNING) even if the situation got worse. Notification is sent becasue the status has changed. For additional notifications (yes, there can be more) we simply alternate between statuses 1 and 2. But this is not very nice solution. It would be, if the service could be hidden from GUI, so that the operator is not seeing the color (he/she does not like that WARNING may denote a worse situation than CRITICAL).

Re: Notifications without changing the service status

Posted: Thu Apr 22, 2021 5:58 pm
by ssax
You could enable is_volatile on the service:

https://assets.nagios.com/downloads/nag ... vices.html

Re: Notifications without changing the service status

Posted: Thu Apr 22, 2021 11:44 pm
by meolic
ssax wrote:You could enable is_volatile on the service:

https://assets.nagios.com/downloads/nag ... vices.html
Thank you for the suggestion. But, we do not want that the notification is sent everytime the service is checked - it is checked every minute! The notification must be sent only if the bash script decided that the notification is needed.

Re: Notifications without changing the service status

Posted: Fri Apr 23, 2021 12:26 am
by meolic
If is_volatile could be dynamically set and reset from the bash script... but this seems to be a wrong approach anyway.

The passive checks may be the right directon. But, we do not have the experiences with them. Can anyone post a short receipt how the requested behaviour could be implemented with the help of passive checks?

Re: Notifications without changing the service status

Posted: Fri Apr 23, 2021 12:41 pm
by ssax
Does that check currently run on the XI server or is it being called on another system?

Given that the notification functionality will not meet your needs in this case I would enable is_volatile on the service and then set it up as a passive check (just run it on a cron job) and adjust the bash script to only submit the results when you want it to. The reason I'm not recommending an agent for this (like I usually would to run passive checks) is because the agents will ALWAYS send the results, you can't stop it from sending the results (good or bad). With a cron job you would control whether a result is sent or not.

If the script is not on the XI server you could:

Setup NRDP to receive passive results:

https://assets.nagios.com/downloads/nrd ... erview.pdf

Then have your bash script submit them:

https://support.nagios.com/kb/article/n ... t-599.html

If the script is on the XI server you can either do the NRDP process above or this:

https://assets.nagios.com/downloads/nag ... and_id=114

As an alternative you can have your bash script do this to send a notification:

Code: Select all

https://assets.nagios.com/downloads/nagioscore/docs/externalcmds/cmdinfo.php?command_id=135

Re: Notifications without changing the service status

Posted: Fri Apr 23, 2021 12:49 pm
by meolic
The bash script is located on Nagios XI server in /usr/local/nagios/libexec/scripts. Thus, your answer is applicable. Thank you.

Re: Notifications without changing the service status

Posted: Mon Apr 26, 2021 9:17 am
by ssax
Great, let us know if you have any related questions.