Skip to content

Commit

Permalink
Some disks doesnt report device speed correctly, when we assign pd_de…
Browse files Browse the repository at this point in the history
…vice_speed metric a string value: Unknown, script execution crashes, in that case assign a 0 speed value.

Signed-off-by: kr0m <[email protected]>
  • Loading branch information
kr0m authored and kr0m committed Sep 2, 2023
1 parent 34dd42e commit 9370d8d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions storcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,15 @@ def create_metrics_of_physical_drive(physical_drive, detailed_info_array, contro
metrics["pd_link_speed"].labels(controller_index, enclosure, slot).set(
attributes["Link Speed"].split(".")[0]
)
metrics["pd_device_speed"].labels(controller_index, enclosure, slot).set(
attributes["Device Speed"].split(".")[0]
)
# Some disks doesnt report device speed correctly
# when pd_device_speed metric assigns a string value: "Unknown"
# script execution crashes in that case assign a 0 speed value.
if attributes["Device Speed"].split(".")[0] == "Unknown":
metrics["pd_device_speed"].labels(controller_index, enclosure, slot).set('0')
else:
metrics["pd_device_speed"].labels(controller_index, enclosure, slot).set(
attributes["Device Speed"].split(".")[0]
)
metrics["pd_commissioned_spare"].labels(controller_index, enclosure, slot).set(
settings["Commissioned Spare"] == "Yes"
)
Expand Down

0 comments on commit 9370d8d

Please sign in to comment.