aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/telemetry/bundle_bpf.py
diff options
context:
space:
mode:
authorViliam Luc <vluc@cisco.com>2022-04-13 14:00:44 +0200
committerViliam Luc <vluc@cisco.com>2022-09-28 10:28:03 +0000
commita2182abd2665aa9264464a99ad77718e2c7bbe18 (patch)
treeb6552e130c503c0694167ca7485711e776fa2b79 /resources/tools/telemetry/bundle_bpf.py
parentbff439b69ee71b654b1da92564ff62de7327fe71 (diff)
telemetry: linux telemetry with perf-stat
Signed-off-by: Viliam Luc <vluc@cisco.com> Change-Id: I17ced17a309cc0ac21c5fc94e570c89a456339e2
Diffstat (limited to 'resources/tools/telemetry/bundle_bpf.py')
-rw-r--r--resources/tools/telemetry/bundle_bpf.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/resources/tools/telemetry/bundle_bpf.py b/resources/tools/telemetry/bundle_bpf.py
index c376da9d63..58cfd5d0b6 100644
--- a/resources/tools/telemetry/bundle_bpf.py
+++ b/resources/tools/telemetry/bundle_bpf.py
@@ -52,12 +52,15 @@ class BundleBpf:
self.obj = BPF(text=self.code)
- def attach(self, duration):
+
+ def attach(self, sample_period):
"""
Attach events to BPF.
- :param duration: Trial duration.
- :type duration: int
+ :param sample_period: A "sampling" event is one that generates
+ an overflow notification every N events, where N is given by
+ sample_period.
+ :type sample_period: int
"""
try:
for event in self.events:
@@ -65,15 +68,16 @@ class BundleBpf:
ev_type=event[u"type"],
ev_config=event[u"name"],
fn_name=event[u"target"],
- sample_period=duration
+ sample_period=sample_period
)
except AttributeError:
- getLogger("console_stderr").error(u"Could not attach BPF events!")
+ getLogger("console_stderr").error(f"Could not attach BPF event: "
+ f"{event[u'name']}")
sys.exit(Constants.err_linux_attach)
def detach(self):
"""
- Dettach events from BPF.
+ Detach events from BPF.
"""
try:
for event in self.events:
@@ -98,6 +102,9 @@ class BundleBpf:
for _, metric_list in self.metrics.items():
for metric in metric_list:
+ if table_name != metric[u"name"]:
+ table_name = metric[u"name"]
+ text += f"{table_name}\n"
for (key, val) in self.obj.get_table(metric[u"name"]).items():
item = dict()
labels = dict()