@@ -335,7 +335,7 @@ def processEMSEvents(service):
335335 event ["refresh" ] -= 1
336336 #
337337 # Run the API call to get the current list of EMS events.
338- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/support/ems/events'
338+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/support/ems/events?return_timeout=15 '
339339 response = http .request ('GET' , endpoint , headers = headers )
340340 if response .status == 200 :
341341 data = json .loads (response .data )
@@ -465,7 +465,7 @@ def getLastRunTime(scheduleUUID):
465465 daysOfWeek = ""
466466 #
467467 # Run the API call to get the schedule information.
468- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/cluster/schedules/{ scheduleUUID } ?fields=*'
468+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/cluster/schedules/{ scheduleUUID } ?fields=*&return_timeout=15 '
469469 response = http .request ('GET' , endpoint , headers = headers )
470470 if response .status == 200 :
471471 schedule = json .loads (response .data )
@@ -517,7 +517,7 @@ def getPolicySchedule(policyUUID):
517517 global config , http , headers , clusterName , clusterVersion , logger
518518
519519 # Run the API call to get the policy information.
520- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/snapmirror/policies/{ policyUUID } ?fields=*'
520+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/snapmirror/policies/{ policyUUID } ?fields=*&return_timeout=15 '
521521 response = http .request ('GET' , endpoint , headers = headers )
522522 if response .status == 200 :
523523 data = json .loads (response .data )
@@ -620,7 +620,7 @@ def processSnapMirrorRelationships(service):
620620 logger .warning (f'Unknown snapmirror alert type: "{ key } ".' )
621621 #
622622 # Run the API call to get the current state of all the snapmirror relationships.
623- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/snapmirror/relationships?fields=*'
623+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/snapmirror/relationships?fields=*&return_timeout=15 '
624624 response = http .request ('GET' , endpoint , headers = headers )
625625 if response .status == 200 :
626626 data = json .loads (response .data )
@@ -794,18 +794,29 @@ def processStorageUtilization(service):
794794 event ["refresh" ] -= 1
795795 #
796796 # Run the API call to get the physical storage used.
797- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/storage/aggregates?fields=space'
797+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/storage/aggregates?fields=space&return_timeout=15 '
798798 aggrResponse = http .request ('GET' , endpoint , headers = headers )
799799 if aggrResponse .status != 200 :
800800 logger .error (f'API call to { endpoint } failed. HTTP status code { aggrResponse .status } .' )
801801 aggrResponse = None
802802 #
803803 # Run the API call to get the volume information.
804- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/storage/volumes?fields=space,files,svm,state'
804+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/storage/volumes?fields=space,files,svm,state&return_timeout=15 '
805805 volumeResponse = http .request ('GET' , endpoint , headers = headers )
806806 if volumeResponse .status != 200 :
807807 logger .error (f'API call to { endpoint } failed. HTTP status code { volumeResponse .status } .' )
808808 volumeResponse = None
809+ volumeRecords = None
810+ else :
811+ volumeRecords = json .loads (volumeResponse .data ).get ("records" )
812+ #
813+ # Now get the constituent volumes.
814+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/storage/volumes?is_constituent=true&fields=space,files,svm,state&return_timeout=15'
815+ volumeResponse = http .request ('GET' , endpoint , headers = headers )
816+ if volumeResponse .status != 200 :
817+ logger .error (f'API call to { endpoint } failed. HTTP status code { volumeResponse .status } .' )
818+ else :
819+ volumeRecords .extend (json .loads (volumeResponse .data ).get ("records" ))
809820 #
810821 # If both API calls failed, no point on continuing.
811822 if volumeResponse is None and aggrResponse is None :
@@ -834,8 +845,7 @@ def processStorageUtilization(service):
834845 events .append (event )
835846 elif lkey == "volumewarnpercentused" or lkey == "volumecriticalpercentused" :
836847 if volumeResponse is not None :
837- data = json .loads (volumeResponse .data )
838- for record in data ["records" ]:
848+ for record in volumeRecords :
839849 if record ["space" ].get ("percent_used" ):
840850 if record ["space" ]["percent_used" ] >= rule [key ]:
841851 uniqueIdentifier = record ["uuid" ] + "_" + key
@@ -852,8 +862,7 @@ def processStorageUtilization(service):
852862 events .append (event )
853863 elif lkey == "volumewarnfilespercentused" or lkey == "volumecriticalfilespercentused" :
854864 if volumeResponse is not None :
855- data = json .loads (volumeResponse .data )
856- for record in data ["records" ]:
865+ for record in volumeRecords :
857866 #
858867 # If a volume is offline, the API will not report the "files" information.
859868 if record .get ("files" ) is not None :
@@ -875,8 +884,7 @@ def processStorageUtilization(service):
875884 }
876885 events .append (event )
877886 elif lkey == "offline" :
878- data = json .loads (volumeResponse .data )
879- for record in data ["records" ]:
887+ for record in volumeRecords :
880888 if rule [key ] and record ["state" ].lower () == "offline" :
881889 uniqueIdentifier = f'{ record ["uuid" ]} _{ key } _{ rule [key ]} '
882890 if not eventExist (events , uniqueIdentifier ): # This resets the "refresh" field if found.
@@ -916,7 +924,6 @@ def processStorageUtilization(service):
916924def sendAlert (message , severity ):
917925 global config , snsClient , logger , cloudWatchClient
918926
919-
920927 if severity == "CRITICAL" :
921928 logger .critical (message )
922929 elif severity == "ERROR" :
@@ -985,7 +992,7 @@ def processQuotaUtilization(service):
985992 event ["refresh" ] -= 1
986993 #
987994 # Run the API call to get the quota report.
988- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/storage/quota/reports?fields=*'
995+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/storage/quota/reports?fields=*&return_timeout=30 '
989996 response = http .request ('GET' , endpoint , headers = headers )
990997 if response .status == 200 :
991998 data = json .loads (response .data )
@@ -1150,7 +1157,7 @@ def processVserver(service):
11501157 if vserverState is not None and vserverState :
11511158 #
11521159 # Run the API call to get the vserver state for each vserver.
1153- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/svm/svms?fields=state'
1160+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/svm/svms?fields=state&return_timeout=15 '
11541161 response = http .request ('GET' , endpoint , headers = headers )
11551162 if response .status == 200 :
11561163 data = json .loads (response .data )
@@ -1173,7 +1180,7 @@ def processVserver(service):
11731180 if nfsProtocolState is not None and nfsProtocolState :
11741181 #
11751182 # Run the API call to get the NFS protocol state for each vserver.
1176- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/protocols/nfs/services?fields=state'
1183+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/protocols/nfs/services?fields=state&return_timeout=15 '
11771184 response = http .request ('GET' , endpoint , headers = headers )
11781185 if response .status == 200 :
11791186 data = json .loads (response .data )
@@ -1196,7 +1203,7 @@ def processVserver(service):
11961203 if cifsProtocolState is not None and cifsProtocolState :
11971204 #
11981205 # Run the API call to get the NFS protocol state for each vserver.
1199- endpoint = f'https://{ config ["OntapAdminServer" ]} /api/protocols/cifs/services?fields=enabled'
1206+ endpoint = f'https://{ config ["OntapAdminServer" ]} /api/protocols/cifs/services?fields=enabled&return_timeout=15 '
12001207 response = http .request ('GET' , endpoint , headers = headers )
12011208 if response .status == 200 :
12021209 data = json .loads (response .data )
0 commit comments