how can check specific sensors in specific time

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

how can check specific sensors in specific time

Postby baber » Sun Oct 07, 2018 10:05 am

Dear all
Hi

i have added a server to nagios in below i put my server.cfg file

Code: Select all
        use                     local-service
        host_name               cm
        service_description     CPU Load
        servicegroups           TS
        check_command           check_nrpe!check_load
        }

#define service{
#        use                     local-service
#        host_name               cm
#        service_description     SNMP
#        check_command           check_nrpe!check_snmp!'-H localhost -C public -o .1.3.6.1.4.1.2021.11.9.0'
#        }

define service{
        use                     local-service
        host_name               cm
        service_description     Memory
        servicegroups           TS
        check_command           check_nrpe!check_mem!'-w 10 -c 5 -f -C'
        }

define service{
        use                     local-service
        host_name               cm
        service_description     DNS
        check_command           check_nrpe!check_dns
        }

define service{
        use                     local-service
        host_name               cm
        service_description     Current Users
        servicegroups           TS
        check_command           check_nrpe!check_users
        }


now i want to know how can check two sensors in a specific time for example i want DNS check and Current Users check not check between 13:00-19:00 every day and check other times of day



is that possible ?

BR
Babak
baber
 
Posts: 283
Joined: Wed Oct 21, 2015 4:39 am

Re: how can check specific sensors in specific time

Postby mcapra » Mon Oct 08, 2018 8:22 am

Yes, it is possible by using the check_period directive under your service/host definitions.

This directive is used to specify the short name of the time period during which active checks of this [host, service] can be made.

This directive references a Nagios timeperiod object.

More info:
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/timeperiods.html
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/objectdefinitions.html#timeperiod
Former Nagios employee
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3470
Joined: Thu May 05, 2016 3:54 pm

Re: how can check specific sensors in specific time

Postby tgriep » Mon Oct 08, 2018 12:41 pm

Thanks @mcapra for the help.

What you would do is to setup a timeperiod line the example below and use that for your service's check_period.

Code: Select all
define timeperiod {
    timeperiod_name         not13to19
    alias                   Do not check from 13:00 to 19:00
    saturday                00:00-13:00,19:00-24:00
    friday                  00:00-13:00,19:00-24:00
    thursday                00:00-13:00,19:00-24:00
    wednesday               00:00-13:00,19:00-24:00
    tuesday                 00:00-13:00,19:00-24:00
    monday                  00:00-13:00,19:00-24:00
    sunday                  00:00-13:00,19:00-24:00
}

That way the service will only check between the hours of 00:00-13:00 and 19:00-24:00.

Try that out and post if you have any further questions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 7320
Joined: Thu Oct 30, 2014 9:02 am

Re: how can check specific sensors in specific time

Postby baber » Mon Oct 08, 2018 2:01 pm

thanks
but not work correctly

this is my timeperiod.cfg file

Code: Select all
###############################################################################
# TIMEPERIODS.CFG - SAMPLE TIMEPERIOD DEFINITIONS
#
#
# NOTES: This config file provides you with some example timeperiod definitions
#        that you can reference in host, service, contact, and dependency
#        definitions.
#       
#        You don't need to keep timeperiods in a separate file from your other
#        object definitions.  This has been done just to make things easier to
#        understand.
#
###############################################################################



###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################

# This defines a timeperiod where all times are valid for checks,
# notifications, etc.  The classic "24x7" support nightmare. :-)
define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }


# 'workhours' timeperiod definition
define timeperiod{
   timeperiod_name   workhours
   alias      Normal Work Hours
   monday      09:00-17:00
   tuesday      09:00-17:00
   wednesday   09:00-17:00
   thursday   09:00-17:00
   friday      09:00-17:00
   }


# 'none' timeperiod definition
define timeperiod{
   timeperiod_name   none
   alias      No Time Is A Good Time
   }


# Some U.S. holidays
# Note: The timeranges for each holiday are meant to *exclude* the holidays from being
# treated as a valid time for notifications, etc.  You probably don't want your pager
# going off on New Year's.  Although you're employer might... :-)
define timeperiod{
   name         us-holidays
        timeperiod_name         us-holidays
        alias                   U.S. Holidays

        january 1               00:00-00:00     ; New Years
        monday -1 may           00:00-00:00     ; Memorial Day (last Monday in May)
        july 4                  00:00-00:00     ; Independence Day
        monday 1 september      00:00-00:00     ; Labor Day (first Monday in September)
        thursday 4 november     00:00-00:00     ; Thanksgiving (4th Thursday in November)
        december 25             00:00-00:00     ; Christmas
        }


# This defines a modified "24x7" timeperiod that covers every day of the
# year, except for U.S. holidays (defined in the timeperiod above).
define timeperiod{
        timeperiod_name 24x7_sans_holidays
        alias           24x7 Sans Holidays

   use      us-holidays      ; Get holiday exceptions from other timeperiod

        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }

# 'Switch workhours' timeperiod definition
define timeperiod{
        timeperiod_name Switch_workhours
        alias           Switch Work Hours
        sunday          00:00-01:00,06:00-24:00
        monday          00:00-01:00,06:00-24:00
        tuesday         00:00-01:00,06:00-24:00
        wednesday       00:00-01:00,06:00-24:00
        thursday        00:00-01:00,06:00-24:00
        friday          00:00-01:00,06:00-24:00
        saturday        00:00-01:00,06:00-24:00
        }


