How to Temporarily Disable Nagios Email Notifications During Server Setup


1 views

When setting up a new Nagios monitoring server, you'll typically receive email notifications for every service check before you've properly configured thresholds and dependencies. This creates unnecessary noise during the crucial setup phase.

The fastest way to stop all email notifications is to edit the main Nagios configuration file:

# vi /usr/local/nagios/etc/nagios.cfg

Find and modify these directives:

enable_notifications=0
# Restart Nagios to apply changes
service nagios restart

For more granular control during setup, use service-specific overrides in your host or service definitions:

define service {
    host_name               new-server
    service_description     SSH
    ...
    notifications_enabled   0  # Disables notifications for this service only
}

Nagios provides a built-in feature for scheduled notification suppression:

# Set a 4-hour blackout starting now
echo "[date +%s] DISABLE_NOTIFICATIONS" > /usr/local/nagios/var/rw/nagios.cmd
sleep 14400  # 4 hours in seconds
echo "[date +%s] ENABLE_NOTIFICATIONS" > /usr/local/nagios/var/rw/nagios.cmd

For complex deployments, consider using custom variables to control notifications:

define host {
    host_name           new-server
    ...
    _SETUP_PHASE        true  # Custom variable
}

define service {
    host_name               new-server
    service_description     PING
    ...
    notification_options    n
    register                0  # Template
}

# Only enable notifications when _SETUP_PHASE is false
use                     generic-service
notification_options    u,c,r
condition               _SETUP_PHASE != true

After making changes, verify notification status through the web interface or CLI:

# Check global notification status
grep enable_notifications /usr/local/nagios/etc/nagios.cfg

# View notification settings for specific services
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg | grep -A5 "notifications_enabled"

When setting up a new Nagios server, you might get flooded with email notifications for every service check, host alert, or configuration test. These notifications can quickly become overwhelming during the initial setup phase when false positives are common.

The fastest way to stop all email notifications is to modify the main Nagios configuration file:

# Edit the main Nagios configuration file
sudo nano /usr/local/nagios/etc/nagios.cfg

# Set these parameters to 0
enable_notifications=0

After making changes, restart Nagios:

sudo systemctl restart nagios

If you only want to disable notifications for certain services during setup:

define service {
    host_name               my-server
    service_description     HTTP
    ...
    notifications_enabled   0   # Disable notifications for this service
}

For a more elegant solution, consider putting hosts in scheduled downtime:

# Command to schedule downtime for a host
echo "[%lu] SCHEDULE_HOST_DOWNTIME;my-server;date +%s;date -d '+2 hours' +%s;1;0;7200;nagiosadmin;Setup period" > /usr/local/nagios/var/rw/nagios.cmd

You can create notification filters to suppress certain types of alerts:

define contact {
    contact_name                    nagiosadmin
    ...
    service_notification_options    n   # 'n' means no notifications
    host_notification_options       n
}

After making changes, verify they took effect:

# Check the Nagios log for configuration errors
tail -f /usr/local/nagios/var/nagios.log

# Verify notification settings
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

When your setup is complete, remember to re-enable notifications by reversing these changes and verifying your alert thresholds are properly configured.