update script for monitoring switch temparature
[debian6500.git] / master / opt / script / get_switch_temperature
CommitLineData
a3300608
LM
1#!/bin/sh
2
e26ccab6 3CONNECT_SWITCH=/opt/script/connect_switch
a3300608
LM
4
5PROGNAME=$(basename $0)
6
7# formating functions
8
9_echo () { [ "$(echo -e '')" ] && echo $@ || echo -e $@; }
10title () { _echo "\033[0;1m$*\033[0;0m"; }
11pass () { _echo "\033[1;32m$*\033[0;0m"; }
12warn () { _echo "\033[1;33m$*\033[0;0m"; }
13fail () { _echo "\033[1;31m$*\033[0;0m"; }
14
15usage () {
16 echo "usage: $PROGNAME [-h] [-s host]"
17 echo " -h: help message"
18 echo " -s host: switch hostname"
19 exit $@
20}
21
22[ -x $CONNECT_SWITCH ] || exit 0
23
24# argument processing
25
26while [ $# -gt 0 ]; do
27 case "$1" in
28 -h) usage 0;;
29 -s) shift; SWITCH=$1;;
30 esac
31 shift
32done
33
34[ "$SWITCH" ] || usage 1
35ping -c 1 -w 1 $SWITCH 2>&1 1>/dev/null || exit 1
36
37$CONNECT_SWITCH $SWITCH -c 'show platform chassis status' | \
38 awk '/air/ { sub(/\r/, ""); print "'$SWITCH': ", $3, $4, $2 }' | \
39 logger -t switch