Page 1 of 1

Disable notifications after a restore

Posted: Mon Mar 08, 2021 9:33 am
by paulconca
Hi All,

We do a weekly back up from our primary and restore it on our Secondary using a script

To disable the notifications we edit the configs as below, it seems to be the only way to guarantee no emails are sent.
sed -i 's/ host_notifications_enabled 1/ host_notifications_enabled 0/g' /usr/local/nagios/etc/contacts.cfg
sed -i 's/ service_notifications_enabled 1/ service_notifications_enabled 0/g' /usr/local/nagios/etc/nagios.cfg

This works fine until the configuration is applied on the UI, as the above options are still all enabled in the UI.
We use the Secondary for testing so we need to apply the configuration.

Is there a way to disable the notifications and individual user notifications in the UI via command line, as we are using scripts to do the restores?

Thank you

Re: Disable notifications after a restore

Posted: Mon Mar 08, 2021 4:51 pm
by benjaminsmith
Hi,

Good question. The Nagios External Commands would be best in this situation. There are a few options, but running the following bash script will disable all notifications.

Code: Select all

#!/bin/sh
# This is a sample shell script showing how you can submit the DISABLE_NOTIFICATIONS command
# to Nagios. Adjust variables to fit your environment as necessary.

now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'

/bin/printf "[%lu] DISABLE_NOTIFICATIONS\n" $now > $commandfile   
For more command options and examples, take a look at the following reference.
Nagios Core External Commands

Let me know if that will work for you.