Activities

October 2011
M T W T F S S
« Sep   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Disable Nagios notification for a Time period

Yeaah it’s another jobs comes from my curiosity as I need nagios notification disable while I’m running a backup.

In my case I would need to take a database backup from a MySql slave. This slave is already added in Nagios monitoring system as well as this system watching the binary log position of both master and slave and send dbas alert up on mismatch.

I would need to bring down slave being running while I’m taking automated data base backup and nagios will send bunch of emails until the replication restart.

So I like to disable this nagios notification for a period of time.

a. I used to take regular table backup on every day at 2:00AM
b. A full database backup which will be running on every Sunday at 2:00 AM.

Solutions.

1. Create new time period in /usr/local/nagios/etc/objects/timeperiods.cfg
add following at the end of the file

define timeperiod {
timeperiod_name doc_bkp_time
 alias          Document backup
   sunday 00:00-2:00,12:00-24:00
  monday 00:00-2:00,04:00-24:00
  tuesday 00:00-2:00,04:00-24:00
  wednesday 00:00-2:00,04:00-24:00
  thursday 00:00-2:00,04:00-24:00
  friday 00:00-2:00,04:00-24:00
  saturday 00:00-2:00,04:00-24:00
}

2. Create a new custom service which would using this time period
Append the following lines on ” /usr/local/nagios/etc/objects/templates.cfg”

define service{
        name                            replication-service
        active_checks_enabled           1
        passive_checks_enabled          1
        parallelize_check               1
        obsess_over_service             1
        check_freshness                 0
        notifications_enabled           1
        event_handler_enabled           1
        flap_detection_enabled          1
        failure_prediction_enabled      1
        process_perf_data               1
        retain_status_information       1
        retain_nonstatus_information    1
        is_volatile                     0
        check_period                   24x7
        max_check_attempts              2
        normal_check_interval           5
        retry_check_interval            2
        contact_groups                  group-dba
        notification_options            w,u,c,r
        notification_interval          30
        notification_period            doc_bkp_time
         register                        0
        }

3. Use this service in nagios service command you have been using.

You may need to update the earlier service template associate with Nagios check command.

 define service{
 use replication-service
 host_name  SVR-db03
 service_description Replication Status
 check_command check_nrpe!check_slave_stat
 contact_groups   group-dba
 }

It’s time to check the Nagios settings are properly configured.

[root@nagios ~]#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Optional

Here I had used a contact group to get Nagios notification only to concerned DBA team. You may remove that line it. If you want to create email notification group add the following entries in “contact.cfg” (/usr/local/nagios/etc/objects/contacts.cfg)file.

define contact{
contact_name    user1
use             generic-contact
alias           User1 name
email           user1@domain.com
 }
define contact{
contact_name    user2
use             generic-contact
alias           User2 name
email           user2@domain.com
 }
define contactgroup{
contactgroup_name       group-dba
alias                   Database admins
members                 user1, user2
 }

That’s it !! 🙂 🙂 You have created group email notifications and Limited Time Nagios notification. 🙂

4 comments to Disable Nagios notification for a Time period

  • Alvin G. Matunog

    Very nice tip. Thank you very much. You seem to love challenges, so I would like to share my problem with you. May be you can give me a tip too or you can solve this. I have the same task but mine is a bit different. I was able to configure the timeperiod but I have another problem which up to this writing I was not able to solve yet. My windows servers are scheduled to restart every 1st Sunday of every month because of update patches and full system backup. During this time, I don`t want Nagios to monitor it so I want to stop monitoring at this time. My schedule of downtime is every 11:30-12:00 of 1st sunday of every month. This means that it will stop at 11:30 and resumes at 12:00. But the problem is after stopping at 11:30, it will resume on the next day (monday) and not on 12:00 sunday. I tried this schedule on a regular weekday I have no problem (e.g. every sunday it stops at 11:30 and resumes at 12:00, there is no problem). But on offset weekdays, it does not work or resumes on the time that it was set. Do you have any idea what I am missing? Thank you very much. More power man!

  • ram

    I need to monitor on every Sunday but alert needs to be generated alternate week for Sundays.

    could you please let me know Time period for this

    Thanks
    Ram

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>