#!/bin/sh

#
# Processing uptime data
# 
# cat uptime |awk '{print $1*10000}'  > norm_min_uptime
#
# gnuplot commands
# ----------------
# > plot "fan0_actual_speed" smooth csplines, "fan1_actual_speed" smooth csplines, "temperature_0" smooth csplines, "temperature_1" smooth csplines, "temperature_2" smooth csplines,  "temperature_3" smooth csplines, "temperature_4" smooth csplines, "temperature_5" smooth csplines
#
# > replot "norm_min_uptime" smooth csplines
#

sysdir=/sys/devices/platform/applesmc


mkdir $1

while 'true'; 
do
	for x in `cd $sysdir; ls temperature_*`; 
	do 
		cat $sysdir/$x >> $1/$x; 
	done

	for x in `cd $sysdir; ls fan?_act*`;	 
	do 
		cat $sysdir/$x >> $1/$x; 
	done

	uptime |awk '{print $8 " " $9 " " $10}'| sed 's/,//'|sed 's/,//' >> $1/uptime
sleep 30
done