����JFIF��x�x����'403WebShell
403Webshell
Server IP : 78.140.185.180  /  Your IP : 18.218.161.96
Web Server : LiteSpeed
System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : builderbox ( 1072)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib64/nagios/plugins/base/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib64/nagios/plugins/base/check_whois
#!/bin/bash

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3

WARNING_DAYS=${WARNING_DAYS:="29"}
CRITICAL_DAYS=${CRITICAL_DAYS:="7"}

print_usage() {
        echo ""
        echo "Domain name expirtion check script for Nagios"
        echo ""
        echo "Usage: $0 -d example.com"
        echo ""
        echo "  -w|--warning  Warning days before domain expire (default 29)"
        echo "  Exit with WARNING status if domain expire less than warning days"
        echo "  -c|--critical  Crical days before domain expire (default 7)"
        echo "  Exit with CRITICAL status if domain expire less than critical day"
        echo "  -h|--host  Whois server to check (optinal)"
        echo "  -p|--port  Whois server port number (default : 43)"
        echo "  -t|--timeout  Timeout in seconds (default : 60)"
        echo "  --help  Show this page"
        echo ""
    echo "Usage: $0"
    echo "Usage: $0 --help"
    echo ""
    exit 0
}

print_help() {
    print_usage
        echo ""
        echo "This plugin will check domain name expiration date"
        echo ""
        exit 0
}

while [ $# -gt 0 ]; do
    case "$1" in
        --help)
            print_help
            exit $STATE_UNKNOWN
            ;;
        -d | --domain)
                shift
                DOMAIN=$1
                ;;
        -h | --host)
                shift
                HOST=$1
                ;;
        -w | --warning)
                shift
                WARNING_DAYS=$1
                ;;
        -c | --critical)
               shift
               CRITICAL_DAYS=$1
               ;;
        -p | --port)
               shift
               CRITICAL_DAYS=$1
               ;;
        -t | --timeout)
               shift
               TIMEOUT=$1
               ;;
    *)  echo "Unknown argument: $1"
            print_usage
            exit $STATE_UNKNOWN
            ;;
        esac
shift
done

if [ ! -z "$HOST" ]; then
    HOST="-h $HOST"
fi
if [ -z "$TIMEOUT" ]; then
        TIMEOUT="60"
fi
if [ -z "$PORT" ]; then
    PORT='43'
fi
if [ -z "$DOMAIN" ]; then
    echo "DOMAIN must be specified"
    print_usage
    exit $STATE_UNKNOWN
fi
expireDate=$(timeout "$TIMEOUT"s whois $HOST -p $PORT $DOMAIN | egrep -m 1 'Registration Expiration Date|Registry Expiry Date' | awk '{print $NF}'| cut -c1-10)
if [ -z $expireDate ]; then
    echo "CRITICAL: Can't Get $DOMAIN Expiration Date"
    exit $STATE_CRITICAL
fi
currentDate=`date +%s`

expireDate=`date +%s --date="$expireDate"`

### Difference between expiration and right now
timeDiffSec=`expr $expireDate - $currentDate`

### Convert to days (86400 seconds in a day)
timeDiffDays=`expr $timeDiffSec / 86400`

if [ $timeDiffDays -lt $CRITICAL_DAYS ]; then
    echo "CRITICAL: $timeDiffDays Left Until $DOMAIN Expiration"
    exit $STATE_CRITICAL
fi

if [ $timeDiffDays -lt $WARNING_DAYS ]; then
    echo "WARNING: $timeDiffDays Left Until $DOMAIN Expiration"
    exit $STATE_WARNING
fi

if [ $timeDiffDays -gt $WARNING_DAYS ]; then
    echo "OK: $timeDiffDays Left Until $DOMAIN Expiration"
    exit $STATE_OK
fi

Youez - 2016 - github.com/yon3zu
LinuXploit