sqlite database for stats master
sqlite database for stats

file:a/cputemp.sh (deleted)
--- a/cputemp.sh
+++ /dev/null
@@ -1,24 +1,1 @@
-#!/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:a/hddtemp.sh (deleted)
--- a/hddtemp.sh
+++ /dev/null
@@ -1,30 +1,1 @@
-#!/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
-

file:b/runscripts.sh (new)
--- /dev/null
+++ b/runscripts.sh
@@ -1,1 +1,6 @@
+#!/bin/bash
 
+for script in `ls /opt/scripts/*.sh`; do 
+	. $script
+done;
+

--- /dev/null
+++ b/scripts/cputemp.sh
@@ -1,1 +1,28 @@
+#!/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
+else
+	$LOG "CPU temperature : $CPUTEMP C"
+	sync;sync
+fi
+
+sqlite3 stats.db  "create table if not exists stats (id INTEGER PRIMARY KEY,data REAL,type TEXT,desc TEXT,data DATETIME);"
+sqlite3 stats.db  "insert into temp (data,type,desc,data) values ('$CPUTEMP','cpu','','$(date "+%Y-%m-%d %H:%M:%S")');"
+
+

--- /dev/null
+++ b/scripts/hddtemp.sh
@@ -1,1 +1,32 @@
+#!/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
+	else
+		$LOG "Hard disk temperature : $disk $HDTEMP C"
+		sync;sync
+	fi
+	sqlite3 stats.db  "create table if not exists stats (id INTEGER PRIMARY KEY,data REAL,type TEXT,desc TEXT,data DATETIME);"
+	sqlite3 stats.db  "insert into stats (data,type,desc,data) values ('$HDTEMP','hdd','$disk','$(date "+%Y-%m-%d %H:%M:%S")');"
+fi
+done
+

file:b/scripts/uptime.sh (new)
--- /dev/null
+++ b/scripts/uptime.sh
@@ -1,1 +1,24 @@
+#!/bin/bash
+LOG=/usr/bin/logger
+ALERT_LEVEL=10
 
+LOAD=$(uptime | awk -F'average: ' '{print $2}')
+LOAD=$(echo "$LOAD" | awk -F' ' '{print $1}' | sed -r 's/,//g')
+
+if [ $(echo "$LOAD > $ALERT_LEVEL" | bc) -eq 1 ]; then
+	$LOG "System load is $LOAD crossed the limit"
+	sync;sync
+	# notification method. I use boxcar.io push messages to my phone
+	#screen -dmS boxcar curl -d "email=" \
+	#-d "&notification[from_screen_name]=" \
+	#-d "&notification[message]=Load is $LOAD" \
+	#http://boxcar.io/devices/providers/hash/notifications
+else
+	$LOG "Load : $LOAD"
+	sync;sync
+fi
+
+sqlite3 stats.db  "create table if not exists stats (id INTEGER PRIMARY KEY,value REAL,type TEXT,desc TEXT,date DATETIME);"
+sqlite3 stats.db  "insert into stats (value,type,desc,date) values ('$LOAD','load','','$(date "+%Y-%m-%d %H:%M:%S")');"
+
+

file:a/uptime.sh (deleted)
--- a/uptime.sh
+++ /dev/null
@@ -1,24 +1,1 @@
-#!/bin/bash
-LOG=/usr/bin/logger
-ALERT_LEVEL=10
 
-LOAD=$(uptime | awk '{ print $10}')
-LOAD=$(echo "$LOAD" | sed -r 's/,//g')
-if [ "$LOAD" == "" ]; then
-	LOAD=$(uptime | awk '{ print $11}')
-	LOAD=$(echo "$LOAD" | sed -r 's/,//g')
-fi
-
-if [ $(echo "$LOAD > $ALERT_LEVEL" | bc) == 1 ]; then
-	$LOG "System load is $LOAD crossed the limit"
-	sync;sync
-	# notification method. I use boxcar.io push messages to my phone
-	#screen -dmS boxcar curl -d "email=" \
-	#-d "&notification[from_screen_name]=" \
-	#-d "&notification[message]=Load is $LOAD" \
-	#http://boxcar.io/devices/providers/hash/notifications
-else
-	$LOG "Load : $LOAD"
-	sync;sync
-fi
-

comments