@cryptotaxi247 / netdata-1 / commits / d274e5bb3

fix not handling N/A value in python.d/nvidia_smi (#15231)

Ilya Mashchenko committed Jun 21, 2023 at 21:24 UTC d274e5bb30b95f3aaebc8d5e19e352982edf53eb
1 file changed +10 -7
collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
+10 -7
@@ -17,6 +17,8 @@ disabled_by_default = True
17
18 NVIDIA_SMI = 'nvidia-smi'
19
20 +NOT_AVAILABLE = 'N/A'
21 +
22 EMPTY_ROW = ''
23 EMPTY_ROW_LIMIT = 500
24 POLLER_BREAK_ROW = '</nvidia_smi_log>'
@@ -481,13 +483,14 @@ class GPU:
483 'power_draw': self.power_draw(),
484 }
485
484 - pci_bw_max = self.pci_bw_max()
485 - if not pci_bw_max:
486 - data['rx_util_percent'] = 0
487 - data['tx_util_percent'] = 0
488 - else :
489 - data['rx_util_percent'] = str(int(int(self.rx_util())*100/self.pci_bw_max()))
490 - data['tx_util_percent'] = str(int(int(self.tx_util())*100/self.pci_bw_max()))
486 + if self.rx_util() != NOT_AVAILABLE and self.tx_util() != NOT_AVAILABLE:
487 + pci_bw_max = self.pci_bw_max()
488 + if not pci_bw_max:
489 + data['rx_util_percent'] = 0
490 + data['tx_util_percent'] = 0
491 + else:
492 + data['rx_util_percent'] = str(int(int(self.rx_util()) * 100 / self.pci_bw_max()))
493 + data['tx_util_percent'] = str(int(int(self.tx_util()) * 100 / self.pci_bw_max()))
494
495
496 for v in POWER_STATES: