summaryrefslogtreecommitdiffstats
path: root/rteval
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2010-08-03 17:15:18 +0200
committerDavid Sommerseth <davids@redhat.com>2010-08-23 22:03:12 +0200
commitf3c241d2d47e16bb9695d2dd4898c6f1da4e3fb6 (patch)
tree41ee3d2fc824de0c63d1212b388631049eee0439 /rteval
parentbd8a8021bdbca4e394c02d220a651bb5142c3940 (diff)
downloadrteval-f3c241d2d47e16bb9695d2dd4898c6f1da4e3fb6.tar.gz
rteval-f3c241d2d47e16bb9695d2dd4898c6f1da4e3fb6.tar.xz
rteval-f3c241d2d47e16bb9695d2dd4898c6f1da4e3fb6.zip
Extract IPv6 network configuration
This implementation will need python-ethtool v0.4 or newer to be able to extract the IPv6 information. This update makes sure older python-ethtool version will continue to work, while not extracting the IPv6 information. Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'rteval')
-rw-r--r--rteval/rteval.py67
1 files changed, 48 insertions, 19 deletions
diff --git a/rteval/rteval.py b/rteval/rteval.py
index ac865e5..28fa872 100644
--- a/rteval/rteval.py
+++ b/rteval/rteval.py
@@ -463,30 +463,59 @@ class RtEval(object):
while rl != '' :
rl = route.readline()
splt = rl.split("\t")
- if len(splt) > 2 and splt[2] != '00000000': # Only catch default route
+ # Only catch default route
+ if len(splt) > 2 and splt[2] != '00000000' and splt[1] == '00000000':
defgw4 = splt[0]
break
route.close()
- # Get lists over all devices, remove loopback device
- ifdevs = ethtool.get_active_devices()
- ifdevs.remove('lo')
- ifdevs.sort()
-
# Make an interface tag for each device found
- for dev in ifdevs:
- self.xmlreport.openblock('interface',
- {'device': dev,
- 'hwaddr': ethtool.get_hwaddr(dev)}
- )
- # Protcol configurations
- self.xmlreport.openblock('IPv4',
- {'ipaddr': ethtool.get_ipaddr(dev),
- 'netmask': ethtool.get_netmask(dev),
- 'defaultgw': (defgw4 == dev) and '1' or '0'}
- )
- self.xmlreport.closeblock()
- self.xmlreport.closeblock()
+ if hasattr(ethtool, 'get_interfaces_info'):
+ # Using the newer python-ethtool API (version >= 0.4)
+ for dev in ethtool.get_interfaces_info(ethtool.get_devices()):
+ if cmp(dev.device,'lo') == 0:
+ continue
+
+ self.xmlreport.openblock('interface',
+ {'device': dev.device,
+ 'hwaddr': dev.mac_address}
+ )
+
+ # Protcol configurations
+ if dev.ipv4_address:
+ self.xmlreport.openblock('IPv4',
+ {'ipaddr': dev.ipv4_address,
+ 'netmask': dev.ipv4_netmask,
+ 'broadcast': dev.ipv4_broadcast,
+ 'defaultgw': (defgw4 == dev.device) and '1' or '0'}
+ )
+ self.xmlreport.closeblock()
+
+ for ip6 in dev.get_ipv6_addresses():
+ self.xmlreport.openblock('IPv6',
+ {'ipaddr': ip6.address,
+ 'netmask': ip6.netmask,
+ 'scope': ip6.scope}
+ )
+ self.xmlreport.closeblock()
+ self.xmlreport.closeblock()
+ else: # Fall back to older python-ethtool API (version < 0.4)
+ ifdevs = ethtool.get_active_devices()
+ ifdevs.remove('lo')
+ ifdevs.sort()
+
+ for dev in ifdevs:
+ self.xmlreport.openblock('interface',
+ {'device': dev,
+ 'hwaddr': ethtool.get_hwaddr(dev)}
+ )
+ self.xmlreport.openblock('IPv4',
+ {'ipaddr': ethtool.get_ipaddr(dev),
+ 'netmask': ethtool.get_netmask(dev),
+ 'defaultgw': (defgw4 == dev) and '1' or '0'}
+ )
+ self.xmlreport.closeblock()
+ self.xmlreport.closeblock()
self.xmlreport.closeblock()
self.xmlreport.openblock('loads', {'load_average':str(accum / samples)})