Skip to content

Commit fde059f

Browse files
authored
Merge pull request #128 from julien6387/dev-0.18.5
fix process CPU in SOLARIS mode
2 parents 5f599c3 + f1579b4 commit fde059f

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 0.18.5 (2024-08-19)
4+
5+
* Fix process CPU statistics when using SOLARIS mode.
6+
Issue introduced in **Supvisors** 0.18 with statistics refactoring.
7+
8+
39
## 0.18.4 (2024-07-13)
410

511
* Fix `supervisord` uptime in the **Supvisors** Web UI.

supvisors/tests/test_viewhandler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,24 +1046,32 @@ def test_write_detailed_process_cpu(mocker, supvisors, handler):
10461046
supvisors.options.stats_irix_mode = True
10471047
# test call with no stats
10481048
assert not handler.write_detailed_process_cpu(stats_elt, None, 4)
1049+
assert proc_stats.cpu == [10, 16, 13]
1050+
assert proc_stats.times == [1, 2, 3]
10491051
# test call with empty stats
10501052
for mode in [True, False]:
10511053
supvisors.options.stats_irix_mode = mode
10521054
assert handler.write_detailed_process_cpu(stats_elt, Mock(cpu=[], times=[]), 4)
1055+
assert proc_stats.cpu == [10, 16, 13]
1056+
assert proc_stats.times == [1, 2, 3]
10531057
assert mocked_common.call_args_list == [call(stats_elt, [], [],
10541058
'pcpuval_td_mid', 'pcpuavg_td_mid',
10551059
'pcpuslope_td_mid', 'pcpudev_td_mid')]
10561060
mocked_common.reset_mock()
10571061
# test call with irix mode
10581062
supvisors.options.stats_irix_mode = True
10591063
assert handler.write_detailed_process_cpu(stats_elt, proc_stats, 4)
1064+
assert proc_stats.cpu == [10, 16, 13]
1065+
assert proc_stats.times == [1, 2, 3]
10601066
assert mocked_common.call_args_list == [call(stats_elt, [10, 16, 13], [1, 2, 3],
10611067
'pcpuval_td_mid', 'pcpuavg_td_mid',
10621068
'pcpuslope_td_mid', 'pcpudev_td_mid')]
10631069
mocked_common.reset_mock()
10641070
# test call with solaris mode
10651071
supvisors.options.stats_irix_mode = False
10661072
assert handler.write_detailed_process_cpu(stats_elt, proc_stats, 4)
1073+
assert proc_stats.cpu == [10, 16, 13]
1074+
assert proc_stats.times == [1, 2, 3]
10671075
assert mocked_common.call_args_list == [call(stats_elt, [2.5, 4, 3.25], [1, 2, 3],
10681076
'pcpuval_td_mid', 'pcpuavg_td_mid',
10691077
'pcpuslope_td_mid', 'pcpudev_td_mid')]

supvisors/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.18.4
1+
version=0.18.5

supvisors/web/viewhandler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,13 @@ def write_detailed_process_cpu(self, stats_elt, proc_stats: Optional[ProcStatist
506506
:return: True if process CPU statistics are valid.
507507
"""
508508
if proc_stats:
509-
# if SOLARIS mode configured, update the CPU data
510-
# this will be applicable to the CPU plot
511-
if not self.supvisors.options.stats_irix_mode:
512-
proc_stats.cpu = [x / nb_cores for x in proc_stats.cpu]
513-
self._write_common_detailed_statistics(stats_elt, proc_stats.cpu, proc_stats.times,
509+
if self.supvisors.options.stats_irix_mode:
510+
cpu = proc_stats.cpu
511+
else:
512+
# if SOLARIS mode configured, update the CPU data
513+
# this will be applicable to the CPU plot
514+
cpu = [x / nb_cores for x in proc_stats.cpu]
515+
self._write_common_detailed_statistics(stats_elt, cpu, proc_stats.times,
514516
'pcpuval_td_mid', 'pcpuavg_td_mid',
515517
'pcpuslope_td_mid', 'pcpudev_td_mid')
516518
return True

0 commit comments

Comments
 (0)