Define Notifications chain specific to Windows Service

Hi Team,

I have been trying to implement the email notification for specific windows system service. Here, Service apply as shown below…

apply Service "AmazonSSMAgent" {

  check_command = "service-windows"

  vars.service_win_service = "AmazonSSMAgent" //access the host custom var

  command_endpoint = host.vars.client_endpoint

  assign where host.vars.SSM == "AmazonSSMAgent" && host.vars.client_endpoint

}

Notification apply is shown below…

apply Notification "mail-icingaadmin" to Service {
  import "mail-service-notification"
  user_groups = host.vars.notification.mail.groups
  users = host.vars.notification.mail.users
  #interval = 0 // disable re-notification
  //vars.notification_logtosyslog = true
  assign where host.vars.notification.mail
}

I have been looking the above post… I think configurations should be as shown below.

 apply Service "AmazonSSMAgent" {
       check_command = "service-windows"
      vars.service_win_service = "AmazonSSMAgent" //access the host custom var
      vars. custom_notifications_users = ["username1@domain.com", "username2@domain.com"]
      command_endpoint = host.vars.client_endpoint
      assign where host.vars.SSM == "AmazonSSMAgent" && host.vars.client_endpoint
    }

     apply Notification "custom-mail-icingaadmin" to Service {
      import "mail-service-notification"
      user_groups = host.vars.notification.mail.groups
      users = service.vars.notification.mail.users
      #interval = 0 // disable re-notification
      //vars.notification_logtosyslog = true
      assign where service.vars.custom_notification_users.len() > 0
    }

Is these are are configurations that i should make? with an existing configurations can you suggest me the things that i need to perform?

Thanks in advance

Any help would be much appreciated here? thanks in advance

Hello there!

I would like to ask you not to bump your topics please :slight_smile:
This forum is run for and by the community answering questions in their spare time.
Most of us have been taking time off over the holidays, so please be patient :slight_smile:

Have a nice week
Feu

Hello,
this will never work. Because you set the users in variable custom_notifications_users , but you use service.vars.notification.mail.users in your notification apply rule.

You have to use the same variable to set the users to be notificated.

apply Notification "custom-mail-icingaadmin" to Service {
      import "mail-service-notification"
      user_groups = host.vars.notification.mail.groups
      users = service.vars.custom_notifications_users 
      #interval = 0 // disable re-notification
      //vars.notification_logtosyslog = true
      assign where service.vars.custom_notification_users.len() > 0
}

If you have users assigned in the template of the notification rule you can use users += service.vars.custom_notifications_users to merge both arrays (users/groups have to an array always, see the docs)

Regards,
Carsten