#!/bin/sh # # $Id: sensorstats,v 1.1.1.1 2003/10/04 16:01:42 karsten Exp $ # ######################################################################### # Sensorstats # # Get some stats from the i2c-bus, put them in a simple table and # draw some pics with gnuplot and imagemagick. # # Hacked by Karsten Kruse, tecneeq@gmx.net http://www.tecneeq.de/ # ######################################################################### # Crontabexample # # fetch statistics # * * * * * sensorstats --get # # make pics # 01 * * * * sensorstats --output ######################################################################### # Some Settings path_output="/home/karsten/webs/tecneeq/pics/sensorstats_workstation" path_database="/home/karsten/bin/sensorstats1/database" your_sensors="/proc/sys/dev/sensors/via686a-isa-6000" test_enviroment() { if [ ! -d $path_output ] ; then echo "ERROR: Directory $path_output not found." echo "Where should i put my Stats?" exit 1 fi if [ ! -d $path_database ] ; then echo "ERROR: Directory $path_database does not exist." echo "Where should i put my Databases?" exit 1 fi if [ ! -d $your_sensors ] ; then echo "ERROR: $your_sensors does not exist." echo "Where should i fetch my Numbers from?" echo "I will continue, but you should setup I2C and sensors!" fi } fetchstats() { # Fetch the raw numbers and put them into the tables cat $your_sensors/in0 | cut -d " " -f 3 >> $path_database/in0_core.db cat $your_sensors/in2 | cut -d " " -f 3 >> $path_database/in2_io.db cat $your_sensors/in3 | cut -d " " -f 3 >> $path_database/in3_5v.db cat $your_sensors/in4 | cut -d " " -f 3 >> $path_database/in4_12v.db cat $your_sensors/temp1 | cut -d " " -f 3 >> $path_database/temp1_cpu.db cat $your_sensors/temp2 | cut -d " " -f 3 >> $path_database/temp2_sys.db cat /proc/loadavg | cut -d " " -f 1 >> $path_database/load1.db cat /proc/loadavg | cut -d " " -f 2 >> $path_database/load2.db cat /proc/loadavg | cut -d " " -f 3 >> $path_database/load3.db #cat fan1_cpu.db | sed -n '$p' # Trim files to 24 hour window for i in `ls *.db` ; do if [ `wc -l < $i` -gt 1440 ] ; then tail $i -n1440 > ${i}.tmp mv ${i}.tmp $i fi done } makepics() { # Convert the tables into pics. This is gnuplot-syntax until EOF appears! gnuplot < put stats to database" echo " sensorstats --output ==> convert database to pics" echo " sensorstats --help ==> this helptext" echo " Needs: gnuplot with png-support and lmsensors" } test_enviroment cd $path_database case $1 in --get|-g) fetchstats ; exit ;; --output|-o) makepics ; exit ;; --help|-h) usage ; exit ;; *) usage ; exit 1 ;; esac