diff --git a/prog/rrd/Makefile b/prog/rrd/Makefile new file mode 100644 index 00000000..8094201a --- /dev/null +++ b/prog/rrd/Makefile @@ -0,0 +1,53 @@ +# +# Edit the following for your setup +# +USER=httpd +#CRONTAB=/var/spool/cron/tabs/$(USER) +RRDPATH=/usr/local/rrdtool/bin +BINPATH=/usr/local/bin +RRDDIR=/var/lib/sensors-rrd +APACHE=/usr/local/apache/htdocs +APACHDIR=$(APACHE)/senspix +SENSDEV=w83781d-isa-0290 +MACH=`uname -n` +# +# Everything below here should be fine +# +RRDB=$(RRDDIR)/sensors.rrd +SENSDIR=/proc/sys/dev/sensors/$(SENSDEV) + +all: sens_day.cgi sens_week.cgi $(SENSDIR) + +%.cgi : %.in Makefile + sed -e "s#%%RRDPATH%%#$(RRDPATH)#g;s#%%APACHDIR%%#$(APACHDIR)#g;s#%%RRDDIR%%#$(RRDDIR)#g;s#%%MACH%%#$(MACH)#g" $< > $@ + +$(RRDDIR) : + install -d -o $(USER) $(RRDDIR) + +$(RRDB) : $(RRDDIR) + ./sens_create_rrd $(RRDB) + chown $(USER) $(RRDB) + +$(SENSDIR) : + $(error error - sensor $(SENSDEV) not installed - check SENSDEV definition in Makefile) + +$(CRONTAB) : + $(error error - crontab for user $(USER) not present - check CRONTAB definition in Makefile) + +$(APACHE) : + $(error error - Web server directory $(APACHE) not present - check APACHE definition in Makefile) + +$(APACHDIR)/pix : $(APACHE) + install -d -o $(USER) -m 777 $(APACHDIR)/pix + +install: all $(RRDB) $(SENSDIR) $(CRONTAB) $(APACHDIR)/pix + install -o root -g root -m 755 sens_update_rrd $(BINPATH) + install -o root -g root -m 755 sens_week.cgi $(APACHDIR) + install -o root -g root -m 755 sens_day.cgi $(APACHDIR) +# grep sens_update_rrd $(CRONTAB) > /dev/null 2>&1 || echo '*/5 * * * * /usr/local/bin/sens_update_rrd' $(RRDB) $(SENSDEV) >> $(CRONTAB) + @echo + @echo Note!!! You must manually install the following line in the crontab for user $(USER): + @echo ' */5 * * * * ' /usr/local/bin/sens_update_rrd $(RRDB) $(SENSDEV) + +clean: + rm -f sens_day.cgi sens_week.cgi diff --git a/prog/rrd/README b/prog/rrd/README new file mode 100644 index 00000000..54038810 --- /dev/null +++ b/prog/rrd/README @@ -0,0 +1,102 @@ +OVERVIEW +-------- +This directory contains shell and cgi scripts which maintain a +database of sensor data and generate web pages containing +graphs of sensor data. + +The RRD (Round Robin Database) package is required. +Get this package from + http://ee-staff.ethz.ch/~oetiker/webtools/rrdtool + +A web server with CGI support is required. + +We have provided these scripts because the RRD package, +while simple to build and install, is rather difficult +to configure to store and display data. + +RRD, together with lm_sensors and these scripts, provide the +following advantages: + - True round-robin (constant-size) database + - On-the-fly graph generation with CGI scripts + - Multiple data views using single database + - Automatic time stamping, interpolation of missing data, + large data dropouts (during machine downtime) correctly + shown on graphs + +If you are looking for something less sophisticated, try +tellerstats (see link in ../../doc/useful_addresses.html). + +The scripts read /proc entries and do not use libsensors. +Therefore the scale factors in /etc/sensors.conf are not used, +and you may have to change the scale factors in the cgi scripts. + + +WARNING! +-------- +The 'make install' script tries to make it easy for you but +makes a lot of assumptions about your cron and web setup. +If you have any concerns, do NOT run make install, and +install the items by hand instead. + + +INSTALLATION INSTRUCTIONS +------------------------- + + - Make and install lm_sensors. Get it working (run 'sensors') + before you try this! + - Get RRD, make and install it + - cd /usr/local; ln -s rrdtool-x.y.z rrdtool + - cd back to here + - Edit the top of the Makefile. Do NOT skip this step. + The defaults will probably not work for you. + Here are the defaults: + Cron user + USER=httpd + Path to rrdtool and rrdcgi + RRDPATH=/usr/local/rrdtool/bin + Place to install sens_update_rrd script + BINPATH=/usr/local/bin + Place to store the database + RRDDIR=/var/lib/sensors-rrd + Place to put the cgi script and the graphs + APACHE=/usr/local/apache/htdocs + APACHDIR=$(APACHE)/senspix + The sensor device in your system + (isa recommended over i2c if both are available) + SENSDEV=w83781d-isa-0290 + - make + - (as root) make install, which does the following. + If you don't want it to do this, install by hand!!! + Creates a database + Installs the data gathering script + Installs the CGI script in your web server + - Manually add the following line to the crontab for + the user specified above, which will call the data gathering + script every 5 minutes (adjust paths as necessary) + */5 * * * * /usr/local/bin/sens_update_rrd /var/lib/sensors-rrd/sensors.rrd w83781d-isa-0290 + - Load http://localhost/senspix/sens_day.cgi in your web browser + to test + + +PROBLEMS +-------- + RRD problems: see the RRD documentation + lm_sensors problems: see the lm_sensors FAQ and other documentation, + enter a support ticket on our + web page http://www.lm-sensors.nu or email us at + sensors@stimpy.netroedge.com + Cron problems: check the cron logs, maybe your cron format + is different or you need to signal the cron daemon? + Unused sensors: remove appropriate sections from sens_day.cgi.in + and sens_week.cgi.in and remake and install. + Sensor scaling factors incorrect (in3-in6): Edit lines in + sens_day.cgi.in and sens_week.cgi.in that start + 'CDEF:' to change the scale factor. + CGI problems: check the apache logs. If CGI is not enabled for + the directory add a .htaccess file to the directory + including the line + Options ExecCGI + Problems with these scripts: + enter a support ticket on our + web page http://www.lm-sensors.nu or email us at + sensors@stimpy.netroedge.com diff --git a/prog/rrd/sens_create_rrd b/prog/rrd/sens_create_rrd new file mode 100755 index 00000000..535da176 --- /dev/null +++ b/prog/rrd/sens_create_rrd @@ -0,0 +1,58 @@ +# +# sens_create_rrd - +# Create a sensors rrd database of 14 sensor readings +# at 5 minute intervals for 1 week. +# +# Copyright 2001 Mark D. Studebaker +# +# 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. +# +RRDPATH=/usr/local/rrdtool/bin +RRDB=$1 +#Heartbeat 15 minutes +HB=900 +#Rows 12 * 24 * 7 = 1 week of every 5 minutes +RW=2016 + +if [ $# -ne 1 ] +then + echo usage: $0 database.rrd + exit 1 +fi + +DIR=`dirname $1` +if [ ! -w $DIR ] +then + echo $0: directory $DIR not present or not writable + exit 1 +fi + +$RRDPATH/rrdtool create $RRDB --step 300 \ + DS:fan1:GAUGE:${HB}:U:U \ + DS:fan2:GAUGE:${HB}:U:U \ + DS:fan3:GAUGE:${HB}:U:U \ + DS:temp1:GAUGE:${HB}:U:U \ + DS:temp2:GAUGE:${HB}:U:U \ + DS:temp3:GAUGE:${HB}:U:U \ + DS:in0:GAUGE:${HB}:U:U \ + DS:in1:GAUGE:${HB}:U:U \ + DS:in2:GAUGE:${HB}:U:U \ + DS:in3:GAUGE:${HB}:U:U \ + DS:in4:GAUGE:${HB}:U:U \ + DS:in5:GAUGE:${HB}:U:U \ + DS:in6:GAUGE:${HB}:U:U \ + DS:loadavg:GAUGE:${HB}:U:U \ + RRA:AVERAGE:0.5:1:$RW + diff --git a/prog/rrd/sens_day.in b/prog/rrd/sens_day.in new file mode 100644 index 00000000..efd8ca86 --- /dev/null +++ b/prog/rrd/sens_day.in @@ -0,0 +1,230 @@ +#!%%RRDPATH%%/rrdcgi + + + +One Day Hardware Statistics for %%MACH%% + + + +

