[ SEA-GHOST MINI SHELL]

Path : /proc/2/root/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/root/var/lib/zabbix/sla.sh

#!/bin/bash

API=$1
SID=$2
PERIOD=$3
#to=$(date +%s)
#from=$(date +%s -d "1 day ago")
COUNTER=0
SUMSLA=0

if [ $PERIOD == 1 ]; then
#currently day
  to=$(date +%s)
  from=$(date +%s -d "1 day ago")
elif [ $PERIOD == 2 ]; then
#Currently month
  to=$(date +%s)
  from=$(date +%s -d "1 month ago")
fi

#authenticate
   authenticate=$(curl -s -H  'Content-Type: application/json-rpc' -d "{\"jsonrpc\": \"2.0\",\"method\":\"user.login\",\"params\":{\"user\":\"monitoring-ldap-read\",\"password\":\"asd@#4sd3S#s3S!d56\"},\"auth\": null,\"id\":0}" $API)
   AUTH_TOKEN=`echo ${authenticate}|jq -r .result`


responce=$(curl -s -H 'Content-Type: application/json-rpc' -d "{\"jsonrpc\": \"2.0\",\"method\":\"service.get\",\"params\":{\"output\":\"extend\",\"selectDependencies\":\"extend\",\"serviceids\":\""${SID}"\"},\"auth\":\""${AUTH_TOKEN}"\",\"id\":1}" $API)
for LINE in $(echo ${responce}|jq . | grep "servicedownid"| awk {'print $2'}|sed "s/,//g")
  do
   SLA=$(curl -s -H 'Content-Type: application/json-rpc' -d "{\"jsonrpc\": \"2.0\",\"method\":\"service.getsla\",\"params\":{\"serviceids\":"${LINE}",\"intervals\":[{\"from\":\""${from}"\",\"to\":\""${to}"\"}]},\"auth\":\""${AUTH_TOKEN}"\",\"id\":1}" $API|jq .result."${LINE}".sla[0].sla)
#  echo $SLA
   if [ ! -z $SLA ]; then
     SUMSLA=$(echo "$SUMSLA + $SLA"| bc -l)
     COUNTER=$[COUNTER + 1]
   fi
done

AWGSLA=$(echo "scale=4; $SUMSLA/$COUNTER" | bc)

#echo "----------"
#echo "SUMSLA: $SUMSLA"
#echo "COUNTER: $COUNTER"
echo "$AWGSLA"


SEA-GHOST - SHELL CODING BY SEA-GHOST