I’ve a pacemaker cluster where various haproxy daemons are running, each of them has ists own admin.sock file. The admin.sock file exists sometimes on server A and sometimes on server B.
I try to combine the “assigne where” rule with the check of the existense of the admin.sock file but havn’t find any example.
apply Service "Haproxy: stats" {
import "generic-service"
check_command = "haproxy_status"
vars.haproxy_status_socket = "/run/haproxy/msx/admin.sock"
vars.haproxy_status_default = "d,1,2,,"
command_endpoint = host.name
assign where match ("deblb*", host.name) and ??? haproxy_status_socket exists???
}
apply Service "file_age: " for (file_age => config in host.vars.file_age) {
import "generic-service"
check_command = "file_age"
command_endpoint = host.name
vars += config
assign where match ("deblb1*", host.name)
assign where match ("deblb2*", host.name)
}
and have in the hosts file the following variables:
I’m sorry, this was not a good idea since you would need a reload when the cluster changes.
A better idea is to keep the new checks and use their results in the existing check. If the new check reports admin.sock does not exist (you can get the result with get_objects), it overwrites its check result with e.g. “OK - haproxy inactive”.
I’m sorry I’ve no idea how to use the results of the file_age check in the haproxy_status check. I havn’t found any “assign where” rule examples which are using check results in the docs.
To handle the absence of one paticular socket file is a second step - I want to understand how the system works if the sockets are there.