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

Revision 1051, 3.6 KB (checked in by mds, 12 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#    tellerstats.sh                  3
4#       generate graphs from the data
5#
6#    Copyright 2001 The lm_sensors group
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21#
22
23# generic tellerstats init BEGIN
24
25# get config information from /etc/tellerstats.conf or whereever we are pointed
26
27if [ -z "$TELLERSTATS_CONF" ]
28then
29   TELLERSTATS_CONF=/etc/tellerstats.conf
30fi   
31
32export TELLERSTATS_CONF
33
34if [ ! -r $TELLERSTATS_CONF ]
35then
36   echo "$0: Could not find config file $TELLERSTATS_CONF"
37   exit 1
38fi   
39
40. $TELLERSTATS_CONF
41
42if [ ! -d $DBPATH ]
43then
44   echo "$0: data directory $DBPATH does not exist"
45   exit 1
46fi
47
48if [ ! -d $SENSORPATH ]
49then
50   echo "$0: sensor information directory $SENSORPATH does not exist."
51   exit 1
52fi
53
54if [ ! -d $HTMLROOT ]
55then
56   echo "$0: The root of your webserver - $HTMLROOT - does not exist..bailing out"
57   exit 1
58fi
59
60if [ ! -d $HTMLPATH ]
61then
62   echo "$0: The place where we keep HTML files and pictures - $HTMLPATH - does not exist..bailing out"
63   exit 1
64fi
65
66if [ ! -r $GNUPLOTSCRIPT_TMPL ]
67then
68   echo "$0: The gnuplot script template $GNUPLOTSCRIPT_TMPL does not exist..bailing out"
69   exit 1
70fi
71
72export DBPATH SENSORPATH TEMPPATH HTMLROOT HTMLPATH GNUPLOTSCRIPT_TMPL
73
74if [ -n "$DEBUG" ]
75then
76   echo "DBPATH = $DBPATH"
77   echo "SENSORPATH = $SENSORPATH"
78   echo "TEMPPATH = $TEMPPATH"
79   echo "HTMLROOT = $HTMLROOT"
80   echo "HTMLPATH = $HTMLPATH"
81   echo "GNUPLOTSCRIPT_TMPL = $GNUPLOTSCRIPT_TMPL"
82fi
83
84# generic tellerstats init END
85
86if [ -z "$LINEWIDTH" ]
87then
88   LINEWIDTH=5
89fi
90export LINEWIDTH   
91
92if [ -z "$PLOTFORMAT" ]
93then
94   PLOTFORMAT=ps
95fi
96export PLOTFORMAT
97
98if [ -z "$PLOTTERMINAL" ]
99then
100   PLOTTERMINAL="postscript eps enhanced color \"Helvetica\" 22"
101fi
102export PLOTTERMINAL
103
104if [ -n "$DEBUG" ]
105then
106   echo "LINEWIDTH = $LINEWIDTH"
107   echo "PLOTFORMAT = $PLOTFORMAT"
108   echo "PLOTTERMINAL = $PLOTTERMINAL"
109fi
110
111# Trim files to 48 hour window
112
113cd $DBPATH
114files="`echo *`"
115
116for this in $files
117do
118   tail $this -n576 > ${this}.tmp
119   mv ${this}.tmp $this
120done
121
122###############################################
123
124rm -rf $TEMPPATH
125mkdir -p $TEMPPATH
126
127cd $TEMPPATH
128
129# Update primary plots
130GNUPLOTSCRIPT="$TEMPPATH/gnuplotscript"
131cat $GNUPLOTSCRIPT_TMPL | perl -p -e's/\$(\w+)/$ENV{$1}/g' > $GNUPLOTSCRIPT
132gnuplot < $GNUPLOTSCRIPT
133rm $GNUPLOTSCRIPT
134
135files="`echo *`"
136
137CONVERT_OPTS_A="-interlace none -scale 320x240 -quality 100"
138CONVERT_OPTS_B="-interlace none -scale 800x600 -quality 100"
139
140for this in $files
141do
142   prefix=`echo $this|perl -p -e's/\.\w+$//'`
143   convert $CONVERT_OPTS_A $TEMPPATH/$this $HTMLPATH/${prefix}.png
144   convert $CONVERT_OPTS_B $TEMPPATH/$this $HTMLPATH/${prefix}B.png
145   touch $HTMLPATH/${prefix}.png $HTMLPATH/${prefix}B.png
146done
147
148# Update timestamp
149
150touch $HTMLPATH/index.shtml
151
152# if this was called as a cgi script, it should redirect to the index.shtml file
153if [ -n "$REMOTE_HOST" ]
154then
155   REL_HTML=${HTMLPATH#$HTMLROOT}
156   echo "Location: $REL_HTML/index.shtml"
157   echo
158fi
159
160if [ -z "$DEBUG" ]
161then
162   rm -rf $TEMPPATH
163fi   
164
165exit 0
Note: See TracBrowser for help on using the browser.