[ 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/iostat-parse.sh

#!/usr/bin/env bash
IFS=$' '
NUMBER=0
FROMFILE=$1
DISK=$2
METRIC=$3

[[ $# -lt 3 ]] && { echo "FATAL: some parameters not specified"; exit 1; }
[[ -f "$FROMFILE" ]] || { echo "FATAL: datafile not found"; exit 1; }

columns=$(iostat -x 1 1 |grep Device)
n=1
for i in $(echo "${columns}")
do
  if [[ "${i}" == "avgqu-sz" || "${i}" == "aqu-sz" ]];then
    avgqusz=$n
  elif [[ "${i}" == "r/s" ]];then
    rs_num=$n
  elif [[ "${i}" == *"util"* ]];then
    util_num=$n
  elif [[ "${i}" == "w/s" ]];then
    ws_num=$n
  fi
  n=$(( $n+1 ))
done


case "$3" in
"r/s")
  NUMBER=$rs_num
;;
"w/s")
  NUMBER=$ws_num
;;
"avgqu-sz")
  NUMBER=$avgqusz
;;
"util")
  NUMBER=$util_num
;;
*) echo ZBX_NOTSUPPORTED; exit 1 ;;
esac

grep -w $DISK $FROMFILE  | tr -s ' ' |awk -v N=$NUMBER 'BEGIN {sum=0.0;count=0;} {sum=sum+$N;count=count+1;} END {printf("%.2f\n", sum/count);}'

SEA-GHOST - SHELL CODING BY SEA-GHOST