Simple nagios check script to monitor pve-zsync included

mailinglists

Renowned Member
Mar 14, 2012
643
70
93
I just took 5 minutes and wrote this, as there are no nagios plugins existing for monitoring pve-zsync jobs.
Haven't really tested it yet, just sent it to my coworker, but I guess it should work as expected.
Feel free to make it more advanced, share your mods back or just use as is.
Code:
root@fer:/usr/local/nagios/libexec# cat check_pveZsync.sh
#!/bin/bash
# Poop simple script to check Proxmox pve-zsync.
# ExitCode:
# 0 = Ok
# 1 = Warning
# 2 = Critical
# 4 = Ok (No replicatons configured)

if [ ! "`pve-zsync list | awk '{print $3}' | grep -v ok | grep -v syncing | grep -v STATE`" ]
    then
    echo "OK: No pve-zsync jobs or all in OK / syncing state."
    exit 0

        elif [ "`pve-zsync list | awk '{print $3}' | grep stopped | grep -v STATE`" ]
        then
            echo "WARNING: Some jobs are in a stopped state. Please check."
            exit 1
        elif [ "`pve-zsync list | awk '{print $3}' | grep -v stopped | grep -v ok | grep -v syncing | grep -v STATE`" ]
        then
            echo "CRITICAL: Some jobs are in a failed state! Please check."
            exit 2
        fi
fi
root@fer:/usr/local/nagios/libexec# ./check_pveZsync.sh
OK: No pve-zsync jobs or all in OK / syncing state.
 
  • Like
Reactions: Moayad and guletz
Did something happen on copy/paste? The if statement is nested at 'elsif' and has two 'fi' for closing the statement.