| 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 | |
|---|
| 30 | if [ -z "$TELLERSTATS_CONF" ] |
|---|
| 31 | then |
|---|
| 32 | TELLERSTATS_CONF=/etc/tellerstats.conf |
|---|
| 33 | fi |
|---|
| 34 | |
|---|
| 35 | export TELLERSTATS_CONF |
|---|
| 36 | |
|---|
| 37 | if [ ! -r $TELLERSTATS_CONF ] |
|---|
| 38 | then |
|---|
| 39 | echo "$0: Could not find config file $TELLERSTATS_CONF" |
|---|
| 40 | exit 1 |
|---|
| 41 | fi |
|---|
| 42 | |
|---|
| 43 | . $TELLERSTATS_CONF |
|---|
| 44 | |
|---|
| 45 | if [ ! -d $DBPATH ] |
|---|
| 46 | then |
|---|
| 47 | echo "$0: data directory $DBPATH does not exist" |
|---|
| 48 | exit 1 |
|---|
| 49 | fi |
|---|
| 50 | |
|---|
| 51 | if [ ! -d $SENSORPATH ] |
|---|
| 52 | then |
|---|
| 53 | echo "$0: sensor information directory $SENSORPATH does not exist." |
|---|
| 54 | exit 1 |
|---|
| 55 | fi |
|---|
| 56 | |
|---|
| 57 | if [ ! -d $HTMLROOT ] |
|---|
| 58 | then |
|---|
| 59 | echo "$0: The root of your webserver - $HTMLROOT - does not exist..bailing out" |
|---|
| 60 | exit 1 |
|---|
| 61 | fi |
|---|
| 62 | |
|---|
| 63 | if [ ! -d $HTMLPATH ] |
|---|
| 64 | then |
|---|
| 65 | echo "$0: The place where we keep HTML files and pictures - $HTMLPATH - does not exist..bailing out" |
|---|
| 66 | exit 1 |
|---|
| 67 | fi |
|---|
| 68 | |
|---|
| 69 | if [ ! -r $GNUPLOTSCRIPT_TMPL ] |
|---|
| 70 | then |
|---|
| 71 | echo "$0: The gnuplot script template $GNUPLOTSCRIPT_TMPL does not exist..bailing out" |
|---|
| 72 | exit 1 |
|---|
| 73 | fi |
|---|
| 74 | |
|---|
| 75 | export DBPATH SENSORPATH TEMPPATH HTMLROOT HTMLPATH GNUPLOTSCRIPT_TMPL |
|---|
| 76 | |
|---|
| 77 | if [ -n "$DEBUG" ] |
|---|
| 78 | then |
|---|
| 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" |
|---|
| 85 | fi |
|---|
| 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 |
|---|
| 98 | DATE=`date +%Y%m%d%H%M%S` |
|---|
| 99 | |
|---|
| 100 | T=`cat $SENSORPATH/in0 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 101 | echo $DATE $T >> $DBPATH/cpu1V |
|---|
| 102 | |
|---|
| 103 | T=`cat $SENSORPATH/in1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 104 | echo $DATE $T >> $DBPATH/cpu2V |
|---|
| 105 | |
|---|
| 106 | T=`cat $SENSORPATH/in2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 107 | echo $DATE $T >> $DBPATH/ThreeVOLT |
|---|
| 108 | |
|---|
| 109 | T=`cat $SENSORPATH/in3 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 110 | T=`echo $T \* 1.68 | bc` |
|---|
| 111 | echo $DATE $T >> $DBPATH/FiveVOLT |
|---|
| 112 | |
|---|
| 113 | T=`cat $SENSORPATH/in4 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 114 | T=`echo $T \* 3.8 | bc` |
|---|
| 115 | echo $DATE $T >> $DBPATH/TwelveVOLT |
|---|
| 116 | |
|---|
| 117 | T=`cat $SENSORPATH/in5 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 118 | T=`echo $T \* -3.477 | bc` |
|---|
| 119 | echo $DATE $T >> $DBPATH/NegTwelveVOLT |
|---|
| 120 | |
|---|
| 121 | T=`cat $SENSORPATH/in6 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 122 | T=`echo $T \* -1.505 | bc` |
|---|
| 123 | echo $DATE $T >> $DBPATH/NegFiveVOLT |
|---|
| 124 | |
|---|
| 125 | T=`cat $SENSORPATH/temp1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 126 | echo $DATE $T >> $DBPATH/mb_temp |
|---|
| 127 | |
|---|
| 128 | T=`cat $SENSORPATH/temp2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 129 | echo $DATE $T >> $DBPATH/cpu_temp |
|---|
| 130 | |
|---|
| 131 | T=`cat $SENSORPATH/fan1 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 132 | echo $DATE $T >> $DBPATH/fanone |
|---|
| 133 | |
|---|
| 134 | T=`cat $SENSORPATH/fan2 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 135 | echo $DATE $T >> $DBPATH/fantwo |
|---|
| 136 | |
|---|
| 137 | T=`cat $SENSORPATH/fan3 | perl -p -e 's/^.+ ([^ ]+)$/$1/'` |
|---|
| 138 | echo $DATE $T >> $DBPATH/fanthree |
|---|
| 139 | |
|---|
| 140 | T=`cat /proc/loadavg | perl -p -e 's/^([^ ]+) .+$/$1/'` |
|---|
| 141 | echo $DATE $T >> $DBPATH/load |
|---|
| 142 | |
|---|
| 143 | exit 0 |
|---|