apply Service "ssh" {
import "generic-service"
check_command = "ssh"
assign where (host.address || host.address6) && host.vars.os == "Linux"
}
Currently it sits in: /etc/icinga2/zones.d/global-templates/services.conf
But I would like to change the command_endpoint to just run on my master node. When I moved it to: /etc/icinga2/zones.d/master/services.conf
And added command_endpoint = NodeName I got this error:
[2024-08-11 21:42:43 -0400] critical/config: Error: Validation failed for object 'tesla.lan!ssh' of type 'Service'; Attribute 'command_endpoint': Command endpoint must be in zone 'tesla.lan' or in a direct child zone thereof.
Location: in /etc/icinga2/zones.d/master/services.conf: 90:1-90:19
/etc/icinga2/zones.d/master/services.conf(88): */
/etc/icinga2/zones.d/master/services.conf(89):
/etc/icinga2/zones.d/master/services.conf(90): apply Service "ssh" {
^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/master/services.conf(91): import "generic-service"
/etc/icinga2/zones.d/master/services.conf(92):
My question is:
How do I perform most of my checks from the agent, but have a few checks that the master runs?
I would prefer to have āpingā, āsshā, āhttpā etc checks to come from outside where as āserviceā checks and ādiskā checks should come from inside the host.
Storing object definitions in different directories does not change the where a check is executed. This is done within service objects. With command_endpoint configured it will be executed there, if not it will be executed on its parent.
NB: We are using Director, so I will speak only for the case when Director is used.
In Service Apply Rules, you canāt set the command_endpoint. You have to create different Service Templates, one for each command_endpoint, and then create one Service Apply Rule per Service Template.
You can use the same name for all Service Apply Rules, BUT if you do so, you have to make sure you do not apply more than one service with the same name to a host. In other words, your āAssign whereā clauses must be mutually exclusive for Apply Rules with the same name.
I moved the check back to global-templates and left the command_endpoint = NodeName (which is the master) and it crashed with a similar error:
[2024-08-12 10:29:10 -0400] critical/config: Error: Validation failed for object 'tesla.lan!ssh' of type 'Service'; Attribute 'command_endpoint': Command endpoint must be in zone 'tesla.lan' or in a direct child zone thereof.
Location: in /etc/icinga2/zones.d/global-templates/services.conf: 59:1-59:19
/etc/icinga2/zones.d/global-templates/services.conf(57): */
/etc/icinga2/zones.d/global-templates/services.conf(58):
/etc/icinga2/zones.d/global-templates/services.conf(59): apply Service "ssh" {
^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/global-templates/services.conf(60): import "generic-service"
/etc/icinga2/zones.d/global-templates/services.conf(61):
I created a new host, I put it in the master zone. This host I donāt want to install an agent on it, so putting it in the master zone makes sense.
I was able to perform ssh and ping checks from the master.
Note: this is exactly what I want for the other hosts, but I want to also run the agent and do additional checks locally.
It seems to me that the answer to my initial question is: āItās not possibleā but I wanted to confirm with someone that actually knows if this is the case.
This is the error I donāt understand, how it could be possible.
Just in case the wrapping is preventing other people from reading it:
Validation failed for object ātesla.lan!sshā of type āServiceā; Attribute ācommand_endpointā: Command endpoint must be in zone ātesla.lanā or in a direct child zone thereof.
Master isnāt the direct child zone of tesla.lan, itās the parent. which makes me think itās not possible to have a parent host check a child host?
Thank you for this comment. Iāve accepted this as the answer.
I think I have it working, if not Iāll post a new question on a fresh foot with my question.
I moved the host to the master zone, and now my other zone folders are empty (which confuses me a bit).
The endpoints are configured in the global template folder, so they donāt need to be movedā¦
I generally I really donāt understand why zone folders are used if I want everything on the master and global templatesā¦ I wonder if thereās any place I can read more about this.