Template and script below checks the status of Keepalived Processes
This template consist of a Zabbix template and a simple monitoring script. The Keepalived VRRP instance notifys the script when a change happens. The Script writes the Status of the VRRP instance into a temporary file. The Zabbix agent then reads the content of the file with vfs.file.regmatch and reports it to the Zabbix server. Unfortunately I am only able to test and provide a template for Zabbix Version 5.0.
-
Copy the Script to the keepalived Node into
/usr/local/bin/keepalived_notify.sh
-
Make it executable and owned by root
chmod 751 /usr/local/bin/keepalived_notify.sh chown root:root /usr/local/bin/keepalived_notify.sh
-
Add the notify Parameter to the Keepalived config
vrrp_instance VRRP_1 { [...] notify "/usr/local/bin/keepalived_notify.sh" }
-
Import the Zabbix template to your Zabbix instance.
-
Add the template to the hosts in Zabbix
#!/bin/bash
#Write status to temporaray file.
touch /var/run/keepalived_status
chmod 0644 /var/run/keepalived_status
echo "$1 $2 has transitioned to the $3 state with a priority of $4" > /var/run/keepalived_status
DerHerscher
There are no macros links in this template.
There are no template links in this template.
There are no discovery rules in this template.
Name | Description | Type | Key and additional info |
---|---|---|---|
Keepalived: is BACKUP | - |
Zabbix agent |
vfs.file.regmatch[/var/run/keepalived_status,^.(BACKUP).$] Update: 2m |
Keepalived: is MASTER | - |
Zabbix agent |
vfs.file.regmatch[/var/run/keepalived_status,^.(MASTER).$] Update: 2m |
Keepalived: process count | - |
Zabbix agent |
proc.num[keepalived]] Update: 2m |
Name | Description | Expression | Priority |
---|---|---|---|
Keepalived: state change from BACKUP to MASTER | - |
Expression: {Template App Keepalived:vfs.file.regmatch[/var/run/keepalived_status,^.(MASTER).$].prev()}=0 and {Template App Keepalived:vfs.file.regmatch[/var/run/keepalived_status,^.(MASTER).$].last()}=1 Recovery expression: |
average |
Keepalived: state change from MASTER to BACKUP | - |
Expression: {Template App Keepalived:vfs.file.regmatch[/var/run/keepalived_status,^.(MASTER).$].prev()}=1 and {Template App Keepalived:vfs.file.regmatch[/var/run/keepalived_status,^.(MASTER).$].last()}=0 Recovery expression: |
average |
Keepalived: state is BACKUP but it's stopped | - |
Expression: {Template App Keepalived:vfs.file.regmatch[/var/run/keepalived_status,^.(MASTER).$].last()}=0 and {Template App Keepalived:proc.num[keepalived].last()}<2 Recovery expression: |
high |
Keepalived: state is MASTER but it's stopped | - |
Expression: {Template App Keepalived:vfs.file.regmatch[/var/run/keepalived_status,^.(MASTER).$].last()}=1 and {Template App Keepalived:proc.num[keepalived].last()}<2 Recovery expression: |
disaster |