Skip to content

Ph0B1uS/keepalived-zabbix-template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Keepalived

Overview

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.

Usage

  1. Copy the Script to the keepalived Node into /usr/local/bin/keepalived_notify.sh

  2. Make it executable and owned by root

    chmod 751 /usr/local/bin/keepalived_notify.sh
    chown root:root /usr/local/bin/keepalived_notify.sh
    
  3. Add the notify Parameter to the Keepalived config

    vrrp_instance VRRP_1 {
        [...]
        notify "/usr/local/bin/keepalived_notify.sh"
    }
    
  4. Import the Zabbix template to your Zabbix instance.

  5. Add the template to the hosts in Zabbix


keepalived_notify.sh Script:

#!/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

Author

DerHerscher

Macros used

There are no macros links in this template.

Template links

There are no template links in this template.

Discovery rules

There are no discovery rules in this template.

Items collected

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

Triggers

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

About

This is a Template for Monitoring Keepalived instances

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%