Server IP : 162.0.209.157 / Your IP : 3.145.78.12 [ Web Server : LiteSpeed System : Linux premium178.web-hosting.com 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : balaoqob ( 2395) PHP Version : 8.0.30 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /lib64/nagios/plugins/nccustom/ |
Upload File : |
#!/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"