initial commit
initial commit

file:b/cputemp.sh (new)
--- /dev/null
+++ b/cputemp.sh
@@ -1,1 +1,24 @@
+#!/bin/bash
+LOG=/usr/bin/logger
+DOWN=/sbin/shutdown
+ALERT_LEVEL=65
 
+CPUTEMP=$(sensors | grep "Physical id" | awk '{ print $4}')
+CPUTEMP="$(echo "$CPUTEMP" | sed 's/[^0-9]//g')"
+CPUTEMP=$(($CPUTEMP/10))
+
+if [ $CPUTEMP -ge $ALERT_LEVEL ]; then
+	$LOG "System going down as CPU temperature $CPUTEMP C crossed the limit"
+	sync;sync
+	# notification method. I use boxcar.io push messages to my phone
+	#screen -dmS cpu curl -d "email=" \
+	#-d "&notification[from_screen_name]=" \
+	#-d "&notification[message]=CPU Temp is $CPUTEMP" \
+	#http://boxcar.io/devices/providers/hash/notifications
+	# shut down system
+        $DOWN -h 0
+else
+	$LOG "CPU temperature : $CPUTEMP C"
+	sync;sync
+fi
+

file:b/hddtemp.sh (new)
--- /dev/null
+++ b/hddtemp.sh
@@ -1,1 +1,30 @@
+#!/bin/bash
+HDDS="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde"
+HDT=/usr/sbin/hddtemp
+LOG=/usr/bin/logger
+DOWN=/sbin/shutdown
+ALERT_LEVEL=55
 
+for disk in $HDDS
+do
+  if [ -b $disk ]; then
+	HDTEMP=$($HDT $disk | awk '{ print $4}')
+	HDTEMP="$(echo "$HDTEMP" | sed 's/[^0-9]//g')"
+        if [ $HDTEMP -ge $ALERT_LEVEL ]; then
+		$LOG "System going down as hard disk : $disk temperature $HDTEMP C crossed the limit"
+		sync;sync
+		ss="$(echo "$disk" | sed 's/[^a-z]//g')"
+		# notification method. I use boxcar.io push messages to my phone
+		#screen -dmS $ss curl -d "email=" \
+		#-d "&notification[from_screen_name]=" \
+		#-d "&notification[message]=CPU Temp is $CPUTEMP" \
+		#http://boxcar.io/devices/providers/hash/notifications
+		# shut down system
+		$DOWN -h 0
+	else
+		$LOG "Hard disk temperature : $disk $HDTEMP C"
+		sync;sync
+        fi
+  fi
+done
+

comments