ONE DAY VIEW

+One Week View + +

TEMPERATURES

+ + +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Temperature (degrees C)" + -t "Motherboard temperature" + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 1:5 + DEF:temp=%%RRDDIR%%/sensors.rrd:temp1:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Temperature (degrees C)" + -t "CPU 1 temperature" + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 1:5 + DEF:temp=%%RRDDIR%%/sensors.rrd:temp2:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Temperature (degrees C)" + -t "CPU 2 temperature" + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 1:5 + DEF:temp=%%RRDDIR%%/sensors.rrd:temp3:AVERAGE + LINE2:temp#FF00FF> +

+ +

FANS

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Fan speed (RPM)" + -t "Fan 1 speed" + -u 5000 + --units-exponent 0 + --alt-autoscale + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + DEF:temp=%%RRDDIR%%/sensors.rrd:fan1:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Fan speed (RPM)" + -t "Fan 2 speed" + -u 5000 + --units-exponent 0 + --alt-autoscale + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + DEF:temp=%%RRDDIR%%/sensors.rrd:fan2:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Fan speed (RPM)" + -t "Fan 3 speed" + -u 5000 + --units-exponent 0 + --alt-autoscale + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + DEF:temp=%%RRDDIR%%/sensors.rrd:fan3:AVERAGE + LINE2:temp#FF00FF> +

