Hello,
I am running icinga2 + icinga2 web on postrges. My goal is to have separate conf file for each server I would like to monitor (windows and linux servers) on the server I am running icinga2 agent and have few services predefined based on OS.
I am trying to modify default services.conf. So for example service load. I thought that I just add this:
assign where host.vars.os == “Linux”
because thats what I define at my host conf file. BUT I found out, that service assigns to correct host ( I see service load at my debiantest host in icingaweb2) but the datas I mean true load is read from my localhost, where icinga runs (tested through stress command on endpoint)
What I have to do is to explicitly define that service (HOST EDIT). But that quiet doesn’t make sense to me to redo over and over. The point is not to write the service again and again at every config file its like 50 servers so far but to define default service load (and others) and assign those templates to servers based on their custom variables (for example vars.os.linux / windows).
I must admit, that I am not very skilled with icinga stuff. I am trying to find everything in docs, but this does not make sense to me. Could you please help me?
SERVICE
apply Service “load” {
import “generic-service”
check_command = “load”
/* Used by the ScheduledDowntime apply rule in downtimes.conf
. */
vars.backup_downtime = “02:00-03:00”
#assign where host.name == NodeName
assign where host.vars.os == “Linux”
}
apply Service for (disk => config in host.vars.disks) {
import “generic-service”
check_command = “disk”
vars += config
}
HOST:
object Host “debiantest.mydomain.loc” {
import “Generic Host Template”
address = “192.168.0.118”
vars.os = “Linux”
vars.disk[“disk /”] = {
disk_partitions = “/”
}
check_command = “hostalive”
}
object Endpoint “debiantest.mydomain.loc” {
host = “192.168.0.118”
}
object Zone “debiantest.jazzy.cz” {
endpoints = [“debiantest.mydomain.loc”]
parent = “master”
HOST EDIT
object Host “debiantest.mydomain.loc” {
import “Generic Host Template”
address = “192.168.0.118”
vars.os = “Linux”
vars.disk[“disk /”] = {
disk_partitions = “/”
}
check_command = “hostalive”
}
object Endpoint “debiantest.mydomain.loc” {
host = “192.168.0.118”
}
object Zone “debiantest.mydomain.loc” {
endpoints = [“debiantest.mydomain.loc”]
parent = “master”
}
object Service “load” {
host_name = “debiantest.mydomain.loc”
check_command = “load”
command_endpoint = “debiantest.mydomain.loc”
}