root/lm-sensors/trunk/prog/tellerstats/gather.sh @ 1051

Revision 1051, 3.9 KB (checked in by mds, 13 years ago)

the famous "tellerstats" package of Phil's with updates

from me and Hans Ecke <hans@…>.
Intent is a simple package which can be customized, configured,
and installed easily.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/bash
2#
3#    gather.sh
4#       gather the data.
5#       run from cron every 5 minutes.
6#       Don't run manually as root or else files in data/ will get
7#       root ownership then your (non-root) cron daemon won't work
8#
9#    Copyright 2001 The lm_sensors group
10#
11#    This program is free software; you can redistribute it and/or modify
12#    it under the terms of the GNU General Public License as published by
13#    the Free Software Foundation; either version 2 of the License, or
14#    (at your option) any later version.
15#
16#    This program is distributed in the hope that it will be useful,
17#    but WITHOUT ANY WARRANTY; without even the implied warranty of
18#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19#    GNU General Public License for more details.
20#
21#    You should have received a copy of the GNU General Public License
22#    along with this program; if not, write to the Free Software
23#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24#
25
26# generic tellerstats init BEGIN
27
28# get config information from /etc/tellerstats.conf or whereever we are pointed
29
30if [ -z "$TELLERSTATS_CONF" ]
31then
32   TELLERSTATS_CONF=/etc/tellerstats.conf
33fi   
34
35export TELLERSTATS_CONF
36
37if [ ! -r $TELLERSTATS_CONF ]
38then
39   echo "$0: Could not find config file $TELLERSTATS_CONF"
40   exit 1
41fi   
42
43. $TELLERSTATS_CONF
44
45if [ ! -d $DBPATH ]
46then
47   echo "$0: data directory $DBPATH does not exist"
48   exit 1
49fi
50
51if [ ! -d $SENSORPATH ]
52then
53   echo "$0: sensor information directory $SENSORPATH does not exist."
54   exit 1
55fi
56
57if [ ! -d $HTMLROOT ]
58then
59   echo "$0: The root of your webserver - $HTMLROOT - does not exist..bailing out"
60   exit 1
61fi
62
63if [ ! -d $HTMLPATH ]
64then
65   echo "$0: The place where we keep HTML files and pictures - $HTMLPATH - does not exist..bailing out"
66   exit 1
67fi
68
69if [ ! -r $GNUPLOTSCRIPT_TMPL ]
70then
71   echo "$0: The gnuplot script template $GNUPLOTSCRIPT_TMPL does not exist..bailing out"
72   exit 1
73fi
74
75export DBPATH SENSORPATH TEMPPATH HTMLROOT HTMLPATH GNUPLOTSCRIPT_TMPL
76
77if [ -n "$DEBUG" ]
78then
79   echo "DBPATH = $DBPATH"
80   echo "SENSORPATH = $SENSORPATH"
81   echo "TEMPPATH = $TEMPPATH"
82   echo "HTMLROOT = $HTMLROOT"
83   echo "HTMLPATH = $HTMLPATH"
84   echo "GNUPLOTSCRIPT_TMPL = $GNUPLOTSCRIPT_TMPL"
85fi
86
87# generic tellerstats init END
88
89# From /etc/sensors.conf for the W83781D:
90#
91#    compute in3 ((6.8/10)+1)*@ ,  @/((6.8/10)+1)
92#    compute in4 ((28/10)+1)*@  ,  @/((28/10)+1)
93#    compute in5 -(210/60.4)*@  ,  -@/(210/60.4)
94#    compute in6 -(90.9/60.4)*@ ,  -@/(90.9/60.4)
95#
96
97#date=yyyyMMddHHmmss, the same format gnuplot expects for the x-axis
98DATE=`date +%Y%m%d%H%M%S`
99
100T=`cat $SENSORPATH/in0   | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
101echo $DATE $T >> $DBPATH/cpu1V
102
103T=`cat $SENSORPATH/in1   | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
104echo $DATE $T >> $DBPATH/cpu2V
105
106T=`cat $SENSORPATH/in2   | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
107echo $DATE $T >> $DBPATH/ThreeVOLT
108
109T=`cat $SENSORPATH/in3   | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
110T=`echo $T \* 1.68 | bc`
111echo $DATE $T >> $DBPATH/FiveVOLT
112
113T=`cat $SENSORPATH/in4   | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
114T=`echo $T \* 3.8 | bc`
115echo $DATE $T >> $DBPATH/TwelveVOLT
116
117T=`cat $SENSORPATH/in5   | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
118T=`echo $T \* -3.477 | bc`
119echo $DATE $T >> $DBPATH/NegTwelveVOLT
120
121T=`cat $SENSORPATH/in6   | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
122T=`echo $T \* -1.505 | bc`
123echo $DATE $T >> $DBPATH/NegFiveVOLT
124
125T=`cat $SENSORPATH/temp1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
126echo $DATE $T >> $DBPATH/mb_temp
127
128T=`cat $SENSORPATH/temp2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
129echo $DATE $T >> $DBPATH/cpu_temp
130
131T=`cat $SENSORPATH/fan1  | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
132echo $DATE $T >> $DBPATH/fanone
133
134T=`cat $SENSORPATH/fan2  | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
135echo $DATE $T >> $DBPATH/fantwo
136
137T=`cat $SENSORPATH/fan3  | perl -p -e 's/^.+ ([^ ]+)$/$1/'`
138echo $DATE $T >> $DBPATH/fanthree
139
140T=`cat /proc/loadavg     | perl -p -e 's/^([^ ]+) .+$/$1/'`
141echo $DATE $T >> $DBPATH/load
142
143exit 0
Note: See TracBrowser for help on using the browser.