403Webshell
Server IP : 66.29.132.122  /  Your IP : 18.226.172.230
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/self/root/proc/thread-self/root/lib64/nagios/plugins/nccustom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/root/proc/thread-self/root/lib64/nagios/plugins/nccustom/check-cpanel-update.sh
#!/bin/bash

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

resultFile="/var/log/nc_audit/check_sec_updates"
agetreshold=16 # 16 hours

#input option

PROGNAME=${0##*/}

print_usage() {
    echo ""
    echo "Usage: $PROGNAME [-f Diff path] [-a file Age treshold, hours]"
    echo "Usage: $PROGNAME -h | --help"
}

print_help() {
    print_usage
    echo ""
    echo "This script check cPanel security updates (see TOP-347)"
    echo ""
    echo "-f Different path and file. Default - /var/log/nc_audit/check_sec_updates"
    echo "-a Age treshold for logfiles, hours. Default - 16"
    echo "-h help Print this help screen"
    echo "--help Print this help screen"
    echo ""
    exit 3
}

while [ $# -gt 0 ]; do

    case "$1" in
        -f)
         resultFile=$2; shift
         ;;

        -a)
        agetreshold=$2; shift
        ;;

        --help)
        print_help
        exit 3
         ;;

        -h)
        print_help
        exit 3
         ;;

        *)
        echo >&2 "Unknown argument: $1"
        print_usage
        exit 3
        ;;

        esac
        shift
done

#file existence

if [ ! -f "$resultFile" ]; then
    echo "UNKNOWN. $resultFile no file"
    exit 3
fi

#check age file

resultFileAge=$((($(date +%s) - $(date +%s -r "${resultFile}")) / 3600))    # in hours

if (( resultFileAge > agetreshold )) ; then
    echo "UNKNOWN. File ${resultFile} older than ${agetreshold} hours"
    exit 3
fi

#checking file status

read -r firstline<"$resultFile"

firstline_code=$(echo "${firstline}" | awk '{print$1}' | sed 's/\[\|\]://g')

case "${firstline_code}" in

    "OK" )
    exitcode="0"
    ;;

    "FAILED" | "CRITICAL" )
    exitcode="2"
    ;;

    * )                         #Unknown state
    firstline="UNKNOWN. String from $resultFile does not match any pattern"
    exitcode="3"
    ;;

esac

echo "$firstline"
exit "$exitcode"

Youez - 2016 - github.com/yon3zu
LinuXploit