+ +

POWER SUPPLIES

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Volts" + -t "Core 1 Voltage" + -l 1 -u 3 --rigid + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 0.2:1 + DEF:temp=%%RRDDIR%%/sensors.rrd:in0:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Volts" + -t "Core 2 Voltage" + -l 1 -u 3 --rigid + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 0.2:1 + DEF:temp=%%RRDDIR%%/sensors.rrd:in1:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Volts" + -t "+3.3 Volt Supply" + -l 2 -u 4 --rigid + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 0.2:1 + DEF:temp=%%RRDDIR%%/sensors.rrd:in2:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Volts" + -t "+5 Volt Supply" + -l 4 -u 6 --rigid + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 0.2:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in3:AVERAGE + CDEF:temp=1.68,x,* + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Volts" + -t "+12 Volt Supply" + -l 10 -u 14 + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 1:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in4:AVERAGE + CDEF:temp=3.8,x,* + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Volts" + -t "-12 Volt Supply" + -l -14 -u -10 + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 1:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in5:AVERAGE + CDEF:temp=-3.48,x,* + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1days + -v "Volts" + -t "-5 Volt Supply" + -l -6 -u -4 --rigid + -x HOUR:1:HOUR:3:HOUR:3:3600:'%b %d %H:%I' + -y 0.2:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in6:AVERAGE + CDEF:temp=-1.5,x,* + LINE2:temp#FF00FF> +

+ +This page generated with data and scripts from +The lm_sensors drivers; +the data are stored in a Round Robin Database and +the graphs are generated by + +RRD. + + + + + + + diff --git a/prog/rrd/sens_update_rrd b/prog/rrd/sens_update_rrd new file mode 100755 index 00000000..a6e60a20 --- /dev/null +++ b/prog/rrd/sens_update_rrd @@ -0,0 +1,95 @@ +# +# sens_update_rrd - +# Update a sensors rrd database. +# Sample usage: +# sens_update_rrd /var/lib/database.rrd w83781d-isa-0290 +# Sample cron entry: +# */5 * * * * /usr/local/bin/sens_update_rrd /var/lib/sensors-rrd/sensors.rrd w83781d-isa-0290 +# +################################################################# +# +# Copyright 2001 Mark D. Studebaker +# +# 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. +# +################################################################# +# +if [ $# -ne 2 ] +then + echo "usage: $0 database.rrd sensor" + echo " sensor example: w83781d-isa-0290" + exit 1 +fi +# +RRDPATH=/usr/local/rrdtool/bin +RRDB=$1 +# +SENSDIR=/proc/sys/dev/sensors +# +SENSDEV=$2 +SENS=$SENSDIR/$SENSDEV +if [ ! -r $SENS ] +then + exit 1 +fi + +STRING=N +# +# Get the second value from these sensor files +# +SENSORS="fan1 fan2 fan3" +for i in $SENSORS +do + V="`cat $SENSDIR/$SENSDEV/$i 2> /dev/null`" + if [ $? -ne 0 ] + then + STRING="${STRING}:U" + else + V="`echo $V | cut -d ' ' -f 2`" + STRING="${STRING}:${V}" + fi +done +# +# Get the third value from these sensor files +# +SENSORS="temp1 temp2 temp3 in0 in1 in2 in3 in4 in5 in6" +for i in $SENSORS +do + V="`cat $SENSDIR/$SENSDEV/$i 2> /dev/null`" + if [ $? -ne 0 ] + then + STRING="${STRING}:U" + else + V="`echo $V | cut -d ' ' -f 3`" + STRING="${STRING}:${V}" + fi +done +# +# Get the first value from these /proc files +# +SENSORS="loadavg" +for i in $SENSORS +do + V="`cat /proc/$i 2> /dev/null`" + if [ $? -ne 0 ] + then + STRING="${STRING}:U" + else + V="`echo $V | cut -d ' ' -f 1`" + STRING="${STRING}:${V}" + fi +done + +$RRDPATH/rrdtool update $RRDB $STRING diff --git a/prog/rrd/sens_week.in b/prog/rrd/sens_week.in new file mode 100644 index 00000000..d03800b1 --- /dev/null +++ b/prog/rrd/sens_week.in @@ -0,0 +1,230 @@ +#!%%RRDPATH%%/rrdcgi + + + +One Week Hardware Statistics for %%MACH%% + + + +

