Skip to content

Commit 82bdef8

Browse files
committed
fix an issue with ecc error metric
1 parent 119306b commit 82bdef8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

playbooks/roles/metrics-exporter/templates/custom_metrics.py.j2

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ import platform
1313
import time
1414
from rdma_link_flapping import LinkFlappingTest
1515

16+
def get_host_serial():
17+
# Run the shell command
18+
if not is_user_root():
19+
result = subprocess.run(['sudo', 'dmidecode', '-s', 'system-serial-number'], stdout=subprocess.PIPE)
20+
else:
21+
result = subprocess.run(['dmidecode', '-s', 'system-serial-number'], stdout=subprocess.PIPE)
22+
23+
# Decode the output from bytes to string
24+
output = result.stdout.decode('utf-8')
25+
26+
# Return the serial number
27+
return output.strip()
28+
1629
def oca_version_metric(min_version):
1730

1831
metadata = get_metadata()
@@ -642,6 +655,12 @@ if __name__ == '__main__':
642655
metadata=get_metadata()
643656
oci_shape=metadata['shape']
644657
rdma_devices = get_rdma_devices(oci_shape)
658+
host_serial = ""
659+
try:
660+
host_serial = get_host_serial()
661+
except Exception as e:
662+
logger.warning(f"Failed to get host serial number with error: {e}")
663+
host_serial = "Unknown"
645664

646665
# Run the checks every 10 minutes
647666
while True:

0 commit comments

Comments
 (0)