Skip to content

Commit 6b2fd41

Browse files
kcantrelgithub-actions[bot]
authored andcommitted
Apply automatic changes
1 parent e678856 commit 6b2fd41

File tree

2 files changed

+1537
-10
lines changed

2 files changed

+1537
-10
lines changed

Monitoring/monitor-ontap-services/cloudformation.yaml.bak

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -959,11 +959,11 @@ Resources:
959959
if response.status == 200:
960960
data = json.loads(response.data)
961961
for aggr in data["records"]:
962-
if (aggr["space"]["block_storage"]["used"]/aggr["space"]["block_storage"]["size"]) * 100 >= rule[key]:
962+
if aggr["space"]["block_storage"]["used_percent"] >= rule[key]:
963963
uniqueIdentifier = aggr["uuid"] + "_" + key
964964
if not eventExist(events, uniqueIdentifier): # This resets the "refresh" field if found.
965965
alertType = 'Warning' if lkey == "aggrwarnpercentused" else 'Critical'
966-
message = f'Aggregate {alertType} Alert: Aggregate {aggr["name"]} on {clusterName} is more than {rule[key]} full.'
966+
message = f'Aggregate {alertType} Alert: Aggregate {aggr["name"]} on {clusterName} is {aggr["space"]["block_storage"]["used_precent"]}% full, which is more or equal to {rule[key]}% full.'
967967
logger.warning(message)
968968
snsClient.publish(TopicArn=config["snsTopicArn"], Message=message, Subject=f'Monitor ONTAP Services Alert for cluster {clusterName}')
969969
changedEvents = True
@@ -978,18 +978,18 @@ Resources:
978978
print(f'API call to {endpoint} failed. HTTP status code {response.status}.')
979979
elif lkey == "volumewarnpercentused" or lkey == "volumecriticalpercentused":
980980
#
981-
# Run the API call to get the physical storage used.
981+
# Run the API call to get the volume information.
982982
endpoint = f'https://{config["OntapAdminServer"]}/api/storage/volumes?fields=space,svm'
983983
response = http.request('GET', endpoint, headers=headers)
984984
if response.status == 200:
985985
data = json.loads(response.data)
986986
for record in data["records"]:
987-
if record["space"].get("logical_space") and record["space"]["logical_space"].get("used_percent"):
988-
if record["space"]["logical_space"]["used_percent"] >= rule[key]:
987+
if record["space"].get("used_percent"):
988+
if record["space"]["used_percent"] >= rule[key]:
989989
uniqueIdentifier = record["uuid"] + "_" + key
990990
if not eventExist(events, uniqueIdentifier): # This resets the "refresh" field if found.
991991
alertType = 'Warning' if lkey == "volumewarnpercentused" else 'Critical'
992-
message = f'Volume Usage {alertType} Alert: volume {record["svm"]["name"]}:/{record["name"]} on {clusterName} is {record["space"]["logical_space"]["used_percent"]}% full, which is more than {rule[key]}% full.'
992+
message = f'Volume Usage {alertType} Alert: volume {record["svm"]["name"]}:/{record["name"]} on {clusterName} is {record["space"]["used_percent"]}% full, which is more or equal to {rule[key]}% full.'
993993
logger.warning(message)
994994
snsClient.publish(TopicArn=config["snsTopicArn"], Message=message, Subject=f'Monitor ONTAP Services Alert for cluster {clusterName}')
995995
changedEvents = True
@@ -1379,17 +1379,22 @@ Resources:
13791379
if config[filename] == None:
13801380
config[filename] = config["OntapAdminServer"] + "-" + filename.replace("Filename", "")
13811381
#
1382-
# Define the endpoints if an alternate wasn't already given.
1382+
# Define the endpoints if alternates weren't provided.
1383+
if config.get("secretArn") != None:
1384+
secretRegion = config["secretArn"].split(":")[3]
1385+
else:
1386+
#
1387+
# Give it a value so secretsManagerEndPointHostname can be set. The check for all variables will correctly error out because secretArn is missing.
1388+
secretRegion = "No-secretArn-was-provided"
13831389
if config["secretsManagerEndPointHostname"] == None or config["secretsManagerEndPointHostname"] == "":
1384-
config["secretsManagerEndPointHostname"] = f'secretsmanager.{config["secretRegion"]}.amazonaws.com'
1390+
config["secretsManagerEndPointHostname"] = f'secretsmanager.{secretRegion}.amazonaws.com'
13851391

13861392
if config.get("snsTopicArn") != None:
13871393
snsRegion = config["snsTopicArn"].split(":")[3]
13881394
else:
13891395
#
13901396
# Give it a value so snsEndPointHostname can be set. The check for all variables will correctly error out because snsTopicArn is missing.
13911397
snsRegion = "No-snsTopicArn-was-provided"
1392-
13931398
if config["snsEndPointHostname"] == None or config["snsEndPointHostname"] == "":
13941399
config["snsEndPointHostname"] = f'sns.{snsRegion}.amazonaws.com'
13951400
#
@@ -1447,7 +1452,8 @@ Resources:
14471452
#
14481453
# Create a Secrets Manager client.
14491454
session = boto3.session.Session()
1450-
client = session.client(service_name='secretsmanager', region_name=config["secretRegion"], endpoint_url=f'https://{config["secretsManagerEndPointHostname"]}')
1455+
secretRegion = config["secretArn"].split(":")[3]
1456+
client = session.client(service_name='secretsmanager', region_name=secretRegion, endpoint_url=f'https://{config["secretsManagerEndPointHostname"]}')
14511457
#
14521458
# Get the username and password of the ONTAP/FSxN system.
14531459
secretsInfo = client.get_secret_value(SecretId=config["secretArn"])

0 commit comments

Comments
 (0)