Created
July 10, 2010 12:40
-
-
Save pyropeter/470688 to your computer and use it in GitHub Desktop.
Simple system monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
interval=5 | |
intervalLong=300 | |
function getSensors { | |
sensors | awk 'BEGIN {FS=":? +"} /^Core|^fan[12]|^temp/ {printf "%9s %9s\n", $1, $2}' | |
} | |
function getDiskfree { | |
df -hP | sort -rnk5 | awk '/[89][0-9]%|100%/ {printf "%9s %9s %s\n", $4, $5, $6}' | |
} | |
function getHddtemp { | |
hddtemp /dev/sda /dev/sdb | awk 'BEGIN {FS=": "} // {printf "%9s %9s %s\n", $1, $3, $2}' 2>/dev/null | |
} | |
function outRefresh { | |
echo -e "\n\n\n\n\n\n\n\n\n\n\n" | |
echo "$outSensors" | |
echo | |
echo "$outDiskfree" | |
if [ ${#outHddtemp} -gt 0 ]; then | |
echo | |
echo "$outHddtemp" | |
fi | |
echo | |
echo -n "$(uptime)" | |
} | |
function trapInt { | |
outSensors=$(getSensors) | |
outDiskfree=$(getDiskfree) | |
outHddtemp=$(getHddtemp) | |
outRefresh | |
echo -ne "\nPress ^C again quickly to quit" | |
trap SIGINT | |
sleep 1 | |
trap trapInt SIGINT | |
} | |
trap trapInt SIGINT | |
while true; do | |
outDiskfree=$(getDiskfree) | |
outHddtemp=$(getHddtemp) | |
for (( i=0 ; i<$(($intervalLong/$interval + 1)) ; i++ )); do | |
outSensors=$(getSensors) | |
outRefresh | |
sleep $interval | |
done | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Core 0 +43.0°C | |
Core 1 +43.0°C | |
fan1 1371 RPM | |
fan2 1110 RPM | |
temp1 +36.0°C | |
temp2 +43.0°C | |
temp3 +83.0°C | |
1.7G 99% /mnt/datenhalde | |
1.3G 97% /mnt/deb-home | |
8.0G 96% /mnt/gralde2 | |
11G 80% /home | |
32G 80% /mnt/gralde4 | |
/dev/sda 38°C WDC WD3200AAKS-00L9A0 | |
/dev/sdb 39°C WDC WD5000AADS-00M2B0 | |
10:25:01 up 6 days, 10:46, 29 users, load average: 0.02, 0.01, 0.00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment