This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am ryandotclair on github. | |
* I am ryandotclair (https://keybase.io/ryandotclair) on keybase. | |
* I have a public key whose fingerprint is 0F49 1DA8 17C4 55CB 2277 AE75 8680 736B F859 2A37 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, unix_ym, unix_midnight) | |
headers = { | |
'content-type': 'application/json', | |
'accept': 'application/json' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
except ValueError: | |
logger.critical( | |
"Login failure. $SRUSER and $SRPASS credentials failed. Please confirm the environmental variables are " | |
"properly set with correct username/password") | |
sys.exit(1) | |
except Exception as e: | |
logger.critical( | |
"Unisphere couldn't be reached. Please confirm SRUNILOCATION environment variable is properly set and " | |
"Unisphere is up and running.. Details: {}".format(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
symmetrix_list_response = requests.get(vURL, auth=( | |
user, password), verify=False).json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
cursor = db_connection.cursor() | |
SQL = "SELECT EXISTS (SELECT key FROM reporterschema.main WHERE date = %s AND sn = %s AND sg = %s)" | |
DATA = (timestamp, symmetrix_id, storage_group_id) | |
cursor.execute(SQL, DATA) | |
if cursor.fetchall()[0][0]: | |
logger.warning("Record already exists in the database, skipping. Date:{0}, SN:{1}, " | |
"SG:{2}".format(timestamp, symmetrix_id, storage_group_id)) | |
cursor.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def record_exists(): | |
cursor = db_connection.cursor() | |
SQL = "SELECT EXISTS (SELECT key FROM reporterschema.main WHERE date = %s AND sn = %s AND sg = %s)" | |
DATA = (timestamp, symmetrix_id, storage_group_id) | |
cursor.execute(SQL, DATA) | |
if cursor.fetchall()[0][0]: | |
return True | |
else: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
from apscheduler.schedulers.blocking import BlockingScheduler | |
def generate_payload(symmetrix_id, storage_group_id, unix_ym, unix_midnight): | |
.... | |
def main(): | |
.... | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
psql --username "$POSTGRES_USER" -c "create database reporter;" | |
psql --username "$POSTGRES_USER" -d reporter -c "create schema reporterschema;" | |
psql --username "$POSTGRES_USER" -d reporter -c \ | |
"create table reporterschema.main(Key BIGSERIAL PRIMARY KEY,Date DATE NOT NULL,SN TEXT NOT NULL,SG TEXT NOT NULL,SRDFA_MBSent INT NOT NULL);" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Grab Total MB Sent for a given SG | |
for item in result: | |
srdfa_total += item['SRDFA_MBSent'] | |
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) |
NewerOlder