HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
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