@@ -612,8 +612,8 @@ Resources:
612612 # "matching conditions." It is intended to be run as a Lambda function, but
613613 # can be run as a standalone program.
614614 #
615- # Version: v2.15
616- # Date: 2025-05-19-08:28:59
615+ # Version: v2.1
616+ # Date: 2025-05-20-01:22:58
617617 ################################################################################
618618
619619 import json
@@ -929,7 +929,7 @@ Resources:
929929 event["refresh"] -= 1
930930 #
931931 # Run the API call to get the current list of EMS events.
932- endpoint = f'https://{config["OntapAdminServer"]}/api/support/ems/events'
932+ endpoint = f'https://{config["OntapAdminServer"]}/api/support/ems/events?return_timeout=15 '
933933 response = http.request('GET', endpoint, headers=headers)
934934 if response.status == 200:
935935 data = json.loads(response.data)
@@ -1059,7 +1059,7 @@ Resources:
10591059 daysOfWeek = ""
10601060 #
10611061 # Run the API call to get the schedule information.
1062- endpoint = f'https://{config["OntapAdminServer"]}/api/cluster/schedules/{scheduleUUID}?fields=*'
1062+ endpoint = f'https://{config["OntapAdminServer"]}/api/cluster/schedules/{scheduleUUID}?fields=*&return_timeout=15 '
10631063 response = http.request('GET', endpoint, headers=headers)
10641064 if response.status == 200:
10651065 schedule = json.loads(response.data)
@@ -1111,7 +1111,7 @@ Resources:
11111111 global config, http, headers, clusterName, clusterVersion, logger
11121112
11131113 # Run the API call to get the policy information.
1114- endpoint = f'https://{config["OntapAdminServer"]}/api/snapmirror/policies/{policyUUID}?fields=*'
1114+ endpoint = f'https://{config["OntapAdminServer"]}/api/snapmirror/policies/{policyUUID}?fields=*&return_timeout=15 '
11151115 response = http.request('GET', endpoint, headers=headers)
11161116 if response.status == 200:
11171117 data = json.loads(response.data)
@@ -1214,7 +1214,7 @@ Resources:
12141214 logger.warning(f'Unknown snapmirror alert type: "{key}".')
12151215 #
12161216 # Run the API call to get the current state of all the snapmirror relationships.
1217- endpoint = f'https://{config["OntapAdminServer"]}/api/snapmirror/relationships?fields=*'
1217+ endpoint = f'https://{config["OntapAdminServer"]}/api/snapmirror/relationships?fields=*&return_timeout=15 '
12181218 response = http.request('GET', endpoint, headers=headers)
12191219 if response.status == 200:
12201220 data = json.loads(response.data)
@@ -1388,18 +1388,29 @@ Resources:
13881388 event["refresh"] -= 1
13891389 #
13901390 # Run the API call to get the physical storage used.
1391- endpoint = f'https://{config["OntapAdminServer"]}/api/storage/aggregates?fields=space'
1391+ endpoint = f'https://{config["OntapAdminServer"]}/api/storage/aggregates?fields=space&return_timeout=15 '
13921392 aggrResponse = http.request('GET', endpoint, headers=headers)
13931393 if aggrResponse.status != 200:
13941394 logger.error(f'API call to {endpoint} failed. HTTP status code {aggrResponse.status}.')
13951395 aggrResponse = None
13961396 #
13971397 # Run the API call to get the volume information.
1398- endpoint = f'https://{config["OntapAdminServer"]}/api/storage/volumes?fields=space,files,svm,state'
1398+ endpoint = f'https://{config["OntapAdminServer"]}/api/storage/volumes?fields=space,files,svm,state&return_timeout=15 '
13991399 volumeResponse = http.request('GET', endpoint, headers=headers)
14001400 if volumeResponse.status != 200:
14011401 logger.error(f'API call to {endpoint} failed. HTTP status code {volumeResponse.status}.')
14021402 volumeResponse = None
1403+ volumeRecords = None
1404+ else:
1405+ volumeRecords = json.loads(volumeResponse.data).get("records")
1406+ #
1407+ # Now get the constituent volumes.
1408+ endpoint = f'https://{config["OntapAdminServer"]}/api/storage/volumes?is_constituent=true&fields=space,files,svm,state&return_timeout=15'
1409+ volumeResponse = http.request('GET', endpoint, headers=headers)
1410+ if volumeResponse.status != 200:
1411+ logger.error(f'API call to {endpoint} failed. HTTP status code {volumeResponse.status}.')
1412+ else:
1413+ volumeRecords.extend(json.loads(volumeResponse.data).get("records"))
14031414 #
14041415 # If both API calls failed, no point on continuing.
14051416 if volumeResponse is None and aggrResponse is None:
@@ -1428,8 +1439,7 @@ Resources:
14281439 events.append(event)
14291440 elif lkey == "volumewarnpercentused" or lkey == "volumecriticalpercentused":
14301441 if volumeResponse is not None:
1431- data = json.loads(volumeResponse.data)
1432- for record in data["records"]:
1442+ for record in volumeRecords:
14331443 if record["space"].get("percent_used"):
14341444 if record["space"]["percent_used"] >= rule[key]:
14351445 uniqueIdentifier = record["uuid"] + "_" + key
@@ -1446,8 +1456,7 @@ Resources:
14461456 events.append(event)
14471457 elif lkey == "volumewarnfilespercentused" or lkey == "volumecriticalfilespercentused":
14481458 if volumeResponse is not None:
1449- data = json.loads(volumeResponse.data)
1450- for record in data["records"]:
1459+ for record in volumeRecords:
14511460 #
14521461 # If a volume is offline, the API will not report the "files" information.
14531462 if record.get("files") is not None:
@@ -1469,8 +1478,7 @@ Resources:
14691478 }
14701479 events.append(event)
14711480 elif lkey == "offline":
1472- data = json.loads(volumeResponse.data)
1473- for record in data["records"]:
1481+ for record in volumeRecords:
14741482 if rule[key] and record["state"].lower() == "offline":
14751483 uniqueIdentifier = f'{record["uuid"]}_{key}_{rule[key]}'
14761484 if not eventExist(events, uniqueIdentifier): # This resets the "refresh" field if found.
@@ -1510,7 +1518,6 @@ Resources:
15101518 def sendAlert(message, severity):
15111519 global config, snsClient, logger, cloudWatchClient
15121520
1513-
15141521 if severity == "CRITICAL":
15151522 logger.critical(message)
15161523 elif severity == "ERROR":
@@ -1579,7 +1586,7 @@ Resources:
15791586 event["refresh"] -= 1
15801587 #
15811588 # Run the API call to get the quota report.
1582- endpoint = f'https://{config["OntapAdminServer"]}/api/storage/quota/reports?fields=*'
1589+ endpoint = f'https://{config["OntapAdminServer"]}/api/storage/quota/reports?fields=*&return_timeout=30 '
15831590 response = http.request('GET', endpoint, headers=headers)
15841591 if response.status == 200:
15851592 data = json.loads(response.data)
@@ -1744,7 +1751,7 @@ Resources:
17441751 if vserverState is not None and vserverState:
17451752 #
17461753 # Run the API call to get the vserver state for each vserver.
1747- endpoint = f'https://{config["OntapAdminServer"]}/api/svm/svms?fields=state'
1754+ endpoint = f'https://{config["OntapAdminServer"]}/api/svm/svms?fields=state&return_timeout=15 '
17481755 response = http.request('GET', endpoint, headers=headers)
17491756 if response.status == 200:
17501757 data = json.loads(response.data)
@@ -1767,7 +1774,7 @@ Resources:
17671774 if nfsProtocolState is not None and nfsProtocolState:
17681775 #
17691776 # Run the API call to get the NFS protocol state for each vserver.
1770- endpoint = f'https://{config["OntapAdminServer"]}/api/protocols/nfs/services?fields=state'
1777+ endpoint = f'https://{config["OntapAdminServer"]}/api/protocols/nfs/services?fields=state&return_timeout=15 '
17711778 response = http.request('GET', endpoint, headers=headers)
17721779 if response.status == 200:
17731780 data = json.loads(response.data)
@@ -1790,7 +1797,7 @@ Resources:
17901797 if cifsProtocolState is not None and cifsProtocolState:
17911798 #
17921799 # Run the API call to get the NFS protocol state for each vserver.
1793- endpoint = f'https://{config["OntapAdminServer"]}/api/protocols/cifs/services?fields=enabled'
1800+ endpoint = f'https://{config["OntapAdminServer"]}/api/protocols/cifs/services?fields=enabled&return_timeout=15 '
17941801 response = http.request('GET', endpoint, headers=headers)
17951802 if response.status == 200:
17961803 data = json.loads(response.data)
0 commit comments