Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bird, networking] Carry forward PR 1541 #3763

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions sos/report/plugins/bird.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright (C) 2024 Jake Hunsaker <[email protected]>
# Copyright (C) 2019 Alexander Petrovskiy <[email protected]>
#
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, IndependentPlugin


class Bird(Plugin, IndependentPlugin):
"""BIRD is an Internet Routing Daemon used in many *nix and nix-like
distributions. This plugin will capture the configuration files for a local
bird installation, as well as runtime information and metrics.
"""

plugin_name = 'bird'
profiles = ('network', )
packages = ('bird', )
services = ('bird', )

def setup(self):

try:
with open('/etc/bird.conf', 'r', encoding='utf-8') as bfile:
for line in bfile:
if line.startswith('log'):
# non-file values will be dropped by add_copy_spec()
self.add_copy_spec(line.split()[1].strip('"'))
except Exception as err:
self._log_debug(f"Unable to parse bird.conf: {err}")

self.add_copy_spec([
"/etc/bird/*",
"/etc/bird.conf"
])

self.add_cmd_output([
"birdc show status",
"birdc show memory",
"birdc show protocols all",
"birdc show interfaces",
"birdc show route all",
"birdc show symbols",
"birdc show bfd sessions",
"birdc show babel interfaces",
"birdc show babel neighbors",
"birdc show babel entries",
"birdc show babel routes",
"birdc show ospf",
"birdc show ospf neighbors",
"birdc show ospf interface",
"birdc show ospf topology",
"birdc show ospf state all",
"birdc show ospf lsadb",
"birdc show rip interfaces",
"birdc show rip neighbors",
"birdc show static"
])

def postproc(self):
self.do_path_regex_sub('/etc/bird(.*)?.conf',
r"((.*password)\s\"(.*)\"(.*))",
r"\2 *******\4")

# vim: set et ts=4 sw=4 :
55 changes: 39 additions & 16 deletions sos/report/plugins/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,35 @@ def setup(self):
"devlink dev param show",
"devlink dev info",
"devlink port show",
"devlink sb show",
"devlink sb pool show",
"devlink sb port pool show",
"devlink sb tc bind show",
"devlink -s -v trap show",
])

devlinks = self.collect_cmd_output("devlink dev")
if devlinks['status'] == 0:
devlinks_list = devlinks['output'].splitlines()
for devlink in devlinks_list:
self.add_cmd_output(f"devlink dev eswitch show {devlink}")
self.add_cmd_output([
f"devlink dev eswitch show {devlink}",
f"devlink sb occupancy snapshot {devlink}",
f"devlink sb occupancy show {devlink}",
f"devlink -v resource show {devlink}"
])
dev_tables = []
dpipe = self.collect_cmd_output(
f"devlink dpipe table show {devlink}"
)
if dpipe['status'] == 0:
for tableln in dpipe['output'].splitlines():
if tableln.startswith('name'):
dev_tables.append(tableln.split()[1])
self.add_cmd_output([
f"devlink dpipe table show {devlink} name {dname}"
for dname in dev_tables
])

# below commands require some kernel module(s) to be loaded
# run them only if the modules are loaded, or if explicitly requested
Expand Down Expand Up @@ -227,17 +249,17 @@ def collect_ss_ip_ethtool_info(self):
_subdir = f"namespaces/{namespace}"
ns_cmd_prefix = cmd_prefix + namespace + " "
self.add_cmd_output([
ns_cmd_prefix + "ip -d address show",
ns_cmd_prefix + "ip route show table all",
ns_cmd_prefix + "ip -s -s neigh show",
ns_cmd_prefix + "ip -4 rule list",
ns_cmd_prefix + "ip -6 rule list",
ns_cmd_prefix + "ip vrf show",
ns_cmd_prefix + "sysctl -a",
ns_cmd_prefix + f"netstat {self.ns_wide} -neopa",
ns_cmd_prefix + "netstat -s",
ns_cmd_prefix + f"netstat {self.ns_wide} -agn",
ns_cmd_prefix + "nstat -zas",
f"{ns_cmd_prefix} ip -d address show",
f"{ns_cmd_prefix} ip route show table all",
f"{ns_cmd_prefix} ip -s -s neigh show",
f"{ns_cmd_prefix} ip -4 rule list",
f"{ns_cmd_prefix} ip -6 rule list",
f"{ns_cmd_prefix} ip vrf show",
f"{ns_cmd_prefix} sysctl -a",
f"{ns_cmd_prefix} netstat {self.ns_wide} -neopa",
f"{ns_cmd_prefix} netstat -s",
f"{ns_cmd_prefix} netstat {self.ns_wide} -agn",
f"{ns_cmd_prefix} nstat -zas",
], priority=50, subdir=_subdir)
self.add_cmd_output([ns_cmd_prefix + "iptables-save"],
pred=iptables_with_nft,
Expand All @@ -260,10 +282,11 @@ def collect_ss_ip_ethtool_info(self):
# Devices that exist in a namespace use less ethtool
# parameters. Run this per namespace.
self.add_device_cmd([
ns_cmd_prefix + "ethtool %(dev)s",
ns_cmd_prefix + "ethtool -i %(dev)s",
ns_cmd_prefix + "ethtool -k %(dev)s",
ns_cmd_prefix + "ethtool -S %(dev)s"
f"{ns_cmd_prefix} ethtool %(dev)s",
f"{ns_cmd_prefix} ethtool -i %(dev)s",
f"{ns_cmd_prefix} ethtool -k %(dev)s",
f"{ns_cmd_prefix} ethtool -S %(dev)s",
f"{ns_cmd_prefix} ethtool -m %(dev)s"
], devices=_devs['ethernet'], priority=50, subdir=_subdir)

self.add_command_tags()
Expand Down
Loading