This commit is contained in:
@ -1,12 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
REFRESHRATE=1
|
REFRESHRATE=1
|
||||||
LEDCONTROLLER="/usr/bin/ledcontroller"
|
LEDCONTROLLER="./ledcontroller"
|
||||||
|
|
||||||
while (true); do
|
while (true); do
|
||||||
|
|
||||||
for discoColor in blue red green aqua purple yellow white; do
|
for discoColor in blue red green aqua purple yellow white; do
|
||||||
|
echo Set color $discoColor
|
||||||
$LEDCONTROLLER $discoColor
|
$LEDCONTROLLER $discoColor
|
||||||
|
|
||||||
sleep "$REFRESHRATE"
|
sleep "$REFRESHRATE"
|
@ -1,40 +0,0 @@
|
|||||||
# Bash Scripts #
|
|
||||||
|
|
||||||
I teared the notifier apart and placed the notifier's board inside my home server.
|
|
||||||
Due to its size, the RGB LED creates some interesting optical effects if you place it 2-4cm
|
|
||||||
behind the venting holes.
|
|
||||||
|
|
||||||
Here are some simple scripts that use various data to set the LED's color.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## mled-discomode ##
|
|
||||||
|
|
||||||
This script simply cycles through all available colors. I called it disco mode due to the optical
|
|
||||||
phenomena that take place as the light crosses the air vents.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## mled-cputemp ##
|
|
||||||
|
|
||||||
This script works really well for my machine. It uses the `sensors` program to get the CPU
|
|
||||||
temperature.
|
|
||||||
|
|
||||||
If the CPU is at or under the low threshold, the LED turns blue. If it is at or above the
|
|
||||||
high threshold, the LED turns red. If it is in the middle, it gets green.
|
|
||||||
|
|
||||||
It is actually very informative for the machine's state. You can easily detect CPU load.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## mled-iowait, mled-iowaitdetailed ##
|
|
||||||
|
|
||||||
My home server doesn't have any LEDs for HDD activity, though it has plenty of HDDs.
|
|
||||||
These two scripts attempt to make up for this shortcoming when I need some quick profiling of the machine.
|
|
||||||
They actually work better than common HDD activity LEDs because they are based on iowait percentage in one
|
|
||||||
second periods (adjustable).
|
|
||||||
|
|
||||||
`mled-iowait` has 3 levels, so you get only to set a low and a high threshold.
|
|
||||||
|
|
||||||
`mled-iowaitdetailed` has 6 levels of activity, so you can set 5 thresholds. Also below the lowest threshold,
|
|
||||||
it sets the notifier to off, which turns to be a good approach.
|
|
@ -1,28 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
LOWTEMP=46
|
|
||||||
HIGHTEMP=53
|
|
||||||
REFRESHRATE=1
|
|
||||||
LEDCONTROLLER="/usr/bin/ledcontroller"
|
|
||||||
|
|
||||||
|
|
||||||
while (true); do
|
|
||||||
|
|
||||||
temperature="$(sensors|grep 'id 0'|sed -e 's/\.0.*//' -e 's/.*+//')"
|
|
||||||
|
|
||||||
if (( "$temperature" <= "$LOWTEMP" )); then
|
|
||||||
|
|
||||||
$LEDCONTROLLER blue;
|
|
||||||
|
|
||||||
elif (( "$temperature" < "$HIGHTEMP" )); then
|
|
||||||
|
|
||||||
$LEDCONTROLLER green;
|
|
||||||
|
|
||||||
else $LEDCONTROLLER red;
|
|
||||||
|
|
||||||
fi;
|
|
||||||
|
|
||||||
sleep "$REFRESHRATE";
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
LOWTHRESHOLD="1.01"
|
|
||||||
HIGHTHRESHOLD="30.2"
|
|
||||||
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 > $LOWTHRESHOLD") == 0 )); then
|
|
||||||
|
|
||||||
$LEDCONTROLLER blue
|
|
||||||
|
|
||||||
elif (( $(bc <<< "$iowaitPercent > $HIGHTHRESHOLD") == 0 )); then
|
|
||||||
|
|
||||||
$LEDCONTROLLER green
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
$LEDCONTROLLER red
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
# This is an older version of the code, which used /proc/stats to do a similar job.
|
|
||||||
|
|
||||||
#iowaitCounter="$(grep 'cpu ' /proc/stat | cut -f 9 -d ' ')"
|
|
||||||
#$LEDCONTROLLER blue
|
|
||||||
#ledcolor="blue"
|
|
||||||
#
|
|
||||||
#while (true); do
|
|
||||||
#
|
|
||||||
# iowaitTemp="$(grep 'cpu ' /proc/stat | cut -f 9 -d ' ')"
|
|
||||||
#
|
|
||||||
## echo "iowaitCounter=$iowaitCounter, iowaitTemp=$iowaitTemp"
|
|
||||||
#
|
|
||||||
# if (( "$iowaitCounter" == "$iowaitTemp" )); then
|
|
||||||
#
|
|
||||||
# if [ "$ledcolor" != "blue" ]; then
|
|
||||||
#
|
|
||||||
# $LEDCONTROLLER blue
|
|
||||||
# ledcolor="blue"
|
|
||||||
#
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# else
|
|
||||||
#
|
|
||||||
# iowaitCounter="$iowaitTemp"
|
|
||||||
#
|
|
||||||
# if [ "$ledcolor" != "red" ]; then
|
|
||||||
#
|
|
||||||
# $LEDCONTROLLER red;
|
|
||||||
# ledcolor="red"
|
|
||||||
#
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# sleep "$REFRESHRATE";
|
|
||||||
#
|
|
||||||
#done
|
|
||||||
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
#!/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
|
|
Reference in New Issue
Block a user