Skip to content

Commit 37e5baa

Browse files
committed
ft-orchestration MergedStats class to use mpstat, vmstat und pidstat at the same time
1 parent 34cd011 commit 37e5baa

13 files changed

Lines changed: 362 additions & 196 deletions

File tree

tools/ft-orchestration/src/probe/cento.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Daemon,
2020
ExecutableProcessError,
2121
)
22-
from src.probe.mpstat import MpStat
22+
from src.stats.merged import MergedStats
2323
from src.probe.probe_target import ProbeTarget
2424

2525
SETTINGS_TO_ARGS: dict[str, str] = {
@@ -141,7 +141,7 @@ def __init__(
141141
if self._zero_copy:
142142
assert_tool_is_installed("pf_ringcfg", executor)
143143
self._cmd = self._prepare_cmd(target, protocols, settings)
144-
self.host_statistics = MpStat(stats_executor, self._cmd.split(" ", 1)[0])
144+
self.host_statistics = MergedStats(stats_executor, self._cmd.split(" ", 1)[0])
145145

146146
self._local_workdir = tempfile.mkdtemp()
147147
self._log_file = Path(self._local_workdir, "cento.log")

tools/ft-orchestration/src/probe/flowmon_probe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from lbr_testsuite.executable.rsync import RsyncException
2727
from src.probe.interface import ProbeException, ProbeInterface
28-
from src.probe.mpstat import MpStat
28+
from src.stats.merged import MergedStats
2929

3030
FLOWMONEXP_BIN = "/usr/bin/flowmonexp5"
3131
FLOWMONEXP_LOG = Path("/data/components/flowmonexp/log")
@@ -193,7 +193,9 @@ def __init__(
193193
else:
194194
stats_executor = LocalExecutor()
195195

196-
self.host_statistics = MpStat(stats_executor, os.path.basename(FLOWMONEXP_BIN))
196+
self.host_statistics = MergedStats(
197+
stats_executor, os.path.basename(FLOWMONEXP_BIN)
198+
)
197199

198200
dpdk_is_active = Tool(
199201
"systemctl -q is-active dpdk-controller.service",

tools/ft-orchestration/src/probe/interface.py

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,80 +9,7 @@
99
"""
1010

1111
from abc import ABC, abstractmethod
12-
from os import PathLike
13-
from lbr_testsuite.executable import Executor
14-
15-
16-
class HostStats(ABC):
17-
"""
18-
Abstract class defining an interface for a program that reads statistics from a host.
19-
"""
20-
21-
@abstractmethod
22-
def __init__(self, executor: Executor, watch_cmd: str):
23-
"""
24-
Constructor.
25-
26-
Args:
27-
executor (Executor): Executor object.
28-
watch_cmd (str): Program name to watch statistics for.
29-
"""
30-
pass
31-
32-
@property
33-
@abstractmethod
34-
def cpus(self) -> int:
35-
"""
36-
Number of CPUs.
37-
"""
38-
pass
39-
40-
@property
41-
@abstractmethod
42-
def total_ram(self) -> int:
43-
"""
44-
Size of RAM in kB.
45-
"""
46-
pass
47-
48-
@property
49-
@abstractmethod
50-
def local_file(self) -> PathLike:
51-
"""
52-
Path to locally stored CSV file.
53-
"""
54-
pass
55-
56-
@abstractmethod
57-
def start(self):
58-
"""
59-
Start collecting statistics.
60-
"""
61-
pass
62-
63-
@abstractmethod
64-
def stop(self):
65-
"""
66-
Stop collecting statistics.
67-
"""
68-
pass
69-
70-
@abstractmethod
71-
def cleanup(self):
72-
"""
73-
Remove temporary files.
74-
"""
75-
pass
76-
77-
@abstractmethod
78-
def get_csv(self, output_dir: PathLike):
79-
"""
80-
Download the CSV file containing statistics to the output directory.
81-
82-
Args:
83-
output_dir (PathLike): Path where to copy CSV to.
84-
"""
85-
pass
12+
from src.stats.interface import HostStats
8613

8714

8815
class ProbeException(Exception):

tools/ft-orchestration/src/probe/ipfixprobe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from src.common.utils import duplicate_executor
2929
from src.config.common import InterfaceCfg
3030
from src.probe.interface import ProbeException, ProbeInterface
31-
from src.probe.mpstat import MpStat
31+
from src.stats.merged import MergedStats
3232
from src.probe.probe_target import ProbeTarget
3333
from lbr_testsuite.executable import ExecutableProcessError
3434

@@ -392,7 +392,7 @@ def __init__(
392392

393393
assert_tool_is_installed("ipfixprobe", executor)
394394
self._cmd = self._prepare_cmd(target, protocols, settings)
395-
self.host_statistics = MpStat(stats_executor, self._cmd.split(" ", 1)[0])
395+
self.host_statistics = MergedStats(stats_executor, self._cmd.split(" ", 1)[0])
396396

397397
self._local_workdir = tempfile.mkdtemp()
398398
self._log_file = Path(self._local_workdir, "ipfixprobe.log")

tools/ft-orchestration/src/probe/nprobe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Daemon,
2323
ExecutableProcessError,
2424
)
25-
from src.probe.mpstat import MpStat
25+
from src.stats.merged import MergedStats
2626
from src.probe.probe_target import ProbeTarget
2727

2828
SETTINGS_TO_ARGS: dict[str, str] = {
@@ -150,7 +150,7 @@ def __init__(
150150
if self._zero_copy:
151151
assert_tool_is_installed("pf_ringcfg", executor)
152152
self._cmd = self._prepare_cmd(target, protocols, settings)
153-
self.host_statistics = MpStat(stats_executor, self._cmd.split(" ", 1)[0])
153+
self.host_statistics = MergedStats(stats_executor, self._cmd.split(" ", 1)[0])
154154

155155
self._local_workdir = tempfile.mkdtemp()
156156
self._log_files = []

tools/ft-orchestration/src/probe/pmacct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from src.common.utils import duplicate_executor
2121
from src.config.common import InterfaceCfg
2222
from src.probe.interface import ProbeException, ProbeInterface
23-
from src.probe.mpstat import MpStat
23+
from src.stats.merged import MergedStats
2424
from src.probe.probe_target import ProbeTarget
2525

2626

@@ -150,7 +150,7 @@ def __init__(
150150
self._log_file = path.join(self._local_workdir, f"{self._binary}.log")
151151
self._config_file = path.join(self._local_workdir, "settings.conf")
152152
self._cmd = None
153-
self.host_statistics = MpStat(stats_executor, self._binary)
153+
self.host_statistics = MergedStats(stats_executor, self._binary)
154154
self._rsync = Rsync(executor)
155155
self._rss_queues_pcap = rss_queues
156156

tools/ft-orchestration/src/probe/yaf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from src.common.utils import duplicate_executor
2020
from src.config.common import InterfaceCfg
2121
from src.probe.interface import ProbeException, ProbeInterface
22-
from src.probe.mpstat import MpStat
22+
from src.stats.merged import MergedStats
2323
from src.probe.probe_target import ProbeTarget
2424

2525

@@ -234,7 +234,7 @@ def __init__(
234234
self._log_file = path.join(self._local_workdir, "yaf.log")
235235
self._config_file = path.join(self._local_workdir, "settings.conf")
236236
self._cmd = None
237-
self.host_statistics = MpStat(stats_executor, "yaf")
237+
self.host_statistics = MergedStats(stats_executor, "yaf")
238238
self._rsync = Rsync(executor)
239239
self._rss_queues_pcap = rss_queues
240240

tools/ft-orchestration/src/stats/__init__.py

Whitespace-only changes.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from abc import ABC, abstractmethod
2+
from os import PathLike
3+
from lbr_testsuite.executable import Executor
4+
5+
6+
class HostStats(ABC):
7+
"""
8+
Abstract class defining an interface for a program that reads statistics from a host.
9+
"""
10+
11+
@abstractmethod
12+
def __init__(self, executor: Executor, watch_cmd: str):
13+
"""
14+
Constructor.
15+
16+
Args:
17+
executor (Executor): Executor object.
18+
watch_cmd (str): Program name to watch statistics for.
19+
"""
20+
pass
21+
22+
@property
23+
@abstractmethod
24+
def cpus(self) -> int:
25+
"""
26+
Number of CPUs.
27+
"""
28+
pass
29+
30+
@property
31+
@abstractmethod
32+
def total_ram(self) -> int:
33+
"""
34+
Size of RAM in kB.
35+
"""
36+
pass
37+
38+
@property
39+
@abstractmethod
40+
def local_file(self) -> PathLike:
41+
"""
42+
Path to locally stored CSV file.
43+
"""
44+
pass
45+
46+
@abstractmethod
47+
def start(self):
48+
"""
49+
Start collecting statistics.
50+
"""
51+
pass
52+
53+
@abstractmethod
54+
def stop(self):
55+
"""
56+
Stop collecting statistics.
57+
"""
58+
pass
59+
60+
@abstractmethod
61+
def cleanup(self):
62+
"""
63+
Remove temporary files.
64+
"""
65+
pass
66+
67+
@abstractmethod
68+
def get_csv(self, output_dir: PathLike):
69+
"""
70+
Download the CSV file containing statistics to the output directory.
71+
72+
Args:
73+
output_dir (PathLike): Path where to copy CSV to.
74+
"""
75+
pass

0 commit comments

Comments
 (0)