diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2023-06-21 21:24:28 +0300 |
---|---|---|
committer | Austin S. Hemmelgarn <austin@netdata.cloud> | 2023-06-27 08:50:02 -0400 |
commit | 37fd96700b8eeb1e2797d27dda5a094940dc5266 (patch) | |
tree | 86d711438d1dfbfc0c2ff0de6877b850a02d5122 | |
parent | 1a304749fdb3a32112cd8eb12e3a87cb6ac2336b (diff) |
fix not handling N/A value in python.d/nvidia_smi (#15231)
-rw-r--r-- | collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py index 6affae7b8c..271c996383 100644 --- a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py +++ b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py @@ -17,6 +17,8 @@ disabled_by_default = True NVIDIA_SMI = 'nvidia-smi' +NOT_AVAILABLE = 'N/A' + EMPTY_ROW = '' EMPTY_ROW_LIMIT = 500 POLLER_BREAK_ROW = '</nvidia_smi_log>' @@ -481,13 +483,14 @@ class GPU: 'power_draw': self.power_draw(), } - pci_bw_max = self.pci_bw_max() - if not pci_bw_max: - data['rx_util_percent'] = 0 - data['tx_util_percent'] = 0 - else : - data['rx_util_percent'] = str(int(int(self.rx_util())*100/self.pci_bw_max())) - data['tx_util_percent'] = str(int(int(self.tx_util())*100/self.pci_bw_max())) + if self.rx_util() != NOT_AVAILABLE and self.tx_util() != NOT_AVAILABLE: + pci_bw_max = self.pci_bw_max() + if not pci_bw_max: + data['rx_util_percent'] = 0 + data['tx_util_percent'] = 0 + else: + data['rx_util_percent'] = str(int(int(self.rx_util()) * 100 / self.pci_bw_max())) + data['tx_util_percent'] = str(int(int(self.tx_util()) * 100 / self.pci_bw_max())) for v in POWER_STATES: |