From 984f5f4c9106348d575c5895ae0a2c738767c536 Mon Sep 17 00:00:00 2001 From: Marios Andreopoulos Date: Thu, 21 Feb 2013 04:36:16 +0200 Subject: [PATCH] initial commit --- scripts/mled-iowaitdetailed | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 scripts/mled-iowaitdetailed diff --git a/scripts/mled-iowaitdetailed b/scripts/mled-iowaitdetailed new file mode 100755 index 0000000..d5ac6c4 --- /dev/null +++ b/scripts/mled-iowaitdetailed @@ -0,0 +1,44 @@ +#!/bin/bash + +THRESH1="1.00" +THRESH2="5.00" +THRESH3="20.00" +THRESH4="40.00" +THRESH5="80.00" +REFRESHRATE=1 + +LEDCONTROLLER="/usr/bin/ledcontroller" + + +iostat -c "$REFRESHRATE" | while read iostatOutput; do + + iowaitPercent="$(echo "$iostatOutput" | grep -vE "Linux|avg|^$" | awk '{print $4}')" + + [ -z "$iowaitPercent" ] || \ + if (( $(bc <<< "$iowaitPercent > $THRESH1") == 0 )); then + + $LEDCONTROLLER off + + elif (( $(bc <<< "$iowaitPercent > $THRESH2") == 0 )); then + + $LEDCONTROLLER green + + elif (( $(bc <<< "$iowaitPercent > $THRESH3") == 0 )); then + + $LEDCONTROLLER aqua # blue and green + + elif (( $(bc <<< "$iowaitPercent > $THRESH4") == 0 )); then + + $LEDCONTROLLER blue + + elif (( $(bc <<< "$iowaitPercent > $THRESH5") == 0 )); then + + $LEDCONTROLLER purple # red and blue + + else + + $LEDCONTROLLER red + + fi + +done