| 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 (C) 2001 Philip Edelbrock |
| 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., 51 Franklin Street, Fifth Floor, Boston, |
| 24 |
# MA 02110-1301 USA. |
| 25 |
# |
| 26 |
|
| 27 |
# generic tellerstats init BEGIN |
| 28 |
|
| 29 |
# get config information from /etc/tellerstats.conf or wherever we are pointed |
| 30 |
|
| 31 |
if [ -z "$TELLERSTATS_CONF" ] |
| 32 |
then |
| 33 |
TELLERSTATS_CONF=/etc/tellerstats.conf |
| 34 |
fi |
| 35 |
|
| 36 |
export TELLERSTATS_CONF |
| 37 |
|
| 38 |
if [ ! -r $TELLERSTATS_CONF ] |
| 39 |
then |
| 40 |
echo "$0: Could not find config file $TELLERSTATS_CONF" |
| 41 |
exit 1 |
| 42 |
fi |
| 43 |
|
| 44 |
. $TELLERSTATS_CONF |
| 45 |
|
| 46 |
if [ ! -d $DBPATH ] |
| 47 |
then |
| 48 |
echo "$0: data directory $DBPATH does not exist" |
| 49 |
exit 1 |
| 50 |
fi |
| 51 |
|
| 52 |
if [ ! -d $SENSORPATH ] |
| 53 |
then |
| 54 |
echo "$0: sensor information directory $SENSORPATH does not exist." |
| 55 |
exit 1 |
| 56 |
fi |
| 57 |
|
| 58 |
if [ ! -d $HTMLROOT ] |
| 59 |
then |
| 60 |
echo "$0: The root of your webserver - $HTMLROOT - does not exist..bailing out" |
| 61 |
exit 1 |
| 62 |
fi |
| 63 |
|
| 64 |
if [ ! -d $HTMLPATH ] |
| 65 |
then |
| 66 |
echo "$0: The place where we keep HTML files and pictures - $HTMLPATH - does not exist..bailing out" |
| 67 |
exit 1 |
| 68 |
fi |
| 69 |
|
| 70 |
if [ ! -r $GNUPLOTSCRIPT_TMPL ] |
| 71 |
then |
| 72 |
echo "$0: The gnuplot script template $GNUPLOTSCRIPT_TMPL does not exist..bailing out" |
| 73 |
exit 1 |
| 74 |
fi |
| 75 |
|
| 76 |
export DBPATH SENSORPATH TEMPPATH HTMLROOT HTMLPATH GNUPLOTSCRIPT_TMPL |
| 77 |
|
| 78 |
if [ -n "$DEBUG" ] |
| 79 |
then |
| 80 |
echo "DBPATH = $DBPATH" |
| 81 |
echo "SENSORPATH = $SENSORPATH" |
| 82 |
echo "TEMPPATH = $TEMPPATH" |
| 83 |
echo "HTMLROOT = $HTMLROOT" |
| 84 |
echo "HTMLPATH = $HTMLPATH" |
| 85 |
echo "GNUPLOTSCRIPT_TMPL = $GNUPLOTSCRIPT_TMPL" |
| 86 |
fi |
| 87 |
|
| 88 |
# generic tellerstats init END |
| 89 |
|
| 90 |
# From /etc/sensors.conf for the W83781D: |
| 91 |
# |
| 92 |
# compute in3 ((6.8/10)+1)*@ , @/((6.8/10)+1) |
| 93 |
# compute in4 ((28/10)+1)*@ , @/((28/10)+1) |
| 94 |
# compute in5 -(210/60.4)*@ , -@/(210/60.4) |
| 95 |
# compute in6 -(90.9/60.4)*@ , -@/(90.9/60.4) |
| 96 |
# |
| 97 |
|
| 98 |
#date=yyyyMMddHHmmss, the same format gnuplot expects for the x-axis |
| 99 |
DATE=`date +%Y%m%d%H%M%S` |
| 100 |
|
| 101 |
T=`cat $SENSORPATH/in0 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 102 |
echo $DATE $T >> $DBPATH/cpu1V |
| 103 |
|
| 104 |
T=`cat $SENSORPATH/in1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 105 |
echo $DATE $T >> $DBPATH/cpu2V |
| 106 |
|
| 107 |
T=`cat $SENSORPATH/in2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 108 |
echo $DATE $T >> $DBPATH/ThreeVOLT |
| 109 |
|
| 110 |
T=`cat $SENSORPATH/in3 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 111 |
T=`echo $T \* 1.68 | bc` |
| 112 |
echo $DATE $T >> $DBPATH/FiveVOLT |
| 113 |
|
| 114 |
T=`cat $SENSORPATH/in4 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 115 |
T=`echo $T \* 3.8 | bc` |
| 116 |
echo $DATE $T >> $DBPATH/TwelveVOLT |
| 117 |
|
| 118 |
T=`cat $SENSORPATH/in5 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 119 |
T=`echo $T \* -3.477 | bc` |
| 120 |
echo $DATE $T >> $DBPATH/NegTwelveVOLT |
| 121 |
|
| 122 |
T=`cat $SENSORPATH/in6 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 123 |
T=`echo $T \* -1.505 | bc` |
| 124 |
echo $DATE $T >> $DBPATH/NegFiveVOLT |
| 125 |
|
| 126 |
T=`cat $SENSORPATH/temp1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 127 |
echo $DATE $T >> $DBPATH/mb_temp |
| 128 |
|
| 129 |
T=`cat $SENSORPATH/temp2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 130 |
echo $DATE $T >> $DBPATH/cpu_temp |
| 131 |
|
| 132 |
T=`cat $SENSORPATH/fan1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 133 |
echo $DATE $T >> $DBPATH/fanone |
| 134 |
|
| 135 |
T=`cat $SENSORPATH/fan2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 136 |
echo $DATE $T >> $DBPATH/fantwo |
| 137 |
|
| 138 |
T=`cat $SENSORPATH/fan3 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
| 139 |
echo $DATE $T >> $DBPATH/fanthree |
| 140 |
|
| 141 |
T=`cat /proc/loadavg | perl -p -e 's/^([^ ]+) .+$/$1/'` |
| 142 |
echo $DATE $T >> $DBPATH/load |
| 143 |
|
| 144 |
exit 0 |