Skip to content

Commit

Permalink
Add Podman IO, but not workking for the moment because containers/pod…
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed Jan 22, 2023
1 parent b43bf2b commit a805386
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion glances/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,16 @@ 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:
value = unpack_string[0]
unit = None
else:
return None
try:
value = float(unpack_string[0])
except ValueError:
return None
return value * convert_dict[unit]
11 changes: 6 additions & 5 deletions glances/plugins/glances_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,14 @@ def update_podman(self):
'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'] = {}
Expand Down
1 change: 1 addition & 0 deletions unitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def test_018_string_value_to_float(self):
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"""
Expand Down

0 comments on commit a805386

Please sign in to comment.