From c231b53a57a50b6e424828903cc9fcde9d6e32de Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sat, 31 Mar 2001 04:50:25 +0000 Subject: [PATCH] the famous "tellerstats" package of Phil's with updates from me and Hans Ecke . Intent is a simple package which can be customized, configured, and installed easily. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1051 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/tellerstats/README | 46 ++++++++ prog/tellerstats/gather.sh | 143 ++++++++++++++++++++++++ prog/tellerstats/gnuplotscript.tmpl | 79 +++++++++++++ prog/tellerstats/index.shtml | 48 ++++++++ prog/tellerstats/tellerstats.conf | 30 +++++ prog/tellerstats/tellerstats.sh | 165 ++++++++++++++++++++++++++++ 6 files changed, 511 insertions(+) create mode 100644 prog/tellerstats/README create mode 100755 prog/tellerstats/gather.sh create mode 100644 prog/tellerstats/gnuplotscript.tmpl create mode 100644 prog/tellerstats/index.shtml create mode 100644 prog/tellerstats/tellerstats.conf create mode 100755 prog/tellerstats/tellerstats.sh diff --git a/prog/tellerstats/README b/prog/tellerstats/README new file mode 100644 index 00000000..d589bb09 --- /dev/null +++ b/prog/tellerstats/README @@ -0,0 +1,46 @@ +This is tellerstats Version 1.9.2 + + +Author: Phil Edelbrock +with Changes by + Mark D. Studebaker and + Hans Ecke + +Send requests to the lm_sensors mailing list sensors@stimpy.netroedge.com. + + +Required Utilities and Packages: + + apache or other web server + + 'convert' from ImageMagick or X11 + http://www.imagemagick.org + + 'bc' command line calculator + + gnuplot + http://www.gnuplot.org + + lm_sensors + + perl + + +Follow those steps to install tellerstats: + + +* Put the following line into your /etc/crontab file + + */5 * * * * root /usr/local/install/tellerstats/gather.sh + + (change the directory to reflect where you installed gather.sh) + +* Link tellerstats.sh to /etc/cron.hourly/tellerstats.sh + +* move index.shtml into a directory accessible with a webbrowser + and configure your webserver for SSI (server side includes) + +* move tellerstats.conf to /etc and edit it to reflect correct directories + + + diff --git a/prog/tellerstats/gather.sh b/prog/tellerstats/gather.sh new file mode 100755 index 00000000..67e8cb9f --- /dev/null +++ b/prog/tellerstats/gather.sh @@ -0,0 +1,143 @@ +#!/bin/bash +# +# gather.sh +# gather the data. +# run from cron every 5 minutes. +# Don't run manually as root or else files in data/ will get +# root ownership then your (non-root) cron daemon won't work +# +# Copyright 2001 The lm_sensors group +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +# generic tellerstats init BEGIN + +# get config information from /etc/tellerstats.conf or whereever we are pointed + +if [ -z "$TELLERSTATS_CONF" ] +then + TELLERSTATS_CONF=/etc/tellerstats.conf +fi + +export TELLERSTATS_CONF + +if [ ! -r $TELLERSTATS_CONF ] +then + echo "$0: Could not find config file $TELLERSTATS_CONF" + exit 1 +fi + +. $TELLERSTATS_CONF + +if [ ! -d $DBPATH ] +then + echo "$0: data directory $DBPATH does not exist" + exit 1 +fi + +if [ ! -d $SENSORPATH ] +then + echo "$0: sensor information directory $SENSORPATH does not exist." + exit 1 +fi + +if [ ! -d $HTMLROOT ] +then + echo "$0: The root of your webserver - $HTMLROOT - does not exist..bailing out" + exit 1 +fi + +if [ ! -d $HTMLPATH ] +then + echo "$0: The place where we keep HTML files and pictures - $HTMLPATH - does not exist..bailing out" + exit 1 +fi + +if [ ! -r $GNUPLOTSCRIPT_TMPL ] +then + echo "$0: The gnuplot script template $GNUPLOTSCRIPT_TMPL does not exist..bailing out" + exit 1 +fi + +export DBPATH SENSORPATH TEMPPATH HTMLROOT HTMLPATH GNUPLOTSCRIPT_TMPL + +if [ -n "$DEBUG" ] +then + echo "DBPATH = $DBPATH" + echo "SENSORPATH = $SENSORPATH" + echo "TEMPPATH = $TEMPPATH" + echo "HTMLROOT = $HTMLROOT" + echo "HTMLPATH = $HTMLPATH" + echo "GNUPLOTSCRIPT_TMPL = $GNUPLOTSCRIPT_TMPL" +fi + +# generic tellerstats init END + +# From /etc/sensors.conf for the W83781D: +# +# compute in3 ((6.8/10)+1)*@ , @/((6.8/10)+1) +# compute in4 ((28/10)+1)*@ , @/((28/10)+1) +# compute in5 -(210/60.4)*@ , -@/(210/60.4) +# compute in6 -(90.9/60.4)*@ , -@/(90.9/60.4) +# + +#date=yyyyMMddHHmmss, the same format gnuplot expects for the x-axis +DATE=`date +%Y%m%d%H%M%S` + +T=`cat $SENSORPATH/in0 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/cpu1V + +T=`cat $SENSORPATH/in1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/cpu2V + +T=`cat $SENSORPATH/in2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/ThreeVOLT + +T=`cat $SENSORPATH/in3 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +T=`echo $T \* 1.68 | bc` +echo $DATE $T >> $DBPATH/FiveVOLT + +T=`cat $SENSORPATH/in4 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +T=`echo $T \* 3.8 | bc` +echo $DATE $T >> $DBPATH/TwelveVOLT + +T=`cat $SENSORPATH/in5 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +T=`echo $T \* -3.477 | bc` +echo $DATE $T >> $DBPATH/NegTwelveVOLT + +T=`cat $SENSORPATH/in6 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +T=`echo $T \* -1.505 | bc` +echo $DATE $T >> $DBPATH/NegFiveVOLT + +T=`cat $SENSORPATH/temp1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/mb_temp + +T=`cat $SENSORPATH/temp2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/cpu_temp + +T=`cat $SENSORPATH/fan1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/fanone + +T=`cat $SENSORPATH/fan2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/fantwo + +T=`cat $SENSORPATH/fan3 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` +echo $DATE $T >> $DBPATH/fanthree + +T=`cat /proc/loadavg | perl -p -e 's/^([^ ]+) .+$/$1/'` +echo $DATE $T >> $DBPATH/load + +exit 0 diff --git a/prog/tellerstats/gnuplotscript.tmpl b/prog/tellerstats/gnuplotscript.tmpl new file mode 100644 index 00000000..4981a277 --- /dev/null +++ b/prog/tellerstats/gnuplotscript.tmpl @@ -0,0 +1,79 @@ +set term $PLOTTERMINAL +set timefmt "%Y%m%d%H%M%S" +set notime +set autoscale xy +set size 2,2 +set data style lp +set xlabel "Time" +set xdata time + +set ylabel "Voltage (V)" + +set output "$TEMPPATH/cpu1V.$PLOTFORMAT" +plot "$DBPATH/cpu1V" using 1:2 title '' w lp lw $LINEWIDTH, \ + 2.1 title 'min' w lp lw $LINEWIDTH, \ + 2.3 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/cpu2V.$PLOTFORMAT" +plot "$DBPATH/cpu2V" using 1:2 title '' w lp lw $LINEWIDTH, \ + 2.1 title 'min' w lp lw $LINEWIDTH, \ + 2.3 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/ThreeVOLT.$PLOTFORMAT" +plot "$DBPATH/ThreeVOLT" using 1:2 title '' w lp lw $LINEWIDTH, \ + 3.0 title 'min' w lp lw $LINEWIDTH, \ + 3.6 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/FiveVOLT.$PLOTFORMAT" +plot "$DBPATH/FiveVOLT" using 1:2 title '' w lp lw $LINEWIDTH, \ + 4.85 title 'min' w lp lw $LINEWIDTH, \ + 5.15 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/TwelveVOLT.$PLOTFORMAT" +plot "$DBPATH/TwelveVOLT" using 1:2 title '' w lp lw $LINEWIDTH, \ + 11.3 title 'min' w lp lw $LINEWIDTH, \ + 12.7 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/NegTwelveVOLT.$PLOTFORMAT" +plot "$DBPATH/NegTwelveVOLT" using 1:2 title '' w lp lw $LINEWIDTH, \ + -12.7 title 'min' w lp lw $LINEWIDTH, \ + -11.3 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/NegFiveVOLT.$PLOTFORMAT" +plot "$DBPATH/NegFiveVOLT" using 1:2 title '' w lp lw $LINEWIDTH, \ + -5.25 title 'min' w lp lw $LINEWIDTH, \ + -4.75 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/voltages.$PLOTFORMAT" +plot "$DBPATH/cpu1V" using 1:2 title '1V' w lp lw $LINEWIDTH,\ + "$DBPATH/cpu2V" using 1:2 title '2V' w lp lw $LINEWIDTH,\ + "$DBPATH/ThreeVOLT" using 1:2 title '3V' w lp lw $LINEWIDTH,\ + "$DBPATH/FiveVOLT" using 1:2 title '5V' w lp lw $LINEWIDTH,\ + "$DBPATH/TwelveVOLT" using 1:2 title '12V' w lp lw $LINEWIDTH,\ + "$DBPATH/NegTwelveVOLT" using 1:2 title '-12V' w lp lw $LINEWIDTH,\ + "$DBPATH/NegFiveVOLT" using 1:2 title '-5V' w lp lw $LINEWIDTH + +set ylabel "Temperature (Degree C)" + +set output "$TEMPPATH/mb_temp.$PLOTFORMAT" +plot "$DBPATH/mb_temp" using 1:2 title '' w lp lw $LINEWIDTH, \ + 50 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/cpu_temp.$PLOTFORMAT" +plot "$DBPATH/cpu_temp" using 1:2 title '' w lp lw $LINEWIDTH, \ + 50 title 'max' w lp lw $LINEWIDTH +set output "$TEMPPATH/temps.$PLOTFORMAT" +plot "$DBPATH/mb_temp" using 1:2 title 'motherboard' w lp lw $LINEWIDTH, \ + "$DBPATH/cpu_temp" using 1:2 title 'CPU' w lp lw $LINEWIDTH + +set ylabel "Fan Speed (RPM)" + +set output "$TEMPPATH/fanone.$PLOTFORMAT" +plot "$DBPATH/fanone" using 1:2 title '' w lp lw $LINEWIDTH, \ + 3000 title 'min' w lp lw $LINEWIDTH +set output "$TEMPPATH/fantwo.$PLOTFORMAT" +plot "$DBPATH/fantwo" using 1:2 title '' w lp lw $LINEWIDTH, \ + 3000 title 'min' w lp lw $LINEWIDTH +set output "$TEMPPATH/fanthree.$PLOTFORMAT" +plot "$DBPATH/fanthree" using 1:2 title '' w lp lw $LINEWIDTH, \ + 3000 title 'min' w lp lw $LINEWIDTH + +set ylabel "Load Average" + +set output "$TEMPPATH/load.$PLOTFORMAT" +plot "$DBPATH/load" using 1:2 title '' w lp lw $LINEWIDTH + +exit + diff --git a/prog/tellerstats/index.shtml b/prog/tellerstats/index.shtml new file mode 100644 index 00000000..10f3ce19 --- /dev/null +++ b/prog/tellerstats/index.shtml @@ -0,0 +1,48 @@ + + + +Computer Hardware Statistics + + +
Computer Hardware Statistics
+Running 48 Hour Window