ONE WEEK VIEW

+One Day View + +

TEMPERATURES

+ + +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Temperature (degrees C)" + -t "Motherboard temperature" + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 1:5 + DEF:temp=%%RRDDIR%%/sensors.rrd:temp1:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Temperature (degrees C)" + -t "CPU 1 temperature" + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 1:5 + DEF:temp=%%RRDDIR%%/sensors.rrd:temp2:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Temperature (degrees C)" + -t "CPU 2 temperature" + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 1:5 + DEF:temp=%%RRDDIR%%/sensors.rrd:temp3:AVERAGE + LINE2:temp#FF00FF> +

+ +

FANS

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Fan speed (RPM)" + -t "Fan 1 speed" + -u 5000 + --units-exponent 0 + --alt-autoscale + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + DEF:temp=%%RRDDIR%%/sensors.rrd:fan1:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Fan speed (RPM)" + -t "Fan 2 speed" + -u 5000 + --units-exponent 0 + --alt-autoscale + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + DEF:temp=%%RRDDIR%%/sensors.rrd:fan2:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Fan speed (RPM)" + -t "Fan 3 speed" + -u 5000 + --units-exponent 0 + --alt-autoscale + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + DEF:temp=%%RRDDIR%%/sensors.rrd:fan3:AVERAGE + LINE2:temp#FF00FF> +

+ +

POWER SUPPLIES

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Volts" + -t "Core 1 Voltage" + -l 1 -u 3 --rigid + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 0.2:1 + DEF:temp=%%RRDDIR%%/sensors.rrd:in0:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Volts" + -t "Core 2 Voltage" + -l 1 -u 3 --rigid + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 0.2:1 + DEF:temp=%%RRDDIR%%/sensors.rrd:in1:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Volts" + -t "+3.3 Volt Supply" + -l 2 -u 4 --rigid + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 0.2:1 + DEF:temp=%%RRDDIR%%/sensors.rrd:in2:AVERAGE + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Volts" + -t "+5 Volt Supply" + -l 4 -u 6 --rigid + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 0.2:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in3:AVERAGE + CDEF:temp=1.68,x,* + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Volts" + -t "+12 Volt Supply" + -l 10 -u 14 + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 1:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in4:AVERAGE + CDEF:temp=3.8,x,* + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Volts" + -t "-12 Volt Supply" + -l -14 -u -10 + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 1:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in5:AVERAGE + CDEF:temp=-3.48,x,* + LINE2:temp#FF00FF> +

+ +

' + -a PNG + -h 200 -w 800 + --lazy + -s -1week + -v "Volts" + -t "-5 Volt Supply" + -l -6 -u -4 --rigid + -x HOUR:6:DAY:1:DAY:1:86400:'%b %d %H:%I' + -y 0.2:1 + DEF:x=%%RRDDIR%%/sensors.rrd:in6:AVERAGE + CDEF:temp=-1.5,x,* + LINE2:temp#FF00FF> +

+ +This page generated with data and scripts from +The lm_sensors drivers; +the data are stored in a Round Robin Database and +the graphs are generated by + +RRD. + + + + + + +