Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vmax.py #255

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://secure.travis-ci.org/ganglia/gmond_python_modules.png)](http://travis-ci.org/ganglia/gmond_python_modules)
Build Status](https://secure.travis-ci.org/ganglia/gmond_python_modules.png)](http://travis-ci.org/ganglia/gmond_python_modules)

This is the official repository for hosting all user-contributed Gmond Python DSO metric modules.

Expand All @@ -9,7 +9,7 @@ If you have any questions, you could reach us at:

ganglia-developers@lists.sourceforge.net

(subscription required: http://lists.sourceforge.net/lists/listinfo/ganglia-developers)
subscription required: http://lists.sourceforge.net/lists/listinfo/ganglia-developers)

Alternatively, you could join our IRC channel on irc.freenode.net #ganglia and
ping one of the developers.
Expand Down
64 changes: 32 additions & 32 deletions vmax/vmax.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python
# Name: vmax.py
# Desc: Ganglia module for polling the VMAX UniSphere REST interface for metrics
# Author: Evan Fraser evan.fraser@trademe.co.nz
# Date: July 2014
# Copyright: GPL
!/usr/bin/python
Name: vmax.py
Desc: Ganglia module for polling the VMAX UniSphere REST interface for metrics
Author: Evan Fraser evan.fraser@trademe.co.nz
Date: July 2014
Copyright: GPL


import json, os, pprint, re, requests, socket, sys, time
Expand All @@ -12,7 +12,7 @@

unispherePort = 8443

#This is the minimum interval between querying unisphere for metrics
This is the minimum interval between querying unisphere for metrics
METRICS_CACHE_MAX = 300

METRICS = {
Expand Down Expand Up @@ -103,8 +103,8 @@ def get_metric(name):
print "Short response"
pprint.pprint(responseObj)

### Now get the pool based metrics for each vmax.
#Start by getting the list of pools
Now get the pool based metrics for each vmax.
Start by getting the list of pools
baseurl = 'https://' + vmax_dict[key]['unisphereIP'] + ':' + str(unispherePort) + '/univmax/restapi/performance/ThinPool/keys'

requestObj = {'thinPoolKeyParam':
Expand All @@ -117,12 +117,12 @@ def get_metric(name):

headers = {'content-type': 'application/json','accept':'application/json'} #set the headers for how we want the response

#make the actual request, specifying the URL, the JSON from above, standard basic auth, the headers and not to verify the SSL cert.
make the actual request, specifying the URL, the JSON from above, standard basic auth, the headers and not to verify the SSL cert.

r = requests.post(baseurl, requestJSON, auth=(vmax_dict[key]['user'], vmax_dict[key]['pass']), headers=headers, verify=False)


#take the raw response text and deserialize it into a python object.
take the raw response text and deserialize it into a python object.
try:
responseObj = json.loads(r.text)
except:
Expand All @@ -145,10 +145,10 @@ def get_metric(name):

headers = {'content-type': 'application/json','accept':'application/json'} #set the headers for how we want the response

#make the actual request, specifying the URL, the JSON from above, standard basic auth, the headers and not to verify the SSL cert.
make the actual request, specifying the URL, the JSON from above, standard basic auth, the headers and not to verify the SSL cert.
r = requests.post(baseurl, requestJSON, auth=(vmax_dict[key]['user'], vmax_dict[key]['pass']), headers=headers, verify=False)

#take the raw response text and deserialize it into a python object.
take the raw response text and deserialize it into a python object.
try:
responseObj = json.loads(r.text)
except:
Expand Down Expand Up @@ -180,70 +180,70 @@ def get_metric(name):
return METRICS['data'][name]


# define_metrics will run an snmp query on an ipaddr, find interfaces, build descriptors and set spoof_host
# define_metrics is called from metric_init
define_metrics will run an snmp query on an ipaddr, find interfaces, build descriptors and set spoof_host
define_metrics is called from metric_init
def define_metrics(Desc_Skel, unisphereIP, sid, site):
global vmax_dict
spoof_string = unisphereIP + ':vmax_' + site
vmax_name = 'vmax_' + site

#FE Cache Hits/s
FE Cache Hits/s
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_cache_hits',
"units" : "iops",
"description" : "Cache Hits/s",
"groups" : "iops",
"spoof_host" : spoof_string,
}))
#FE Read IOPs
FE Read IOPs
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_fe_reads',
"units" : "iops",
"description" : "FE Read IOPs",
"groups" : "iops",
"spoof_host" : spoof_string,
}))
#FE Write IOPs
FE Write IOPs
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_fe_writes',
"units" : "iops",
"description" : "FE Write IOPs",
"groups" : "iops",
"spoof_host" : spoof_string,
}))
#Array MB_READ_PER_SEC
Array MB_READ_PER_SEC
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_megabytes_read',
"units" : "MB/s",
"description" : "Array MB/s Reads",
"groups" : "Throughput",
"spoof_host" : spoof_string,
}))
#Array MB_WRITE_PER_SEC
Array MB_WRITE_PER_SEC
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_megabytes_written',
"units" : "MB/s",
"description" : "Array MB/s Writes",
"groups" : "Throughput",
"spoof_host" : spoof_string,
}))
#Array RESPONSE_TIME_READ
Array RESPONSE_TIME_READ
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_response_time_read',
"units" : "ms",
"description" : "Array Read Response Time",
"groups" : "Latency",
"spoof_host" : spoof_string,
}))
#Array RESPONSE_TIME_WRITE
Array RESPONSE_TIME_WRITE
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_response_time_write',
"units" : "ms",
"description" : "Array Write Response Time",
"groups" : "Latency",
"spoof_host" : spoof_string,
}))
#Total Volume IO_RATE
Total Volume IO_RATE
descriptors.append(create_desc(Desc_Skel, {
"name" : vmax_name + '_vol_iorate',
"units" : "iops",
Expand All @@ -252,7 +252,7 @@ def define_metrics(Desc_Skel, unisphereIP, sid, site):
"spoof_host" : spoof_string,
}))