+ + +These plots were generated +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +

All Voltages

All Temps

System Loading

+12 Volt Supply

-5 Volt Supply

-12 Volt Supply

CPU1 Core Voltage

CPU2 Core Voltage

+3.3 Volt Supply

+5 Volt Supply

CPU Temperature (degrees C)

Motherboard Temperature (degrees C)

Fan #1 Speed (RPM)

Fan #2 Speed (RPM)

Fan #3 Speed (RPM)

+ +This page generated with drivers and the tellerstats scripts from +The lm_sensors drivers. + +

+ + + diff --git a/prog/tellerstats/tellerstats.conf b/prog/tellerstats/tellerstats.conf new file mode 100644 index 00000000..0f5f5712 --- /dev/null +++ b/prog/tellerstats/tellerstats.conf @@ -0,0 +1,30 @@ +# this is the tellerstats config file. Please be sure to +# edit these for your setup!!! + + +# where we keep the log of sensor data +DBPATH="/var/local/LM78DB/data" + +# where we get the sensor data from +SENSORPATH="/proc/sys/dev/sensors/w83781d-isa-0290" + +# where temporary plots and files are kept +TEMPPATH="/usr/tmp/lm78plots" + +# the root of the webserver +HTMLROOT="/home/httpd/html" + +# where all the web-visible files are +HTMLPATH="$HTMLROOT/tellerstats" + +# the template of the gnuplot script +GNUPLOTSCRIPT_TMPL=/usr/local/install/tellerstats/gnuplotscript.tmpl + +# linewidth of the plots +LINEWIDTH=5 + +# format (fileextensions) for primary plots +PLOTFORMAT=ps +# terminal and options for primary plots (should match above) as give to gnuplot. +# Please see gnuplot online help for "set terminal" +PLOTTERMINAL="postscript eps enhanced color \"Helvetica\" 22" diff --git a/prog/tellerstats/tellerstats.sh b/prog/tellerstats/tellerstats.sh new file mode 100755 index 00000000..2b8327c6 --- /dev/null +++ b/prog/tellerstats/tellerstats.sh @@ -0,0 +1,165 @@ +#!/bin/bash +# +# tellerstats.sh 3 +# generate graphs from the data +# +# Copyright 2001 The lm_sensors group +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +# generic tellerstats init BEGIN + +# get config information from /etc/tellerstats.conf or whereever we are pointed + +if [ -z "$TELLERSTATS_CONF" ] +then + TELLERSTATS_CONF=/etc/tellerstats.conf +fi + +export TELLERSTATS_CONF + +if [ ! -r $TELLERSTATS_CONF ] +then + echo "$0: Could not find config file $TELLERSTATS_CONF" + exit 1 +fi + +. $TELLERSTATS_CONF + +if [ ! -d $DBPATH ] +then + echo "$0: data directory $DBPATH does not exist" + exit 1 +fi + +if [ ! -d $SENSORPATH ] +then + echo "$0: sensor information directory $SENSORPATH does not exist." + exit 1 +fi + +if [ ! -d $HTMLROOT ] +then + echo "$0: The root of your webserver - $HTMLROOT - does not exist..bailing out" + exit 1 +fi + +if [ ! -d $HTMLPATH ] +then + echo "$0: The place where we keep HTML files and pictures - $HTMLPATH - does not exist..bailing out" + exit 1 +fi + +if [ ! -r $GNUPLOTSCRIPT_TMPL ] +then + echo "$0: The gnuplot script template $GNUPLOTSCRIPT_TMPL does not exist..bailing out" + exit 1 +fi + +export DBPATH SENSORPATH TEMPPATH HTMLROOT HTMLPATH GNUPLOTSCRIPT_TMPL + +if [ -n "$DEBUG" ] +then + echo "DBPATH = $DBPATH" + echo "SENSORPATH = $SENSORPATH" + echo "TEMPPATH = $TEMPPATH" + echo "HTMLROOT = $HTMLROOT" + echo "HTMLPATH = $HTMLPATH" + echo "GNUPLOTSCRIPT_TMPL = $GNUPLOTSCRIPT_TMPL" +fi + +# generic tellerstats init END + +if [ -z "$LINEWIDTH" ] +then + LINEWIDTH=5 +fi +export LINEWIDTH + +if [ -z "$PLOTFORMAT" ] +then + PLOTFORMAT=ps +fi +export PLOTFORMAT + +if [ -z "$PLOTTERMINAL" ] +then + PLOTTERMINAL="postscript eps enhanced color \"Helvetica\" 22" +fi +export PLOTTERMINAL + +if [ -n "$DEBUG" ] +then + echo "LINEWIDTH = $LINEWIDTH" + echo "PLOTFORMAT = $PLOTFORMAT" + echo "PLOTTERMINAL = $PLOTTERMINAL" +fi + +# Trim files to 48 hour window + +cd $DBPATH +files="`echo *`" + +for this in $files +do + tail $this -n576 > ${this}.tmp + mv ${this}.tmp $this +done + +############################################### + +rm -rf $TEMPPATH +mkdir -p $TEMPPATH + +cd $TEMPPATH + +# Update primary plots +GNUPLOTSCRIPT="$TEMPPATH/gnuplotscript" +cat $GNUPLOTSCRIPT_TMPL | perl -p -e's/\$(\w+)/$ENV{$1}/g' > $GNUPLOTSCRIPT +gnuplot < $GNUPLOTSCRIPT +rm $GNUPLOTSCRIPT + +files="`echo *`" + +CONVERT_OPTS_A="-interlace none -scale 320x240 -quality 100" +CONVERT_OPTS_B="-interlace none -scale 800x600 -quality 100" + +for this in $files +do + prefix=`echo $this|perl -p -e's/\.\w+$//'` + convert $CONVERT_OPTS_A $TEMPPATH/$this $HTMLPATH/${prefix}.png + convert $CONVERT_OPTS_B $TEMPPATH/$this $HTMLPATH/${prefix}B.png + touch $HTMLPATH/${prefix}.png $HTMLPATH/${prefix}B.png +done + +# Update timestamp + +touch $HTMLPATH/index.shtml + +# if this was called as a cgi script, it should redirect to the index.shtml file +if [ -n "$REMOTE_HOST" ] +then + REL_HTML=${HTMLPATH#$HTMLROOT} + echo "Location: $REL_HTML/index.shtml" + echo +fi + +if [ -z "$DEBUG" ] +then + rm -rf $TEMPPATH +fi + +exit 0