Skip to content

Instantly share code, notes, and snippets.

print("Writing to file: {0}, {1}, {2}, {3}".format(
timestamp, symmetrix_id, storage_group_id, srdfa_total))
with open('SRDFA_Reporter.csv', 'a') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar=',', quoting=csv.QUOTE_MINIMAL)
writer.writerow(timestamp, symmetrix_id,
storage_group_id, str(srdfa_total)])
srdf_total = 0
#Grab Total MB Sent for a given SG
for item in result:
srdf_total +=item['SRDFA_MBSent']
for storage_group_id in storage_group_list:
# For each SG in a given VMAX, get SRDFA_MBSent metric, sum it up
# across yesterday and write it out to csv file.
payload = generate_payload(symmetrix_id, storage_group_id)
headers = {
'content-type': 'application/json',
'accept': 'application/json'
}
ss_url = "https://" + location + "/univmax/restapi/performance/StorageGroup/metrics"
srdfa_response = requests.post(ss_url, data=json.dumps(payload),
# For each VMAX in Unisphere, get the storage Groups
for symmetrix_id in symmetrix_list:
sURL = "https://" + location + "/univmax/restapi/provisioning/symmetrix/" + \
symmetrix_id + "/storagegroup"
storage_group_response = requests.get(sURL, auth=(user, password), verify=False).json()
# Check if a message was returned. If there is a message, report the
# message and then skip to the next VMAX.
try:
symmetrix_list_response = requests.get(vURL, auth=(
user, password), verify=False).json()
if 'message' in symmetrix_list_response:
# I've seen an issue where Unisphere returns a message of "No Symmetrix's found.
message = symmetrix_list_response.get('message')
logger.critical(message)
sys.exit(1)
# Get all VMAXs for a given Unisphere Instance
vURL = "https://" + LOCATION + "/univmax/restapi/provisioning/symmetrix"
# If SRDFA_Reporter.csv file doesn't exist, create it with a header.
if not os.path.isfile('SRDFA_Reporter.csv'):
with open('SRDFA_Reporter.csv', 'w') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar=',', quoting=csv.QUOTE_MINIMAL)
writer.writerow(
['24h Period', 'Array', 'Storage Group', 'Total MB Sent by SRDFA'])
# Get today's midnight
midnight = datetime.combine(date.today(), dt_time.min)
# Convert to unix epoch time
unix_midnight = time.mktime(midnight.timetuple())
# Convert to milliseconds
unix_midnight *= 1000
# Remove trailing .0 float from the time
unix_midnight = str(unix_midnight).replace(".0", "")
# Get yesterday's midnight
# Get the URL from environmentals. Example: "10.241.209.162:8443"
try:
location = os.environ['SRUNILOCATION']
except KeyError:
logger.critical('Need an IP:Port. Please set the environment variable SRUNILOCATION to IP:Port of Unisphere '
'using either "export SRUNILOCATION=IP:PORT" (linux command) or "set SRUINLOCATION=IP:PORT" '
'(Windows command)')
sys.exit(1)
# Get credentials for Unisphere login from environmentals
#Date
TIMESTAMP = date.today() - timedelta(days=1)