Files
lm-sensors/prog/rrd/sens_update_rrd
T
Mark D. Studebaker 006d4302b4 first cut at scripts to make the difficult RRD database package
usable to collect and display sensors data.
      Think 'tellerstats' on steroids.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1052 7894878c-1315-0410-8ee3-d5d059ff63e0
2001-03-31 04:53:45 +00:00

96 lines
2.2 KiB
Plaintext
Executable File

#
# 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 <mdsxyz123@yahoo.com>
#
# 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