cleanup code, more examples
[dell-switch] / snmp-port-toggle.sh
1
2 sw=sw-a200
3 PORT=19
4
5 . ./snmp.conf
6
7 snmp="snmpget -v 2c -c $COMMUNITY -Cf -Ov -OQ $sw"
8
9 port_status() {
10
11 echo -n "$sw $PORT "`$snmp IF-MIB::ifName.$PORT IF-MIB::ifAlias.$PORT IF-MIB::ifType.$PORT IF-MIB::ifOperStatus.$PORT IF-MIB::ifHighSpeed.$PORT`
12
13 }
14
15 port_status
16
17 read -p "# Press ENTER to toggle port" wait_for_key
18
19 if [ "$status" = 'up' ] ; then
20
21         # down
22         snmpset -v1 -c $COMMUNITY $sw IF-MIB::ifAdminStatus.$PORT i 2
23 else
24         # up
25         snmpset -v1 -c $COMMUNITY $sw IF-MIB::ifAdminStatus.$PORT i 1
26 fi
27
28 port_status
29