Thanks for your response. You are correct… my case is i want to send warning alerts for 9*5 timeperiod… & all other alerts
For warning… I have made a separate templates.
Here, Notification template
template Notification "warning-host-notification" {
command = "mail-host-notification"
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += {
// notification_icingaweb2url = "https://www.example.com/icingaweb2"
// notification_from = "Icinga 2 Host Monitoring <icinga@example.com>"
notification_logtosyslog = false
}
period = "8to5"
}
/**
* Provides default settings for service notifications.
* By convention all service notifications should import
* this template.
*/
template Notification "warning-service-notification" {
command = "mail-service-notification"
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += {
// notification_icingaweb2url = "https://www.example.com/icingaweb2"
// notification_from = "Icinga 2 Service Monitoring <icinga@example.com>"
notification_logtosyslog = false
}
period = "8to5"
}
Here, Apply notification block.
apply Notification "warning-admin" to Host {
import "warning-host-notification"
user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users
#nterval = 0 // disable re-notification
interval = 4h
//vars.notification_logtosyslog = true
assign where host.vars.notification.mail
}
apply Notification "warning-admin" to Service {
import "warning-service-notification"
user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users
interval = 4h
#interval = 6h // disable re-notification
# assign where host.vars.notification.mail
assign where host.vars.notification.mail
}
In users.conf… I have defined as shown below.
object User "icingaadminwarn" {
import "generic-user"
display_name = "Notify icinga admin for warning"
enable_notifications = true
states = [ Warning ]
types = [ Problem ]
groups = [ "icingausers" ]
email = "Icinga_Admin@nicholasandco.com"
}
Does this make sense? on my all hostfiles…
we defined as shown below…
vars.notification["mail"] = {
groups = [ "icingausers" ]
users = [ "icingaadmin" ]
}
Does this make sense?