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
<h1>Hello <%= node['apache']['greeting'] %>!</h1> | |
<p>My IP address is <%= node['ipaddress'] %></p> |
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
{ | |
"name" : "webserver", | |
"default_attributes": { | |
"apache" : { | |
"greeting" : "Person" | |
} | |
}, | |
"run_list" : [ | |
"recipe[apache]" | |
] |
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
#! /usr/bin/env python3 |
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
import requests | |
import json | |
import time | |
import os | |
import logging | |
import sys | |
import csv | |
from datetime import datetime, date, timedelta | |
from datetime import time as dt_time |
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
logging.basicConfig( | |
level=logging.getLevelName('DEBUG'), | |
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', | |
filename='SRDFA_Reporter_Error.log') | |
console_write = logging.StreamHandler() | |
console_write.setLevel(logging.getLevelName('INFO')) | |
logger = logging.getLogger() | |
logger.addHandler(console_write) |
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
# Disable warnings from untrusted server certificates | |
try: | |
from requests.packages.urllib3.exceptions import InsecureRequestWarning | |
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | |
except Exception: | |
logger.info("Ignore messages related to insecure SSL certificates") |
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
#Date | |
TIMESTAMP = date.today() - timedelta(days=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
# 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 |
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
# 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 |
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 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']) |