filter log/ filenames into sw.command
[dell-switch] / README
1 # manage Dell switch running-config in git
2
3 dpavlin@black:~/dell-switch$ ./sw-running-config.sh sw-dpc
4
5
6 # /dev/shm/port-status
7
8 Collect information about port status using snmp
9
10 dpavlin@black:~/dell-switch$ ./snmp-port-status.sh sw-core # single switch
11
12 dpavlin@black:~/dell-switch$ ./sw-port-status.sh # all switches
13
14 This will populate /dev/shm/port-status/ and manage changes in git
15
16 You can grep for ports on switches since format is "switch port ...."
17
18 dpavlin@black:~/dell-switch$ egrep ' (15|22) ' /dev/shm/port-status/sw-dpc 
19 sw-dpc 15 g15 1000 up ethernetCsmacd [sw-baraka]
20 sw-dpc 22 g22 100 up ethernetCsmacd [PIX-eth1]
21
22 You can also grep only for sw-name and get both uplink port (if in description)
23 and ports from switch:
24
25 dpavlin@black:/dev/shm/port-status$ egrep sw-baraka * | head
26 sw-a200:sw-a200 22 g22 1000 up ethernetCsmacd [sw-baraka]
27 sw-baraka:sw-baraka 1 g1 1000 down ethernetCsmacd
28 sw-baraka:sw-baraka 2 g2 1000 down ethernetCsmacd
29 sw-baraka:sw-baraka 3 g3 1000 down ethernetCsmacd
30 sw-baraka:sw-baraka 4 g4 1000 down ethernetCsmacd
31 sw-baraka:sw-baraka 5 g5 10 up ethernetCsmacd
32 sw-baraka:sw-baraka 6 g6 1000 down ethernetCsmacd
33 sw-baraka:sw-baraka 7 g7 1000 down ethernetCsmacd
34 sw-baraka:sw-baraka 8 g8 1000 down ethernetCsmacd
35 sw-baraka:sw-baraka 9 g9 1000 down ethernetCsmacd
36
37 Get additional OID from switches:
38
39 dpavlin@black:~/dell-switch$ ./snmp-port-status.sh
40 Usage: ./snmp-port-status.sh hostname ifAdminStatus BRIDGE-MIB::dot1dStpPortState ifInErrors ifOutErrors ifInDiscards
41
42 If it's started without any arguments, script will show additional OIDs which might be interesting to include along
43 default ones. So, to pull ifAdminStatus on all switches we can do something like:
44
45
46
47
48
49
50 # ssh auto-login script for Dell switches
51
52 ./ips | xargs -i ./dell-switch.pl {} "show bridge address"
53
54 ./ips | xargs -i ./dell-switch.pl {} "show interfaces status"
55
56 ./ips | xargs -i ./dell-switch.pl {} "show running-config"
57
58 This will save all commands executed to git repository under log/
59
60 However, somethimes you just need to execute few commands but don't want
61 log output (if configuring switches in batch, for example). You can do
62 that by setting NO_LOG enviroment variable like this:
63
64 grep -A 1 sw-lib /etc/munin/munin.conf | grep 10.20 | awk '{ print $2 }' \
65 | NO_LOG=1 xargs -i ./dell-switch.pl 'snmp-server community public-or-not ro view Default' 'exit' 'copy running-config startup-config'
66
67
68 To use fans script first pull show system from all switches:
69
70 ./ips | xargs -i ./dell-switch.pl {} "show system"
71
72
73 Backup switch configuration to tftp server:
74
75 ./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
76
77
78 To use snmp* utils, create snmp.conf with:
79
80 COMMUNITY=my-comminity-or-public
81
82
83 # Find mac address on network
84
85 collect all mac addresses using snmp
86
87 dpavlin@black:~/dell-switch$ ./sw-mac-port.sh 
88
89 find interesting mac
90
91 dpavlin@black:~/dell-switch$ ./find-port-for-mac 00:1e:8c:0a:49:3c # eeepy eth0
92 sw-e300 1 00:1e:8c:0a:49:3c 23
93 sw-e300-2 1 00:1e:8c:0a:49:3c 21
94 # mac 00:1e:8c:0a:49:3c on 41 switches
95
96 dpavlin@black:~/dell-switch$ ./find-port-for-mac 00:80:c8:37:6d:76 # eeepy eth3
97 sw-e300 1 00:80:c8:37:6d:76 17
98 # mac 00:80:c8:37:6d:76 on 41 switches
99
100
101
102 # switch configuration helpers
103
104 ssh-switch-port-vlan sw port vlan
105 ssh-switch-port-shutdown sw port [no]
106 ssh-snmp-server-rw sw
107