root/lm-sensors/branches/lm-sensors-3.0.0/prog/tellerstats/tellerstats.sh @ 5163

Revision 5163, 3.6 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/bash
2#
3#    tellerstats.sh                  3
4#       generate graphs from the data
5#
6#    Copyright (C) 2001  Philip Edelbrock
7#
8#    This program is free software; you can redistribute it and/or modify
9#    it under the terms of the GNU General Public License as published by
10#    the Free Software Foundation; either version 2 of the License, or
11#    (at your option) any later version.
12#
13#    This program is distributed in the hope that it will be useful,
14#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#    GNU General Public License for more details.
17#
18#    You should have received a copy of the GNU General Public License
19#    along with this program; if not, write to the Free Software
20#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21#    MA 02110-1301 USA.
22#
23
24# generic tellerstats init BEGIN
25
26# get config information from /etc/tellerstats.conf or whereever we are pointed
27
28if [ -z "$TELLERSTATS_CONF" ]
29then
30   TELLERSTATS_CONF=/etc/tellerstats.conf
31fi   
32
33export TELLERSTATS_CONF
34
35if [ ! -r $TELLERSTATS_CONF ]
36then
37   echo "$0: Could not find config file $TELLERSTATS_CONF"
38   exit 1
39fi   
40
41. $TELLERSTATS_CONF
42
43if [ ! -d $DBPATH ]
44then
45   echo "$0: data directory $DBPATH does not exist"
46   exit 1
47fi
48
49if [ ! -d $SENSORPATH ]
50then
51   echo "$0: sensor information directory $SENSORPATH does not exist."
52   exit 1
53fi
54
55if [ ! -d $HTMLROOT ]
56then
57   echo "$0: The root of your webserver - $HTMLROOT - does not exist..bailing out"
58   exit 1
59fi
60
61if [ ! -d $HTMLPATH ]
62then
63   echo "$0: The place where we keep HTML files and pictures - $HTMLPATH - does not exist..bailing out"
64   exit 1
65fi
66
67if [ ! -r $GNUPLOTSCRIPT_TMPL ]
68then
69   echo "$0: The gnuplot script template $GNUPLOTSCRIPT_TMPL does not exist..bailing out"
70   exit 1
71fi
72
73export DBPATH SENSORPATH TEMPPATH HTMLROOT HTMLPATH GNUPLOTSCRIPT_TMPL
74
75if [ -n "$DEBUG" ]
76then
77   echo "DBPATH = $DBPATH"
78   echo "SENSORPATH = $SENSORPATH"
79   echo "TEMPPATH = $TEMPPATH"
80   echo "HTMLROOT = $HTMLROOT"
81   echo "HTMLPATH = $HTMLPATH"
82   echo "GNUPLOTSCRIPT_TMPL = $GNUPLOTSCRIPT_TMPL"
83fi
84
85# generic tellerstats init END
86
87if [ -z "$LINEWIDTH" ]
88then
89   LINEWIDTH=5
90fi
91export LINEWIDTH   
92
93if [ -z "$PLOTFORMAT" ]
94then
95   PLOTFORMAT=ps
96fi
97export PLOTFORMAT
98
99if [ -z "$PLOTTERMINAL" ]
100then
101   PLOTTERMINAL="postscript eps enhanced color \"Helvetica\" 22"
102fi
103export PLOTTERMINAL
104
105if [ -n "$DEBUG" ]
106then
107   echo "LINEWIDTH = $LINEWIDTH"
108   echo "PLOTFORMAT = $PLOTFORMAT"
109   echo "PLOTTERMINAL = $PLOTTERMINAL"
110fi
111
112# Trim files to 48 hour window
113
114cd $DBPATH
115files="`echo *`"
116
117for this in $files
118do
119   tail $this -n576 > ${this}.tmp
120   mv ${this}.tmp $this
121done
122
123###############################################
124
125rm -rf $TEMPPATH
126mkdir -p $TEMPPATH
127
128cd $TEMPPATH
129
130# Update primary plots
131GNUPLOTSCRIPT="$TEMPPATH/gnuplotscript"
132cat $GNUPLOTSCRIPT_TMPL | perl -p -e's/\$(\w+)/$ENV{$1}/g' > $GNUPLOTSCRIPT
133gnuplot < $GNUPLOTSCRIPT
134rm $GNUPLOTSCRIPT
135
136files="`echo *`"
137
138CONVERT_OPTS_A="-interlace none -scale 320x240 -quality 100"
139CONVERT_OPTS_B="-interlace none -scale 800x600 -quality 100"
140
141for this in $files
142do
143   prefix=`echo $this|perl -p -e's/\.\w+$//'`
144   convert $CONVERT_OPTS_A $TEMPPATH/$this $HTMLPATH/${prefix}.png
145   convert $CONVERT_OPTS_B $TEMPPATH/$this $HTMLPATH/${prefix}B.png
146   touch $HTMLPATH/${prefix}.png $HTMLPATH/${prefix}B.png
147done
148
149# Update timestamp
150
151touch $HTMLPATH/index.shtml
152
153# if this was called as a cgi script, it should redirect to the index.shtml file
154if [ -n "$REMOTE_HOST" ]
155then
156   REL_HTML=${HTMLPATH#$HTMLROOT}
157   echo "Location: $REL_HTML/index.shtml"
158   echo
159fi
160
161if [ -z "$DEBUG" ]
162then
163   rm -rf $TEMPPATH
164fi   
165
166exit 0
Note: See TracBrowser for help on using the browser.