diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2018-05-04 08:36:18 +0200 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2018-05-24 15:12:07 +0100 |
commit | 1beec779f0b3d37d9e4726ea1b11b109c35c10c3 (patch) | |
tree | dd4e74673b9d461fa0800564199fe585d42d3936 | |
parent | f504eead2e308ef9818c8dfba5ac10890f541551 (diff) | |
download | sos-1beec779f0b3d37d9e4726ea1b11b109c35c10c3.tar.gz |
[kernel] list loaded eBPF programs and maps
Collect the list all loaded eBPF programs and maps and dump their
content.
Resolves: #1287
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/kernel.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sos/plugins/kernel.py b/sos/plugins/kernel.py index 19a33b97..39874ad0 100644 --- a/sos/plugins/kernel.py +++ b/sos/plugins/kernel.py @@ -9,6 +9,7 @@ from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin import os import glob +import json class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): @@ -25,6 +26,28 @@ class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): ("with-timer", "gather /proc/timer* statistics", "slow", False) ] + def get_bpftool_prog_ids(self, prog_file): + out = [] + try: + prog_data = json.load(open(prog_file)) + except Exception, e: + self._log_info("Could not parse bpftool prog list as JSON: %s" % e) + return out + for item in range(len(prog_data)): + out.append(prog_data[item]["id"]) + return out + + def get_bpftool_map_ids(self, map_file): + out = [] + try: + map_data = json.load(open(map_file)) + except Exception, e: + self._log_info("Could not parse bpftool map list as JSON: %s" % e) + return out + for item in range(len(map_data)): + out.append(map_data[item]["id"]) + return out + def setup(self): # compat self.add_cmd_output("uname -a", root_symlink="uname") @@ -104,4 +127,14 @@ class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): # and may also cause softlockups self.add_copy_spec("/proc/timer*") + # collect list of eBPF programs and maps and their dumps + prog_file = self.get_cmd_output_now("bpftool -j prog list") + for prog_id in self.get_bpftool_prog_ids(prog_file): + for dumpcmd in ["xlated", "jited"]: + self.add_cmd_output("bpftool prog dump %s id %s" % + (dumpcmd, prog_id)) + map_file = self.get_cmd_output_now("bpftool -j map list") + for map_id in self.get_bpftool_map_ids(map_file): + self.add_cmd_output("bpftool map dump id %s" % map_id) + # vim: set et ts=4 sw=4 : |