X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=master%2Fopt%2Fscript%2Fget_switch_temperature;fp=master%2Fopt%2Fscript%2Fget_switch_temperature;h=26c376705738f83ebd55b5239ad35b676d9d81fb;hb=e26ccab66416998c2a67e9d4360920ff0c9e235f;hp=0000000000000000000000000000000000000000;hpb=b7c1e1037154b129986b2c7fd921e1df240e36a7;p=debian6500.git diff --git a/master/opt/script/get_switch_temperature b/master/opt/script/get_switch_temperature new file mode 100755 index 0000000..26c3767 --- /dev/null +++ b/master/opt/script/get_switch_temperature @@ -0,0 +1,39 @@ +#!/bin/sh + +CONNECT_SWITCH=/opt/script/connect_switch + +PROGNAME=$(basename $0) + +# formating functions + +_echo () { [ "$(echo -e '')" ] && echo $@ || echo -e $@; } +title () { _echo "\033[0;1m$*\033[0;0m"; } +pass () { _echo "\033[1;32m$*\033[0;0m"; } +warn () { _echo "\033[1;33m$*\033[0;0m"; } +fail () { _echo "\033[1;31m$*\033[0;0m"; } + +usage () { + echo "usage: $PROGNAME [-h] [-s host]" + echo " -h: help message" + echo " -s host: switch hostname" + exit $@ +} + +[ -x $CONNECT_SWITCH ] || exit 0 + +# argument processing + +while [ $# -gt 0 ]; do + case "$1" in + -h) usage 0;; + -s) shift; SWITCH=$1;; + esac + shift +done + +[ "$SWITCH" ] || usage 1 +ping -c 1 -w 1 $SWITCH 2>&1 1>/dev/null || exit 1 + +$CONNECT_SWITCH $SWITCH -c 'show platform chassis status' | \ + awk '/air/ { sub(/\r/, ""); print "'$SWITCH': ", $3, $4, $2 }' | \ + logger -t switch