###Perform API query to get list of Thinpools
Perform API query to get list of Thinpools

baseurl = 'https://' + unisphereIP + ':8443/univmax/restapi/performance/ThinPool/keys'

Expand Down Expand Up @@ -298,7 +298,7 @@ def define_metrics(Desc_Skel, unisphereIP, sid, site):
"spoof_host" : spoof_string,
}))

#BE_RESPONSE_TIME_READ
BE_RESPONSE_TIME_READ
descriptors.append(create_desc(Desc_Skel, {
"name" : str(vmax_name + '_' + pool["poolId"] + '_response_time_reads'),
"units" : "ms",
Expand All @@ -307,23 +307,23 @@ def define_metrics(Desc_Skel, unisphereIP, sid, site):
"spoof_host" : spoof_string,
}))

#BE_RESPONSE_TIME_WRITE
BE_RESPONSE_TIME_WRITE
descriptors.append(create_desc(Desc_Skel, {
"name" : str(vmax_name + '_' + pool["poolId"] + '_response_time_writes'),
"units" : "ms",
"description" : "Pool BE Write Latency",
"groups" : "Latency",
"spoof_host" : spoof_string,
}))
#BE_MB_READ_RATE
BE_MB_READ_RATE
descriptors.append(create_desc(Desc_Skel, {
"name" : str(vmax_name + '_' + pool["poolId"] + '_megabytes_read'),
"units" : "MB/s",
"description" : "Pool BE MB/s read",
"groups" : "Throughput",
"spoof_host" : spoof_string,
}))
#BE_MB_WRITE_RATE
BE_MB_WRITE_RATE
descriptors.append(create_desc(Desc_Skel, {
"name" : str(vmax_name + '_' + pool["poolId"] + '_megabytes_written'),
"units" : "MB/s",
Expand All @@ -341,7 +341,7 @@ def metric_init(params):
print '[switch] Received the following parameters'
print params

#Import the params into the global NIPARAMS
Import the params into the global NIPARAMS

Desc_Skel = {
'name' : 'XXX',
Expand All @@ -355,11 +355,11 @@ def metric_init(params):
'groups' : 'switch',
}

# Find all the vmax's passed in params
Find all the vmax's passed in params
for vmax in vmax_dict:
# pass skel, ip and name to define_metrics to create descriptors
descriptors = define_metrics(Desc_Skel, vmax_dict[vmax]['unisphereIP'], vmax_dict[vmax]['sid'], vmax_dict[vmax]['site'])
#Return the descriptors back to gmond
Return the descriptors back to gmond
return descriptors

def create_desc(skel, prop):
Expand All @@ -373,7 +373,7 @@ def metric_cleanup():
'''Clean up the metric module.'''
pass

# For CLI Debuging:
For CLI Debuging:
if __name__ == '__main__':
params = {
}
Expand Down
Loading