-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
107 lines (60 loc) · 3.31 KB
/
README
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# manage Dell switch running-config in git
dpavlin@black:~/dell-switch$ ./sw-running-config.sh sw-dpc
# /dev/shm/port-status
Collect information about port status using snmp
dpavlin@black:~/dell-switch$ ./snmp-port-status.sh sw-core # single switch
dpavlin@black:~/dell-switch$ ./sw-port-status.sh # all switches
This will populate /dev/shm/port-status/ and manage changes in git
You can grep for ports on switches since format is "switch port ...."
dpavlin@black:~/dell-switch$ egrep ' (15|22) ' /dev/shm/port-status/sw-dpc
sw-dpc 15 g15 1000 up ethernetCsmacd [sw-baraka]
sw-dpc 22 g22 100 up ethernetCsmacd [PIX-eth1]
You can also grep only for sw-name and get both uplink port (if in description)
and ports from switch:
dpavlin@black:/dev/shm/port-status$ egrep sw-baraka * | head
sw-a200:sw-a200 22 g22 1000 up ethernetCsmacd [sw-baraka]
sw-baraka:sw-baraka 1 g1 1000 down ethernetCsmacd
sw-baraka:sw-baraka 2 g2 1000 down ethernetCsmacd
sw-baraka:sw-baraka 3 g3 1000 down ethernetCsmacd
sw-baraka:sw-baraka 4 g4 1000 down ethernetCsmacd
sw-baraka:sw-baraka 5 g5 10 up ethernetCsmacd
sw-baraka:sw-baraka 6 g6 1000 down ethernetCsmacd
sw-baraka:sw-baraka 7 g7 1000 down ethernetCsmacd
sw-baraka:sw-baraka 8 g8 1000 down ethernetCsmacd
sw-baraka:sw-baraka 9 g9 1000 down ethernetCsmacd
Get additional OID from switches:
dpavlin@black:~/dell-switch$ ./snmp-port-status.sh
Usage: ./snmp-port-status.sh hostname ifAdminStatus BRIDGE-MIB::dot1dStpPortState ifInErrors ifOutErrors ifInDiscards
If it's started without any arguments, script will show additional OIDs which might be interesting to include along
default ones. So, to pull ifAdminStatus on all switches we can do something like:
# ssh auto-login script for Dell switches
./ips | xargs -i ./dell-switch.pl {} "show bridge address"
./ips | xargs -i ./dell-switch.pl {} "show interfaces status"
./ips | xargs -i ./dell-switch.pl {} "show running-config"
This will save all commands executed to git repository under log/
However, somethimes you just need to execute few commands but don't want
log output (if configuring switches in batch, for example). You can do
that by setting NO_LOG enviroment variable like this:
grep -A 1 sw-lib /etc/munin/munin.conf | grep 10.20 | awk '{ print $2 }' \
| NO_LOG=1 xargs -i ./dell-switch.pl 'snmp-server community public-or-not ro view Default' 'exit' 'copy running-config startup-config'
To use fans script first pull show system from all switches:
./ips | xargs -i ./dell-switch.pl {} "show system"
Backup switch configuration to tftp server:
./ips 1,2 | awk '{ print "./dell-switch.pl "$1" \"copy startup-config tftp://10.20.0.253/backups/"$2".config\"" }' | NO_LOG=1 sh -x
To use snmp* utils, create snmp.conf with:
COMMUNITY=my-comminity-or-public
# Find mac address on network
collect all mac addresses using snmp
dpavlin@black:~/dell-switch$ ./sw-mac-port.sh
find interesting mac
dpavlin@black:~/dell-switch$ ./find-port-for-mac 00:1e:8c:0a:49:3c # eeepy eth0
sw-e300 1 00:1e:8c:0a:49:3c 23
sw-e300-2 1 00:1e:8c:0a:49:3c 21
# mac 00:1e:8c:0a:49:3c on 41 switches
dpavlin@black:~/dell-switch$ ./find-port-for-mac 00:80:c8:37:6d:76 # eeepy eth3
sw-e300 1 00:80:c8:37:6d:76 17
# mac 00:80:c8:37:6d:76 on 41 switches
# switch configuration helpers
ssh-switch-port-vlan sw port vlan
ssh-switch-port-shutdown sw port [no]
ssh-snmp-server-rw sw