From 983a8ecdeaaf7e98ca2a0791457b670a0726a184 Mon Sep 17 00:00:00 2001 From: sconklin Date: Tue, 24 Apr 2007 16:25:33 +0000 Subject: Added clalance's patch to gather iptables info. git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@126 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/lib/sos/plugins/networking.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/lib') diff --git a/src/lib/sos/plugins/networking.py b/src/lib/sos/plugins/networking.py index bc66a9e9..31e753e6 100644 --- a/src/lib/sos/plugins/networking.py +++ b/src/lib/sos/plugins/networking.py @@ -13,7 +13,7 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools -import os,re +import os,re,commands class networking(sos.plugintools.PluginBase): """This plugin gathers network related information @@ -32,8 +32,22 @@ class networking(sos.plugintools.PluginBase): for name in reg.findall(content): out[name]=1 return out - - + + def collectIPTable(self,tablename): + """ When running the iptables command, it unfortunately auto-loads + the modules before trying to get output. Some people explicitly + don't want this, so check if the modules are loaded before running + the command. If they aren't loaded, there can't possibly be any + relevant rules in that table """ + + cmd = "/sbin/iptables -t "+tablename+" -nvL" + + (status, output) = commands.getstatusoutput("/sbin/lsmod | grep -q "+tablename) + if status == 0: + self.collectExtOutput(cmd) + else: + self.writeTextToCommand(cmd,"IPTables module "+tablename+" not loaded\n") + def setup(self): self.addCopySpec("/etc/nsswitch.conf") self.addCopySpec("/etc/yp.conf") @@ -47,9 +61,9 @@ class networking(sos.plugintools.PluginBase): ifconfigFile=self.collectExtOutput("/sbin/ifconfig -a") self.collectExtOutput("/sbin/route -n") self.collectExtOutput("/sbin/ipchains -nvL") - self.collectExtOutput("/sbin/iptables -t filter -nvL") - self.collectExtOutput("/sbin/iptables -t nat -nvL") - self.collectExtOutput("/sbin/iptables -t mangle -nvL") + self.collectIPTable("filter") + self.collectIPTable("nat") + self.collectIPTable("mangle") self.collectExtOutput("/bin/netstat -nap") if ifconfigFile: for eth in self.get_interface_name(ifconfigFile): -- cgit