File: //lib64/nagios/plugins/check_proxmox.sh
#!/bin/bash
# check_proxmox - check proxmox core services and statuses
# Requirements:
# Author: Tsvetan Gerov <tsvetan@worldhost.group>
# Version 0.1
# Initialize flags and error message
CRTIICAL=false
WARNING=false
ERROR_MESSAGE=""
check_pveproxy(){
if ! systemctl is-active pveproxy >/dev/null 2>&1; then
CRTIICAL=true
ERROR_MESSAGE+="PVE Proxy is down, "
fi
}
check_cluster(){
CSTATUS=$(pvesh get /cluster/status --output-format=yaml | grep quorate | awk '{print$2}')
if [ "$CSTATUS" != "1" ]; then
CRTIICAL=true
ERROR_MESSAGE+="Check Cluster Quorum, "
fi
}
# Perform checks
check_pveproxy
check_cluster
# Return final state
if [ "$CRTIICAL" = true ]; then
echo "[CRTIICAL] ${ERROR_MESSAGE%, }"
exit 2
elif [ "$WARNING" = true ]; then
echo "[WARNING] ${ERROR_MESSAGE%, }"
exit 1
else
echo "[OK] All services are running correctly."
exit 0
fi