define timeperiod{
         timeperiod_name                     Chakavakcustom
         alias                                  Chakavakcustom
         sunday                                  06:00-18:00
         monday                                06:00-18:00
         tuesday                                06:00-18:00
         wednesday                           06:00-18:00
         thursday                              06:00-18:00
         friday                                   06:00-18:00
         saturday                              06:00-18:00
}


and this is my server.cfg file

Code: Select all
define host{
   use      windows-server   ; Inherit default values from a template
   host_name   chakavakMQ-Live   ; The name we're giving to this host
   alias      server chakavakMQ-Live   ; A longer name associated with the host
   address   1.1.1.1   ; IP address of the host
   }


define service{
   use         local-service
   host_name      chakavakMQ-Live
   service_description   Memory Usage
       servicegroups        TS
   check_command      check_nt!MEMUSE!-w 90 -c 95
   }

#define service{
#   use         local-service
#   host_name      chakavakMQ-Live
#   service_description   Service
#       servicegroups        TS
#   check_command      check_nt!SERVICESTATE!-d SHOWALL -l SNMP
#   }

define service{
   use         local-service
   host_name      chakavakMQ-Live
   service_description   Cpu Usage
       servicegroups        TS
   check_command      check_nrpe!alias_cpu
   }

define service{
   use         local-service
   host_name      chakavakMQ-Live
   service_description   Disk Space
       servicegroups        TS
   check_command      check_nrpe!alias_volumes
   }

#define service{
#   use         local-service
#   host_name      chakavakMQ-Live
#   service_description   Uptime
#   check_command      check_nrpe!alias_up
#   }

#define service{
#   use         local-service
#   host_name      chakavakMQ-Live
#   service_description   Time
#   check_command      check_nrpe!check_windows_time
#   }


define service{
use          local-service
host_name       chakavakMQ-Live
service_description    channel1
servicegroups        TS
check_command       check_nrpe!check_mqstatuschannel_1
check_period      Chakavakcustom
}

#define service{
#use          local-service
#host_name       chakavakMQ-Live
#service_description    channel2
#check_command       check_nrpe!check_mqstatuschannel_2
#}

define service{
use          local-service
host_name       chakavakMQ-Live
service_description    channel2
servicegroups        TS
check_command       check_nrpe!check_mqstatuschannel_2
check_period      Chakavakcustom
}

define service{
use          local-service
host_name       chakavakMQ-Live
service_description    channel3
servicegroups        TS
check_command       check_nrpe!check_mqstatuschannel_3
check_period      Chakavakcustom
}

#define service{
#use          local-service
#host_name       chakavakMQ-Live
#service_description    channel5
#check_command       check_nrpe!check_mqstatuschannel_5
#}

define service{
use          local-service
host_name       chakavakMQ-Live
service_description    channel4
servicegroups        TS
check_command       check_nrpe!check_mqstatuschannel_4
check_period      Chakavakcustom
}



as show in previous codes i want check channel1,channel2,channel3,channel4 in al of days between 06:00-18:00 and not check in other times but this not work it now checking in all times
and my mean is after time 18:00 those services will critical and i want diable checking for not show this critical error in nagios
is that corect ?
baber
 
Posts: 283
Joined: Wed Oct 21, 2015 4:39 am

Re: how can check specific sensors in specific time

Postby tgriep » Mon Oct 08, 2018 2:22 pm

Did you restart the nagios process to load the changes?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 7320
Joined: Thu Oct 30, 2014 9:02 am

Re: how can check specific sensors in specific time

Postby baber » Mon Oct 08, 2018 2:46 pm

tgriep wrote:Did you restart the nagios process to load the changes?


yes
baber
 
Posts: 283
Joined: Wed Oct 21, 2015 4:39 am

Re: how can check specific sensors in specific time

Postby tgriep » Mon Oct 08, 2018 3:09 pm

What version of Nagios Core are you running?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 7320
Joined: Thu Oct 30, 2014 9:02 am

Re: how can check specific sensors in specific time

Postby baber » Thu Oct 11, 2018 6:54 am

tgriep wrote:What version of Nagios Core are you running?


so thanks my problem solved.
just want to know if i want it check all days of the week except fridays is follow correct ? ( i removed friday from the timeperiod)

define timeperiod{
timeperiod_name Chakavakcustom
alias Chakavakcustom
sunday 06:00-16:45
monday 06:00-16:45
tuesday 06:00-16:45
wednesday 06:00-16:45
thursday 06:00-13:30

saturday 06:00-16:45
}

BR
Babak
baber
 
Posts: 283
Joined: Wed Oct 21, 2015 4:39 am

Re: how can check specific sensors in specific time

Postby tgriep » Thu Oct 11, 2018 8:56 am

Yes, removing the Friday period is correct. It will not check on that day if it doesn't exist.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 7320
Joined: Thu Oct 30, 2014 9:02 am

Re: how can check specific sensors in specific time

Postby baber » Sat Oct 13, 2018 12:04 am

tgriep wrote:Yes, removing the Friday period is correct. It will not check on that day if it doesn't exist.


so thanks
my problem solved

BR
Babak
baber
 
Posts: 283
Joined: Wed Oct 21, 2015 4:39 am

Next

Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 38 guests