-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgetVlanCounters.py
executable file
·76 lines (72 loc) · 1.94 KB
/
getVlanCounters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
'''
This script relies on a few things
1. you cave a .eapi.conf file in your ~/
** example .eapi.conf
[connection:tg254]
host: 172.28.129.56
username: admin
#password: (this test env did not need a password)
transport: https
2. You have enabled eapi on your switch: conf; management api https commands; no shut
3. You have enabled vlan counters on the 7280R
tg254.08:41:49(config)#hardware counter feature vlan in
tg254.08:47:33(config)#hardware counter feature vlan out
4. you have installed pyeapi 'pip install pyeapi'
There is a lot of formatting and likely stripping away some of the output for your needs. Let me know if you need help with that.
EXAMPLE OUTPUT:
chines@mbp-arista-13122[~]$ ./getVlanCounters.py
[{'command': 'show vlan counters',
'encoding': 'json',
'result':
{
u'vlanCountersInfo':{
u'1':{
u'inBcastPkts':0,
u'inMcastPkts':0,
u'inOctets':858146,
u'inUcastPkts':5306,
u'outBcastPkts':0,
u'outMcastPkts':0,
u'outOctets':232100,
u'outUcastPkts':2398
},
u'125':{
u'inBcastPkts':0,
u'inMcastPkts':0,
u'inOctets':0,
u'inUcastPkts':0,
u'outBcastPkts':0,
u'outMcastPkts':0,
u'outOctets':0,
u'outUcastPkts':0
},
u'25':{
u'inBcastPkts':0,
u'inMcastPkts':0,
u'inOctets':22374,
u'inUcastPkts':198,
u'outBcastPkts':0,
u'outMcastPkts':0,
u'outOctets':0,
u'outUcastPkts':0
},
u'89':{
u'inBcastPkts':0,
u'inMcastPkts':0,
u'inOctets':0,
u'inUcastPkts':0,
u'outBcastPkts':0,
u'outMcastPkts':0,
u'outOctets':0,
u'outUcastPkts':0
}
}
}
}
]
'''
import pyeapi
from pprint import pprint as pp
node = pyeapi.connect_to('7280-01')
pp(node.enable('show vlan counters'))