mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
netflow: Fix incorrect interface index (#6490)
This commit is contained in:
parent
b85f3d0ed1
commit
2ff2989f72
@ -69,7 +69,7 @@ netflow_setup_interface()
|
||||
# determine (snmp) ifIndex
|
||||
ifIndex=0
|
||||
found=0
|
||||
for item in $(/sbin/ifconfig -l); do
|
||||
for item in $(/usr/local/sbin/ifinfo | awk '$1 == "Interface" { print $2 }'); do
|
||||
let ifIndex = ifIndex + 1 > /dev/null 2>&1
|
||||
if [ "$item" = "$interface" ]; then
|
||||
found=1
|
||||
|
||||
@ -30,6 +30,7 @@ import glob
|
||||
import tempfile
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
from lib.flowparser import FlowParser
|
||||
|
||||
|
||||
@ -40,11 +41,11 @@ class Interfaces(object):
|
||||
""" construct local interface mapping
|
||||
"""
|
||||
self._if_index = dict()
|
||||
sp = subprocess.run(['/sbin/ifconfig', '-l'], capture_output=True, text=True)
|
||||
if_index = 1
|
||||
for line in sp.stdout.split():
|
||||
self._if_index["%s" % if_index] = line
|
||||
if_index += 1
|
||||
sp = subprocess.run(['/usr/local/sbin/ifinfo'], capture_output=True, text=True)
|
||||
interfaces = re.findall(r"Interface ([^ ]+)", sp.stdout)
|
||||
|
||||
for index, interface in enumerate(interfaces, start=1):
|
||||
self._if_index["%s" % index] = interface
|
||||
|
||||
def if_device(self, if_index):
|
||||
""" convert index to device (if found)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user