Page 1 of 2

Time of Email Notifications

Posted: Tue Apr 17, 2018 9:13 am
by TBlaine27
I am using Nagios Core v3

in my objects folder, I have a hosts.cfg file containing a list of IP/hosts I am just monitoring ping to see up/down state.

I am using postfix, and email notifications work great.

The problem is, Nagios is only sending out email notifications between 9am - 5pm daily, and none on weekends.

Where do I find and set this to send alerts 24x7

Thanks!

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 10:09 am
by scottwilkerson
You would have another config for the contact that is receiving the messages, assigned to that is a timeperiod for the host_notification_period and service_notification_period.

This timeperiod is another configuration that has days and times in it. Once modified you would need to restart the nagios service for the changes to take affect

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 12:27 pm
by TBlaine27
This is my current contacts.cfg ---


define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias FINY ALERT ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email,notify-service-by-sms
host_notification_commands notify-host-by-email,notify-host-by-sms
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
pager +15555555555 ; <<***** CHANGE THIS TO YOUR PHONE NUMBER ******
}


define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 12:56 pm
by scottwilkerson
so this is the timeperiods specified

Code: Select all

service_notification_period 24x7
host_notification_period 24x7
now you need to find the timeperiod definition for 24x7

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 2:44 pm
by TBlaine27
would this need to be specified in my hosts.cfg file for each individual host?

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 2:46 pm
by TBlaine27
my hosts.cfg file is a long list like this..

define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name WiFi-AP-HR
alias WiFi-AP-HR
address 192.168.1.7
}

define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name WiFi-AP-Training
alias WiFi-AP-Training
address 192.168.1.6
}

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 2:53 pm
by scottwilkerson
No, these are contact definitions
https://assets.nagios.com/downloads/nag ... ml#contact

Did you fine the timeperiod definition for 24x7?

This is what they look like but the timeperiod_name would be 24x7
https://assets.nagios.com/downloads/nag ... timeperiod

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 2:57 pm
by TBlaine27
contacts.cfg

define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias FINY ALERT ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email,notify-service-by-sms
host_notification_commands notify-host-by-email,notify-host-by-sms
email [email protected],[email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
pager +17168706854 ; <<***** CHANGE THIS TO YOUR PHONE NUMBER ******
}

define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 2:59 pm
by TBlaine27
timeperiods.cfg


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
}

Re: Time of Email Notifications

Posted: Tue Apr 17, 2018 3:10 pm
by scottwilkerson
Are you sure YOUR contact isn't set to use workhours because that looks like 9-5

Are you the nagiosadmin contact only, or is that your only contact?