sensors monitoring via minimyth.script

Share your success stories with others

Moderator: Pablo

Post Reply
hads
Member
Posts: 16
Joined: Tue Feb 06, 2007 9:45 pm

sensors monitoring via minimyth.script

Post by hads » Tue Feb 13, 2007 8:27 am

Hi all,

I've been playing with the fans (lowering voltage etc.) on my EK10000G and wanted a way to monitor them and the temperature until I feel comfortable with how they are going.

I came up with the following minimyth.script which calls back to a script on my backend to log the temperature and let me know if the fans stop or whatever. This seemed to be the easiest way as there is no need to modify minimyth itself.

I'm posting it here in case someone else finds it useful. It will probably only work with the output of sensors if you are using the w83627hf module but should be easy enough to adjust for whatever else you need.

hads

Code: Select all

#!/bin/sh

SERVER_URL="http://frog/monitor/"

cat > /tmp/monitor <<EOF
#!/bin/sh
###
# *** Generated automatically at boot ***
#
# This script monitors the temperature and the speed
# of the CPU and case fans.
#
# It will wget a URL every 2 minutes with the values
# as part of the query string.
###

HOST=\`/bin/hostname\`

while /bin/true; do
	TEMP=\`/usr/bin/sensors | /bin/grep temp2 | /usr/bin/cut -d ' ' -f 6\`
	CPU=\`/usr/bin/sensors | /bin/grep fan1 | /usr/bin/cut -d ' ' -f 6\`
	CASE=\`/usr/bin/sensors | /bin/grep fan2 | /usr/bin/cut -d ' ' -f 6\`

	ANSWER=\`/usr/bin/wget -q -O - "$SERVER_URL?host=\${HOST}&temp=\${TEMP}&cpu=\${CPU}&case=\${CASE}"\`
	if [ "\$ANSWER" = "SHUTDOWN" ]; then
		/sbin/shutdown -h now
	fi
	/bin/sleep 2m
done

EOF

chmod 755 /tmp/monitor
/tmp/monitor &

Post Reply