HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/self/root/lib64/nagios/plugins/check_proxmox.sh
#!/bin/bash
# check_proxmox - check proxmox core services and statuses
# Requirements:
# Author: Tsvetan Gerov <[email protected]>
# 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