Commit 8872e1c7 authored by Ad Schellevis's avatar Ad Schellevis

(netflow, flowd agg) use ifconfig for interface numbering

parent ebc29f92
...@@ -59,12 +59,12 @@ class Interfaces(object): ...@@ -59,12 +59,12 @@ class Interfaces(object):
""" """
self._ifIndex = dict() self._ifIndex = dict()
with tempfile.NamedTemporaryFile() as output_stream: with tempfile.NamedTemporaryFile() as output_stream:
subprocess.call(['/usr/bin/netstat', '-i', '-n'], stdout=output_stream, stderr=open(os.devnull, 'wb')) subprocess.call(['/sbin/ifconfig', '-l'], stdout=output_stream, stderr=open(os.devnull, 'wb'))
output_stream.seek(0) output_stream.seek(0)
for line in output_stream.read().split('\n'): ifIndex=1
parts = line.split() for line in output_stream.read().split('\n')[0].split():
if len(parts) > 2 and parts[2].find('<Link#') > -1: self._ifIndex[str(ifIndex)] = line
self._ifIndex[parts[2].split('#')[1].split('>')[0]] = parts[0] ifIndex += 1
def if_device(self, ifIndex): def if_device(self, ifIndex):
""" convert index to device (if found) """ convert index to device (if found)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment