update script for monitoring switch temparature
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Mon, 9 Nov 2015 15:28:20 +0000 (16:28 +0100)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Mon, 9 Nov 2015 15:28:20 +0000 (16:28 +0100)
master/etc/cron.d/getswitchtemp
master/opt/script/get_switch_temperature [new file with mode: 0755]
master/root/bin/get_switch_temperature [deleted file]

index e76173b5f56e6d9e76409f000d8711b5ca131dbf..633520356f8405c600b2997fe7bfec5c6c52e06d 100644 (file)
@@ -1,2 +1,4 @@
 # m h dom mon dow user command
-0-59/5 * * * *   root  /root/bin/get_switch_temperature
+#0-59/5 * * * *          root  /opt/script/get_switch_temperature swg1
+#1-59/5 * * * *          root  /opt/script/get_switch_temperature swg1
+#2-59/5 * * * *          root  /opt/script/get_switch_temperature swm
diff --git a/master/opt/script/get_switch_temperature b/master/opt/script/get_switch_temperature
new file mode 100755 (executable)
index 0000000..26c3767
--- /dev/null
@@ -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
diff --git a/master/root/bin/get_switch_temperature b/master/root/bin/get_switch_temperature
deleted file mode 100755 (executable)
index 64eb005..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-CONNECT_SWITCH=/root/bin/connect_switch.tcl
-
-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