#! /bin/bash set -u set -e # LUG is considered online if at least one of the ports on switch0 is up # 4: Table switch 1 # 6: Table switch 2 # 25: Switch above fridge PORTS="4 6 26" AGENT="switch0" OID_PREF="1.3.6.1.2.1.2.2.1.8." COMMUNITY=public SNMP_VERSION=1 STATUSFILE="/tmp/lug-status.dat" for port in $PORTS; do status=`snmpget -v $SNMP_VERSION -c $COMMUNITY -O vq $AGENT $OID_PREF$port` if [ "$status" = "up" ]; then echo 1 > $STATUSFILE exit 0 fi done # LUG is offline if all ports are down echo 0 > $STATUSFILE