Hello togehter,
i got two LB haproxy with keepalived. I do passive service checks for both services haproxy and keeplaived.
On LB02 i get Notification Mail for both services, but for LB01 i only get mail for keepalived.
Here is my hosts.conf.
object Host "dev-loadbalancer-01" {
address = "x.x.x.x"
check_command = "hostalive"
# Plugin Checks
vars.check_ssh = true
vars.check_load = true
vars.check_procs = true
vars.check_swap = true
vars.check_users = true
vars.check_apt = true
# OS
vars.os = "Linux"
# Passive Service Checks
vars.check_haproxy = true
vars.check_keepalived = true
# Disk Checks
vars.disks["disk /"] = {
disk_partition = "/"
disk_warning = "20%"
disk_critical = "10%"
}
vars.metric = "hostalive"
vars.notification["mail"] = {
groups = [ "icingaadmins" ]
}
}
object Host "dev-loadbalancer-02" {
address = "x.x.x.x"
check_command = "hostalive"
# Plugin Checks
vars.check_ssh = true
vars.check_load = true
vars.check_procs = true
vars.check_swap = true
vars.check_users = true
vars.check_apt = true
# OS
vars.os = "Linux"
# Passive Service Checks
vars.check_haproxy = true
vars.check_keepalived = true
# Disk Checks
vars.disks["disk /"] = {
disk_partition = "/"
disk_warning = "20%"
disk_critical = "10%"
}
vars.metric = "hostalive"
vars.notification["mail"] = {
groups = [ "icingaadmins" ]
}
}
apply Service:
apply Service "haproxy" {
check_command = "dummy"
vars.dummy_state = 1
vars.dummy_text = "Keine Daten"
vars.metric = "haproxy_service"
assign where host.vars.check_haproxy
}
my bashscript:
#!/bin/bash
if [ $(systemctl is-active haproxy) == 'active' ] > /dev/null
then
curl -k -s -u icingaweb2:xxxxx \
-H 'Accept: application/json' \
-X POST 'https://x.x.x.x/v1/actions/process-check-result?service=dev-loadbalancer-02!haproxy' \
-d '{ "exit_status":0, "plugin_output": "haproxy is running", "check_source": "passive" }'
curl -k -s -u icingaweb2:xxxxx \
-H 'Accept: application/json' \
-X POST 'https://192.x.x.x./v1/actions/process-check-result?service=dev-loadbalancer-02!haproxy' \
-d '{ "exit_status":0, "plugin_output": "haproxy is running", "check_source": "passive" }'
else
curl -k -s -u icingaweb2:xxxxxx \
-H 'Accept: application/json' \
-X POST 'https://x.x.x.x/v1/actions/process-check-result?service=dev-loadbalancer-02!haproxy' \
-d '{ "exit_status":2, "plugin_output": "haproxy is down", "check_source": "passive" }'
curl -k -s -u icingaweb2:xxxxx \
-H 'Accept: application/json' \
-X POST 'https://x.x.x.x/v1/actions/process-check-result?service=dev-loadbalancer-02!haproxy' \
-d '{ "exit_status":2, "plugin_output": "haproxy is down", "check_source": "passive" }'
fi
Here the debug.log when i shutdown haproxy.service LB01:
tail -F /var/log/icinga2/debug.log | grep "dev-loadbalancer-01\!haproxy"
[2019-08-21 11:05:01 +0200] debug/HttpRequest: line: POST /v1/actions/process-check-result?service=dev-loadbalancer-01!haproxy HTTP/1.1, tokens: 3
[2019-08-21 11:05:01 +0200] debug/DbEvents: add log entry history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:05:01 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:05:01 +0200] debug/DbEvents: add state change history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:05:01 +0200] notice/Checkable: State Change: Checkable 'dev-loadbalancer-01!haproxy' soft state change from OK to CRITICAL detected.
[2019-08-21 11:05:01 +0200] debug/DbEvents: add log entry history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:05:01 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:05:01 +0200] debug/DbEvents: add state change history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:05:01 +0200] notice/Checkable: State Change: Checkable 'dev-loadbalancer-01!haproxy' soft state change from CRITICAL to CRITICAL detected.
[2019-08-21 11:06:01 +0200] debug/HttpRequest: line: POST /v1/actions/process-check-result?service=dev-loadbalancer-01!haproxy HTTP/1.1, tokens: 3
[2019-08-21 11:06:01 +0200] debug/DbEvents: add log entry history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:06:01 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:06:01 +0200] debug/DbEvents: add state change history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:06:01 +0200] notice/Checkable: State Change: Checkable 'dev-loadbalancer-01!haproxy' hard state change from CRITICAL to CRITICAL detected.
[2019-08-21 11:06:01 +0200] information/Checkable: Checking for configured notifications for object 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:06:01 +0200] debug/Checkable: Checkable 'dev-loadbalancer-01!haproxy' has 1 notification(s).
[2019-08-21 11:06:02 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-01!haproxy'
[2019-08-21 11:07:01 +0200] debug/HttpRequest: line: POST /v1/actions/process-check-result?service=dev-loadbalancer-01!haproxy HTTP/1.1, tokens: 3
Here for LB02:
[2019-08-21 11:26:01 +0200] debug/HttpRequest: line: POST /v1/actions/process-check-result?service=dev-loadbalancer-02!haproxy HTTP/1.1, tokens: 3
[2019-08-21 11:26:01 +0200] debug/DbEvents: add log entry history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:26:01 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:26:01 +0200] debug/DbEvents: add state change history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:26:01 +0200] notice/Checkable: State Change: Checkable 'dev-loadbalancer-02!haproxy' soft state change from OK to CRITICAL detected.
[2019-08-21 11:26:01 +0200] notice/Checkable: Skipping event handler for HA-paused checkable 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:26:01 +0200] debug/DbEvents: add log entry history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:26:01 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:26:01 +0200] debug/DbEvents: add state change history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:26:01 +0200] notice/Checkable: State Change: Checkable 'dev-loadbalancer-02!haproxy' soft state change from CRITICAL to CRITICAL detected.
[2019-08-21 11:26:01 +0200] notice/Checkable: Skipping event handler for HA-paused checkable 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] debug/HttpRequest: line: POST /v1/actions/process-check-result?service=dev-loadbalancer-02!haproxy HTTP/1.1, tokens: 3
[2019-08-21 11:27:01 +0200] debug/DbEvents: add log entry history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] debug/DbEvents: add state change history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] notice/Checkable: State Change: Checkable 'dev-loadbalancer-02!haproxy' hard state change from CRITICAL to CRITICAL detected.
[2019-08-21 11:27:01 +0200] notice/Checkable: Skipping event handler for HA-paused checkable 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] information/Checkable: Checking for configured notifications for object 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] debug/Checkable: Checkable 'dev-loadbalancer-02!haproxy' has 1 notification(s).
[2019-08-21 11:27:01 +0200] notice/Notification: Attempting to send notifications for notification object 'dev-loadbalancer-02!haproxy!mail-icingaadmin'.
[2019-08-21 11:27:01 +0200] information/Notification: Sending 'Problem' notification 'dev-loadbalancer-02!haproxy!mail-icingaadmin' for user 'icingaadmin'
[2019-08-21 11:27:01 +0200] debug/DbEvents: add notification history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] debug/DbEvents: add contact notification history for service 'dev-loadbalancer-02!haproxy' and user 'icingaadmin'.
[2019-08-21 11:27:01 +0200] debug/DbEvents: add log entry history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:01 +0200] information/Notification: Completed sending 'Problem' notification 'dev-loadbalancer-02!haproxy!mail-icingaadmin' for checkable 'dev-loadbalancer-02!haproxy' and user 'icingaadmin'.
[2019-08-21 11:27:02 +0200] debug/DbEvents: add checkable check history for 'dev-loadbalancer-02!haproxy'
[2019-08-21 11:27:02 +0200] warning/PluginNotificationTask: Notification command for object 'dev-loadbalancer-02!haproxy' (PID: 19874, arguments: '/etc/icinga2/scripts/mail-service-notification.sh' '-4' '192.168.2.101' '-6' '' '-b' '' '-c' '' '-d' '2019-08-21 11:27:01 +0200' '-e' 'haproxy' '-l' 'dev-loadbalancer-02' '-n' 'dev-loadbalancer-02' '-o' 'haproxy is down' '-r' 'monitoring@stashcat.com' '-s' 'CRITICAL' '-t' 'PROBLEM' '-u' 'haproxy' '-v' 'true') terminated with exit code 1, output: GPGME: CMS protocol not available
So i cant understand why for LB02 everything is working and LB01 only misses the haporxy service check notification mail.
Can you help?
Kind regards
Sebo