root/lm-sensors/branches/lm-sensors-3.0.0/prog/rrd/sens_update_rrd @ 5163

Revision 5163, 2.3 KB (checked in by khali, 6 years ago)

Patch from Aurelien Jarno:

I have just noticed that the FSF address is the old one in all files
except COPYING. Please find a patch below to fix that.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/sh
2#
3#    sens_update_rrd -
4#       Update a sensors rrd database.
5#       Sample usage:
6#               sens_update_rrd /var/lib/database.rrd hwmon0
7#       Sample cron entry:
8#               */5 * * * * /usr/local/bin/sens_update_rrd /var/lib/sensors-rrd/sensors.rrd hwmon0
9#
10#################################################################
11#
12#    Copyright 2001,2005 Mark D. Studebaker <mdsxyz123@yahoo.com>
13#
14#    This program is free software; you can redistribute it and/or modify
15#    it under the terms of the GNU General Public License as published by
16#    the Free Software Foundation; either version 2 of the License, or
17#    (at your option) any later version.
18#
19#    This program is distributed in the hope that it will be useful,
20#    but WITHOUT ANY WARRANTY; without even the implied warranty of
21#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22#    GNU General Public License for more details.
23#
24#    You should have received a copy of the GNU General Public License
25#    along with this program; if not, write to the Free Software
26#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27#    MA 02110-1301 USA.
28#
29#################################################################
30#
31if [ $# -lt 1 -o $# -gt 2 ]
32then
33        echo "usage: $0 database.rrd [hwmonN]"
34        exit 1
35elif [ $# -eq 2 ]
36then
37        HWMON=$2
38else
39        HWMON=hwmon0
40fi
41#
42RRDPATH=/usr/bin
43RRDB=$1
44
45SENSDIR=/sys/class/hwmon
46SENS=$SENSDIR/$HWMON/device
47
48if [ ! -d $SENS ]
49then
50        echo "No sensors found in: $SENS"
51        echo "(modprobe sensor modules?)"
52        exit 1
53fi
54
55STRING=N
56#
57# Get the value from these sensor files (/sys)
58#
59SENSORS="fan1 fan2 fan3"
60for i in $SENSORS
61do
62        V="`cat $SENS/${i}_input 2> /dev/null`"
63        if [ $? -ne 0 ]
64        then
65                STRING="${STRING}:U"
66        else
67                STRING="${STRING}:${V}"
68        fi
69done
70#
71# Get the value from these sensor files (/sys) and divide by 1000
72#
73SENSORS="temp1 temp2 temp3 in0 in1 in2 in3 in4 in5 in6"
74for i in $SENSORS
75do
76        V="`cat $SENS/${i}_input 2> /dev/null`"
77        if [ $? -ne 0 ]
78        then
79                STRING="${STRING}:U"
80        else
81                V=`echo "3k0 ${V/-/_} 1000/p"|dc`
82                STRING="${STRING}:${V}"
83        fi
84done
85
86#
87# Get the first value from these /proc files
88#
89SENSORS="loadavg"
90for i in $SENSORS
91do
92        V="`cat /proc/$i 2> /dev/null`"
93        if [ $? -ne 0 ]
94        then
95                STRING="${STRING}:U"
96        else
97                V="`echo $V | cut -d ' ' -f 1`"
98                STRING="${STRING}:${V}"
99        fi
100done
101
102$RRDPATH/rrdtool update $RRDB $STRING
Note: See TracBrowser for help on using the browser.