From d0777c5dd7765776bf8af6a819b966dbc0e66442 Mon Sep 17 00:00:00 2001 From: Jon Stanley Date: Tue, 12 Jun 2012 09:37:59 -0400 Subject: Use 'ip -o addr' instead of ifconfig for parseable output The 'ifconfig' command is deprecated, and the 'ip' command should be used instead for multiple reasons. This is also a more easily parseable format. --- sos/plugins/networking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index b0b3010c..1497c835 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -51,7 +51,7 @@ class networking(Plugin, RedHatPlugin): "/etc/xinetd.d", "/etc/host*", "/etc/resolv.conf"]) - ifconfigFile=self.collectOutputNow("/sbin/ifconfig -a", root_symlink = "ifconfig") + ifconfigFile=self.collectOutputNow("/sbin/ip -o addr", root_symlink = "ip_addr") self.collectExtOutput("/sbin/route -n", root_symlink = "route") self.collectIPTable("filter") self.collectIPTable("nat") -- cgit From b46608a06e69039349b56daa1952d68e4f451ff5 Mon Sep 17 00:00:00 2001 From: Jon Stanley Date: Tue, 12 Jun 2012 10:22:54 -0400 Subject: Change get_interface_name to support arbitrarily named interfaces Due to support for biosdevname, we now have to look at interface types rather than names in order to determine whether an interface is interesting for this plugin. --- sos/plugins/networking.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index 1497c835..4f1f02f6 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -21,11 +21,16 @@ class networking(Plugin, RedHatPlugin): """ optionList = [("traceroute", "collects a traceroute to rhn.redhat.com", "slow", False)] - def get_interface_name(self,ifconfigFile): + def get_interface_name(self,ipaddrFile): """Return a dictionary for which key are interface name according to the output of ifconifg-a stored in ifconfigFile. """ - out=self.doRegexFindAll(r"^(eth\d+)\D", ifconfigFile) + out={} + for interface in open(ipaddrFile, 'r').readlines(): + match=re.match(r'link/ether', interface) + if match: + int=match.string.split(':')[1].lstrip() + out[int]=True return out def collectIPTable(self,tablename): @@ -51,7 +56,7 @@ class networking(Plugin, RedHatPlugin): "/etc/xinetd.d", "/etc/host*", "/etc/resolv.conf"]) - ifconfigFile=self.collectOutputNow("/sbin/ip -o addr", root_symlink = "ip_addr") + ipaddrFile=self.collectOutputNow("/sbin/ip -o addr", root_symlink = "ip_addr") self.collectExtOutput("/sbin/route -n", root_symlink = "route") self.collectIPTable("filter") self.collectIPTable("nat") @@ -66,8 +71,8 @@ class networking(Plugin, RedHatPlugin): self.collectExtOutput("/sbin/ifenslave -a") self.collectExtOutput("/sbin/ip mroute show") self.collectExtOutput("/sbin/ip maddr show") - if ifconfigFile: - for eth in self.get_interface_name(ifconfigFile): + if ipaddrFile: + for eth in self.get_interface_name(ipaddrFile): self.collectExtOutput("/sbin/ethtool "+eth) self.collectExtOutput("/sbin/ethtool -i "+eth) self.collectExtOutput("/sbin/ethtool -k "+eth) -- cgit From 90cd2974fe87d73e1be1644a06b1957d57c4a7f4 Mon Sep 17 00:00:00 2001 From: Jon Stanley Date: Tue, 12 Jun 2012 10:26:58 -0400 Subject: Collect ring, coalesce, and pause attributes of interfaces. These are very useful items to have in general in order to see the configuration of systems. They are performance impacting parameters. --- sos/plugins/networking.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index 4f1f02f6..0497902e 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -77,5 +77,8 @@ class networking(Plugin, RedHatPlugin): self.collectExtOutput("/sbin/ethtool -i "+eth) self.collectExtOutput("/sbin/ethtool -k "+eth) self.collectExtOutput("/sbin/ethtool -S "+eth) + self.collectExtOutput("/sbin/ethtool -a "+eth) + self.collectExtOutput("/sbin/ethtool -c "+eth) + self.collectExtOutput("/sbin/ethtool -g "+eth) if self.getOption("traceroute"): self.collectExtOutput("/bin/traceroute -n rhn.redhat.com") -- cgit From 8df0c1a012ed671121e1104c7c5a23c988831cd9 Mon Sep 17 00:00:00 2001 From: Jon Stanley Date: Tue, 12 Jun 2012 11:53:13 -0400 Subject: Add generated files to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 49d2072c..54303d03 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ dist-build/* sos/__init__.py cover/ .coverage +*.mo +sos.conf.5.gz +sosreport.1.gz -- cgit From 88886641e70801e77c8d4841c9f3ff6b61c1c63e Mon Sep 17 00:00:00 2001 From: Jon Stanley Date: Tue, 12 Jun 2012 11:59:30 -0400 Subject: Various bugfixes from previous commit --- sos/plugins/networking.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index 0497902e..c27c0b82 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -21,13 +21,13 @@ class networking(Plugin, RedHatPlugin): """ optionList = [("traceroute", "collects a traceroute to rhn.redhat.com", "slow", False)] - def get_interface_name(self,ipaddrFile): + def get_interface_name(self,ipaddrOut): """Return a dictionary for which key are interface name according to the output of ifconifg-a stored in ifconfigFile. """ out={} - for interface in open(ipaddrFile, 'r').readlines(): - match=re.match(r'link/ether', interface) + for line in ipaddrOut[1].splitlines(): + match=re.match('.*link/ether', line) if match: int=match.string.split(':')[1].lstrip() out[int]=True @@ -57,6 +57,7 @@ class networking(Plugin, RedHatPlugin): "/etc/host*", "/etc/resolv.conf"]) ipaddrFile=self.collectOutputNow("/sbin/ip -o addr", root_symlink = "ip_addr") + ipaddrOut=self.callExtProg("/sbin/ip -o addr") self.collectExtOutput("/sbin/route -n", root_symlink = "route") self.collectIPTable("filter") self.collectIPTable("nat") @@ -71,8 +72,8 @@ class networking(Plugin, RedHatPlugin): self.collectExtOutput("/sbin/ifenslave -a") self.collectExtOutput("/sbin/ip mroute show") self.collectExtOutput("/sbin/ip maddr show") - if ipaddrFile: - for eth in self.get_interface_name(ipaddrFile): + if ipaddrOut: + for eth in self.get_interface_name(ipaddrOut): self.collectExtOutput("/sbin/ethtool "+eth) self.collectExtOutput("/sbin/ethtool -i "+eth) self.collectExtOutput("/sbin/ethtool -k "+eth) -- cgit