[ SEA-GHOST MINI SHELL]

Path : /proc/2/task/2/root/proc/3/root/proc/self/root/proc/2/cwd/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/task/2/root/proc/3/root/proc/self/root/proc/2/cwd/var/lib/zabbix/installatron.sh

#!/bin/bash

lastMin="5"
LVL=$1

errors="$(grep "$(TZ=UTC date -d "$lastMin minutes ago" +"%m/%d/%Y:%H:%M")" -A 999999 /usr/local/cpanel/logs/access_log | grep "HTTP/1.1\" 500 " | grep installatron | wc -l)"

function for_zabbix() {
  if  (($errors >= $LVL )); then
    echo 1
  elif (( $errors < $LVL )); then
    echo 0
  else
    echo 100500
  fi
}

function show_help() {
  echo "Check of installatron 500 errors";
  echo "Usage: SCRIPT_FILENAME [AMOUNT_OF_ERRORS] [OPTION]"
  echo "AMOUNT_OF_ERRORS:"
  echo "any integer value 1,2,3 etc."
  echo "OPTIONS:"
  echo "  -??        : get text messages with detail issues data"
  echo "  -h|--help : get list of possible parameters"
  echo "  -c        : get  numeric value for zabbix"
  exit 0
}

function general_use() {
  if  (($errors >= $LVL )); then
    echo "ERROR: $errors installatron http 500 errors occured over the past $lastMin min"
  elif (( $errors < $LVL )); then
    echo "OK: There is no installatron http 500 errors over the past $lastMin min"
  else
    echo "INFO: something goes wrong"
  fi
}

# === MAIN PART =================
# get command line options
if [[ $# -eq 2 ]];then
  key="$2"
  case "$key" in
    -c)
    for_zabbix
    ;;
    -??)
    general_use
    ;;
    # Show help flag
    -h|--help)
    show_help
    ;;
    *)
    # Do whatever you want with extra options
    echo "Wrong key, please use -h for help menu"
    ;;
  esac
  shift
else
  echo "Not enough arguments. 1 - amount of minutes 2 - an available key from a help menu."
  show_help
fi


SEA-GHOST - SHELL CODING BY SEA-GHOST