Basic configuration
The configuration file is located at /nagios_installation_path/etc/nagios.cfg
Log File
Format: log_file=<file_name>
Example: log_file=/usr/local/nagios/var/nagios.log
This variable specifies where Nagios should create its main log file. This should be the first variable that you define in your configuration file, as Nagios will try to write errors that it finds in the rest of your configuration data to this file. If you have log rotation enabled, this file will automatically be rotated every hour, day, week, or month.
Object Configuration File
Format: cfg_file=<file_name>
Example: cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg
This directive is used to specify an object configuration file containing object definitions that Nagios should use for monitoring. Object configuration files contain definitions for hosts, host groups, contacts, contact groups, services, commands, etc. You can seperate your configuration information into several files and specify multiple cfg_file= statements to have each of them processed.
Object Configuration Directory
Format: cfg_dir=<directory_name>
Example: cfg_dir=/usr/local/nagios/etc/commands
cfg_dir=/usr/local/nagios/etc/services
cfg_dir=/usr/local/nagios/etc/hosts
This directive is used to specify a directory which contains object configuration files that Nagios should use for monitoring. All files in the directory with a .cfg extension are processed as object config files. Additionally, Nagios will recursively process all config files in subdirectories of the directory you specify here. You can seperate your configuration files into different directories and specify multiple cfg_dir= statements to have all config files in each directory processed.
Time period
The configuration file is in /usr/local/nagios/etc/objects/timeperiods.cfg
E.g. the default 24X7 is in following format:
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 }
There is also a timeperiod called workhours:
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 }
If you want to create a period according to your own business need, e.g. I created a period called myhours:
# 'Myhours' definition define timeperiod{ timeperiod_name myhours alias 13 Hours A Day, 5 Days A Week monday 08:00-21:00 tuesday 08:00-21:00 wednesday 08:00-21:00 thursday 08:00-21:00 friday 08:00-21:00 }
Then we will use myhours in the host definition.
How Time Periods Work With Host and Service Checks
Host and service definitions have an optional check_period directive that allows you to specify a timeperiod that should be used to restrict when regularly scheduled, active checks of the host or service can be made.
If you do not use the check_period directive to specify a timeperiod, Nagios will be able to schedule active checks of the host or service anytime it needs to. This is essentially a 24×7 monitoring scenario.
define host{ use linux-server host_name host1 address host1.mydomain.com hostgroups my-hosts check_period myhours }
Specifying a timeperiod in the check_period directive allows you to restrict the time that Nagios perform regularly scheduled, active checks of the host or service. When Nagios attempts to reschedule a host or service check, it will make sure that the next check falls within a valid time range within the defined timeperiod. If it doesn’t, Nagios will adjust the next check time to coincide with the next “valid” time in the specified timeperiod. This means that the host or service may not get checked again for another hour, day, or week, etc.
reference
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/configmain.html