Hallo allerseits,
ich hab noch ne LED in meiner Front übrig und wollte gerne ne gelbe LED abhaengig von der CPU load schalten.
Gelb leuchten heisst hoher load, gelb blinken hoeherer Load ;).
Default ist <50% nix, 50 - 75% leuchten, >75% blinken. Andere Werte einfach dem Script als Parameter uebergeben.
Bash
#!/bin/bash
if [ "$#" -lt 2 ] ; then
threshold2='75'
else
threshold2=$2
fi
if [ "$#" -lt 1 ] ; then
threshold1='50'
else
threshold1=$1
fi
# using the 5min average ($2) of loadavg.
load=`cat /proc/loadavg | awk '{$load =$2; sub(/\./,",",$load); print $load * 100}'`
echo -n "Load ("$load"%) is ";
if [ "$load" -lt "$threshold1" ] ; then
echo "low.";
irsend send_once EXTB_TX R_LD4
elif [ "$load" -lt "$threshold2" ] ; then
echo "high!";
irsend send_once EXTB_TX S_LD4
else
echo "extremly high!";
irsend send_once EXTB_TX B_LD4
fi
Alles anzeigen
Anpassen muss man natuerlich die irsend Zeile wenn ihr ne andere LED als LED4 nutzen wollt. Aber ich binmir sicher, dass ihr das hinbekommt.
Das script muss nur regelmaessig aufgerufen werden. Ich habs mit cron gemacht.
.
Fertisch!