LINUXOR.SK ... open source notes ...

Vault - keepalived_notify.sh (state file)

category: solutionz · date: 2024-12-31 · updated: 2026-10-02 · author: LALA

Vault Solution · Config document · referenced from Load balancer

A two-line script Keepalived calls on every state change. It overwrites one file with the last transition, so an operator or a monitoring item can ask a node which role it holds without parsing logs.

ItemValue
Path on the host/usr/local/bin/keepalived_notify.sh
Owner and moderoot:root, 0500
Deployed onboth load-balancer nodes of every cluster
Called bynotify in keepalived.conf
Writes/var/run/keepalived_status

The file

bash
#!/bin/bash

echo "$(date) - $1 $2 has transitioned to the $3 state with a priority of $4" > /var/run/keepalived_status

Arguments

ArgumentValue
$1INSTANCE or GROUP
$2Name of the instance, here haproxy_service
$3New state: MASTER, BACKUP or FAULT
$4Priority
← solutionz