In the case where volumes have not yet been defined the list_volumes call returns 400 . If this exception is captured, the check will complete for the other sections.
<<<df>>>
Traceback (most recent call last):
File "./agent_pure", line 209, in <module>
get_volumes()
File "./agent_pure", line 168, in get_volumes
for volume in FA.list_volumes(names=["*"], space=True):
File "/omd/sites/us2/.local/lib/python3.8/site-packages/purestorage/purestorage.py", line 773, in list_volumes
return self._request("GET", "volume", kwargs)
File "/omd/sites/us2/.local/lib/python3.8/site-packages/purestorage/purestorage.py", line 202, in _request
raise PureHTTPError(self._target, str(self._rest_version), response)
purestorage.purestorage.PureHTTPError: PureHTTPError status code 400 returned by REST version 1.19 at us2pure01: BAD REQUEST
[{"msg": "No matching volumes found.", "ctx": "*"}]
The following code changes will handle this:
$ git diff
diff --git a/pure/src/agents/special/agent_pure b/pure/src/agents/special/agent_pure
index f5819e9..a184eb3 100755
--- a/pure/src/agents/special/agent_pure
+++ b/pure/src/agents/special/agent_pure
@@ -169,16 +169,16 @@ def get_volumes():
fs_used = (int(volume['volumes']) + int(volume['snapshots']))
fs_free = (int(volume['size']) - int(volume['volumes']) - (volume['snapshots']))
print(f"{volume['name']} {int(volume['size'])} {int(fs_used)} {int(fs_free)} / {volume['name']}")
- except OSError:
- print(f"Could not get volumes")
+ except (OSError,purestorage.PureHTTPError) as excp:
+ print(f"Could not get volumes - {excp}")
def get_arrayperformance():
print("<<<pure_arrayperformance>>>")
try:
for perfometer in FA.list_volumes(names=["*"], action='monitor'):
print(f"{perfometer['name']} {perfometer['reads_per_sec']} {perfometer['writes_per_sec']} {perfometer['output_per_sec']} {perfometer['input_per_sec']} {perfometer['usec_per_read_op']} {perfometer['usec_per_write_op']}")
- except OSError:
- print(f"Could not get array volume performance")
+ except (OSError,purestorage.PureHTTPError) as excp:
+ print(f"Could not get array volume performance - {excp}")
def get_arraydetails():
print("<<<pure_arraydetails>>>")
@@ -186,8 +186,8 @@ def get_arraydetails():
for details in FA.list_volumes(names=["*"], space=True):
print(f"{details['name']} {details['data_reduction']} {details['total_reduction']} {details['shared_space']} {details['thin_provisioning']} {details['snapshots']} {details['volumes']} {details['size']}")
- except OSError:
- print(f"Could not get array volume details")
+ except (OSError,purestorage.PureHTTPError) as excp:
+ print(f"Could not get array volume details - {excp}")
if __name__ == '__main__':
get_alerts()```
In the case where volumes have not yet been defined the list_volumes call returns 400 . If this exception is captured, the check will complete for the other sections.
The following code changes will handle this: