summaryrefslogtreecommitdiff
path: root/src/op_mode/snmp_ifmib.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-08-11 02:50:20 +0700
committerGitHub <noreply@github.com>2019-08-11 02:50:20 +0700
commitfbb5c22d5704688eff29ecd2dfb79b7dcf7f13df (patch)
tree369404f4cbc10e135b6bb5d9e261eea5e9fc49d1 /src/op_mode/snmp_ifmib.py
parentb570f31e7fce099687a12095850ebf9ae7a469ac (diff)
parentdc936192e87f114df6ab6a4df44967ce0f2b8390 (diff)
downloadvyos-1x-fbb5c22d5704688eff29ecd2dfb79b7dcf7f13df.tar.gz
vyos-1x-fbb5c22d5704688eff29ecd2dfb79b7dcf7f13df.zip
Merge pull request #100 from DmitriyEshenko/snmp
[snmp] T1575 Adding additional check for lspci
Diffstat (limited to 'src/op_mode/snmp_ifmib.py')
-rwxr-xr-xsrc/op_mode/snmp_ifmib.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/op_mode/snmp_ifmib.py b/src/op_mode/snmp_ifmib.py
index 9d56a950b..180892694 100755
--- a/src/op_mode/snmp_ifmib.py
+++ b/src/op_mode/snmp_ifmib.py
@@ -77,10 +77,16 @@ def show_ifdescr(i):
proc = subprocess.Popen(['/usr/bin/lspci', '-mm', '-d', device], stdout=subprocess.PIPE)
(out, err) = proc.communicate()
+ vendor = ""
+ device = ""
+
# convert output to string
string = out.decode("utf-8").split('"')
- vendor = string[3]
- device = string[5]
+ if len(string) >= 3:
+ vendor = string[3]
+
+ if len(string) >= 5:
+ device = string[5]
ret = 'ifDescr = {0} {1}'.format(vendor, device)
return ret.replace('\n', '')