mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-24 12:04:33 +00:00
* More hwmon class changes * Look for rrd in /usr/bin by default * Add missing shell declarations * Update URI git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4372 7894878c-1315-0410-8ee3-d5d059ff63e0
102 lines
2.3 KiB
Bash
Executable File
102 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# sens_update_rrd -
|
|
# Update a sensors rrd database.
|
|
# Sample usage:
|
|
# sens_update_rrd /var/lib/database.rrd hwmon0
|
|
# Sample cron entry:
|
|
# */5 * * * * /usr/local/bin/sens_update_rrd /var/lib/sensors-rrd/sensors.rrd hwmon0
|
|
#
|
|
#################################################################
|
|
#
|
|
# Copyright 2001,2005 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 [ $# -lt 1 -o $# -gt 2 ]
|
|
then
|
|
echo "usage: $0 database.rrd [hwmonN]"
|
|
exit 1
|
|
elif [ $# -eq 2 ]
|
|
then
|
|
HWMON=$2
|
|
else
|
|
HWMON=hwmon0
|
|
fi
|
|
#
|
|
RRDPATH=/usr/bin
|
|
RRDB=$1
|
|
|
|
SENSDIR=/sys/class/hwmon
|
|
SENS=$SENSDIR/$HWMON/device
|
|
|
|
if [ ! -d $SENS ]
|
|
then
|
|
echo "No sensors found in: $SENS"
|
|
echo "(modprobe sensor modules?)"
|
|
exit 1
|
|
fi
|
|
|
|
STRING=N
|
|
#
|
|
# Get the value from these sensor files (/sys)
|
|
#
|
|
SENSORS="fan1 fan2 fan3"
|
|
for i in $SENSORS
|
|
do
|
|
V="`cat $SENS/${i}_input 2> /dev/null`"
|
|
if [ $? -ne 0 ]
|
|
then
|
|
STRING="${STRING}:U"
|
|
else
|
|
STRING="${STRING}:${V}"
|
|
fi
|
|
done
|
|
#
|
|
# Get the value from these sensor files (/sys) and divide by 1000
|
|
#
|
|
SENSORS="temp1 temp2 temp3 in0 in1 in2 in3 in4 in5 in6"
|
|
for i in $SENSORS
|
|
do
|
|
V="`cat $SENS/${i}_input 2> /dev/null`"
|
|
if [ $? -ne 0 ]
|
|
then
|
|
STRING="${STRING}:U"
|
|
else
|
|
V=`echo "3k0 ${V/-/_} 1000/p"|dc`
|
|
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
|