403Webshell
Server IP : 198.38.94.67  /  Your IP : 216.73.217.178
Web Server : LiteSpeed
System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
User : azfilmst ( 1070)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib64/nagios/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib64/nagios/plugins/check_icinga_hosts.sh
#!/bin/bash

usage() {
    echo " check_icinga_hosts - Icinga check for number of services"
    echo ""
    echo " Usage: check_icinga_hosts -w <warning threshold> -c <critical threshold> [ -h ]"
    echo ""
    echo "       -w  Service count at which a warning is triggered"
    echo "       -c  Service count at which a critical is triggered"
    echo "       -h  Show this page"
    echo ""
}

cmdopts() {
    if ( `test 0 -lt $#` )
    then
        while getopts w:c:h myarg "$@"
        do
            case $myarg in
                h|\?)
                    usage
                    exit;;
                w)
                    WARNING=$OPTARG;;
                c)
                    CRITICAL=$OPTARG;;
                *)
                    usage
                    exit;;
            esac
        done
    else
        usage
        exit
    fi
}

cmdopts $@

# Get the host count from Icinga2
HOST_COUNT=$(icinga2 daemon -C | grep "information/ConfigItem: Instantiated" | grep "Services" | awk '{print $6}')

# Check if we got a valid number
if [[ "$HOST_COUNT" =~ ^[0-9]+$ ]]; then
    if [ "$HOST_COUNT" -ge "$CRITICAL" ]
    then
        echo "CRITICAL: Icinga Services count is at $HOST_COUNT (threshold: $CRITICAL)";
        exit 2;
    elif [ "$HOST_COUNT" -ge "$WARNING" ]
    then
        echo "WARNING: Icinga Services count is at $HOST_COUNT (threshold: $WARNING)";
        exit 1;
    else
        echo "OK: Icinga Services count is at $HOST_COUNT";
        exit 0;
    fi
else
    echo "UNKNOWN: Could not determine services count"
    exit 3
fi

Youez - 2016 - github.com/yon3zu
LinuXploit