Notification for one disk to two users

Hi all,

I’m new to Icinga2, I’m currently amending a running setup (r2.14.3-1 , Debian Bullseye) where all alerts go to one email address.

Another team are responsible for the contents of a mount point (/srv) on a certain host and have asked that they be emailed when it reaches a certain percentage (copy should also be delivered to the email address all other alerts are sent to).

So far I have added another Icinga user to users.conf, users.conf reads as below:

object User "the_it_team" {
  import "generic-user"

  display_name = "The IT Team"

  email = "email_address_of_it_team@company.com"
}

object User "teamsrvdir" {

  import "generic-user"

  display_name = "team responsible for srv dir"

  email = "email_address_srvdir@company.com"

I’ve been reading the docs and I am aware that you can override vars in Host object as below.

Hosts file for machine being monitored:

File: /etc/icinga2/conf.d/objects.d/machine_being_monitored.conf

object Host "hostname_being_monitored" {
  import "it_team_master_template"

  address = "machine_being_monitored_fqdn"
  vars.distro = "Debian"
  vars.distrover = 12
  vars.type = "production"
  vars.service_manager = "systemd"
  
    vars.ssh_port = "ssh_port_number"

  vars.ssh_ports = {
    "SSH port <port number listening on>" = {
      ssh_port = "<port number listening on>"
    }
  }
  vars.ssh_ports["SSH port <number>"] = {
    ssh_port = "<ssh port number>"
  }
   
  vars.disks["Disk /mount_point"] = {
    disk_partitions = "/mount_point"
  } 
 
    vars.notification["mail"] = {
    users = [ "teamsrvdir" ]
  }

}

This currently emails all alerts for this host to object User “teamsrvdir”, should I add another user to users.conf with the email address email_address_of_itteam@company.com and make both members of one group so both get the email.

So that only the alerts for /srv go to this group does the below need to be indented according so it is part of vars.disks["Disk /mount_point"] (I’m not clear on how to do this) :

vars.notification[“mail”] = {
users = [ “other_team_responsible_for_srv” ]

Many thanks

Daniel

Thanks for posting and welcome to both Icinga and the Icinga Community.

Who gets notified is specified through Notification objects, usually created via apply to rules, as documented in the “Apply Notifications to Hosts and Services” chapter.

Thus, if I have understood you correctly, you want all notifications to go to your usual IT team, the_it_team, and in addition send out notifications for the /srv to the other team, teamsrvdir.

You should be able to achieve this with another Notification object similar to the following.

apply Notification "mail-teamsrvdir" to Service {
  import "mail-service-notification"

  users = [ "teamsrvdir" ]

  assign where service.name == "disk" && service.vars.disk_partitions == "/srv"
}

Of course, I have not actually tested this example, also because I don’t know how your other Notification objects look like. Thus, please compare this one with your other ones, probably defined in conf.d/notification.sh.

Hi Alvar,

Thanks for your kind welcome and prompt help, very much appreciated.

For the below line I changed ==disk to the service name showing in the web interface and then it worked as expected:


assign where service.name == "disk" && service.vars.disk_partitions == "/srv"

Many thanks

Daniel

Hi @dan-monitor-ct,

just a suggestion, you can use the Icinga Director. so you can manage all configs, users, hosts, service etc.

thanks
Kemal