Add Podman IO, but not workking for the moment because https://github.com/containers/podman/issues/11695

pull/2269/head
nicolargo 2023-01-22 09:54:56 +01:00
parent b43bf2bcb0
commit a805386255
3 changed files with 12 additions and 6 deletions

View File

@ -377,7 +377,7 @@ def string_value_to_float(s):
'TB': 1000000000000,
'PB': 1000000000000000,
}
unpack_string = [float(i[0]) if i[1] == '' else i[1].upper() for i in re.findall(r'([\d.]+)|([^\d.]+)', s.replace(' ', ''))]
unpack_string = [i[0] if i[1] == '' else i[1].upper() for i in re.findall(r'([\d.]+)|([^\d.]+)', s.replace(' ', ''))]
if len(unpack_string) == 2:
value, unit = unpack_string
elif len(unpack_string) == 1:
@ -385,4 +385,8 @@ def string_value_to_float(s):
unit = None
else:
return None
try:
value = float(unpack_string[0])
except ValueError:
return None
return value * convert_dict[unit]

View File

@ -454,13 +454,14 @@ class Plugin(GlancesPlugin):
'limit': string_value_to_float(podman_stats[container_stats['IdShort']]['MemUsage'].split(' / ')[1]),
}
container_stats['memory_percent'] = float(podman_stats[container_stats['IdShort']]['Mem'][:-1])
# Is it possible ?
# Not available for the moment: https://github.com/containers/podman/issues/11695
container_stats['io'] = {}
container_stats['io_r'] = None
container_stats['io_w'] = None
container_stats['io_r'] = string_value_to_float(podman_stats[container_stats['IdShort']]['BlockIO'].split(' / ')[0])
container_stats['io_w'] = string_value_to_float(podman_stats[container_stats['IdShort']]['BlockIO'].split(' / ')[1])
container_stats['network'] = {}
container_stats['network_rx'] = None
container_stats['network_tx'] = None
container_stats['network_rx'] = string_value_to_float(podman_stats[container_stats['IdShort']]['NetIO'].split(' / ')[0])
container_stats['network_tx'] = string_value_to_float(podman_stats[container_stats['IdShort']]['NetIO'].split(' / ')[1])
#
container_stats['Uptime'] = None
else:
container_stats['cpu'] = {}

View File

@ -296,6 +296,7 @@ class TestGlances(unittest.TestCase):
self.assertEqual(string_value_to_float('15.5MB'), 15500000.0)
self.assertEqual(string_value_to_float('25.9'), 25.9)
self.assertEqual(string_value_to_float('12'), 12)
self.assertEqual(string_value_to_float('--'), None)
def test_094_thresholds(self):
"""Test thresholds classes"""