#!/bin/bash # Exit-Codes: # 0 = $STATE_OK # 1 = $STATE_WARNING # 2 = $STATE_CRITICAL # 3 = $STATE_UNKNOWN if [[ -z $1 ]] ; then echo "Usage: $0 " exit 3 fi DEV=$1 RET=0 if [[ -d /sys/class/net/$DEV ]] ; then LINKING=`cat /sys/class/net/$DEV/operstate` if [[ "$LINKING" == "up" ]] ; then echo -n " $DEV up" SPEED=`cat /sys/class/net/$DEV/speed` if [[ -n $SPEED ]] ; then echo -n " $SPEED" fi else echo -n " $DEV down" [[ $RET -lt 2 ]] && RET=2 fi else echo -n "$DEV Not found in sysfs" RET=2 fi echo exit $RET