rrdweather/ 0000755 0001750 0001750 00000000000 10707062526 011076 5 ustar sw sw rrdweather/install.sh 0000755 0001750 0001750 00000001475 10704634127 013111 0 ustar sw sw #!/bin/sh
PATH=/usr/bin:/bin
CURDIR=`pwd`
echo " "
echo "RRDWeather installer"
echo "--------------------"
echo " "
echo "Make sure you have edited rrdweather.conf and rrdweather_cron before continuing"
echo -n "Do you want to (c)ontinue or (q)uit ? : "
read CONTINUE
if [ $CONTINUE != "c" ]
then
exit 1
else
# *.sh
if [ ! -d /usr/share/rrdweather ]
then
echo "Making directory /usr/share/rrdweather ..."
mkdir /usr/share/rrdweather
fi
echo "Copying script files..."
cp $CURDIR/files/*.sh /usr/share/rrdweather
# rrdweather.conf
echo "Copying config file..."
cp $CURDIR/files/rrdweather.conf /etc
# rrdweather_cron
echo "Copying cron file..."
cp $CURDIR/files/rrdweather_cron /etc/cron.d/rrdweather
# weather.cgi
echo "Copy weather.cgi in a cgi-bin enabled directory of the webserver."
fi
rrdweather/TODO 0000644 0001750 0001750 00000000113 10701412656 011556 0 ustar sw sw Todo :
- tabs for daily/weekly/... graphs instead of everything on 1 page
rrdweather/README 0000644 0001750 0001750 00000004731 10705501306 011753 0 ustar sw sw RRDWeather
Released under the GNU General Public License
http://www.wains.be/projects/rrdweather/
What is RRDWeather ?
RRDWeather is a set of scripts working with RRDtool and weather.com.
It collects weather info from the web on a regular basis and puts it in RRDtool graphs.
Installation
See INSTALL
Contributors
- Lionel Porcheron
- Gregory Bittan
- Gregory Guthrie
- Heikki Hokkanen
Changelog
Version 0.42 - October 2007 :
- weather.cgi
* header titles now link to their section. Patch by Heikki Hokkanen
* click on graphs to go to the next section (click on daily graphs to reach weekly graphs and so on)
* no longer necessary to have several weather.cgi files to display different cities, zip passed as argument. Idea by Gregory Guthrie
* city name fetched from the XML source
* made XHTML 1.1 and CSS 2.1 compliant (again)
Version 0.41 - October 2007 :
- applied the patches made available by Lionel Porcheron in Ubuntu Universe repository
* configuration file in /etc instead of editing script files
* remove interactions and read informations from configuration file
* change database location in cgi script
* db_builder.sh and db_update.sh scripts now go in /usr/share/rrdweather
and no more in /usr/lib/rrdweather
* call rrdweather_cron.sh which creates rrd database if necessary (no need to run db_builder.sh first)
- lower and upper limit variables for pressure graphs in cgi script
- speed variable for wind graphs in cgi script
- reduced size of graphs and changed general layout of graph page
- removed the average label for pressure, which was kind of pointless, and due to the smaller graphs,
the labels for pressure were too large, so I needed to get rid of one
- new install script
Version 0.40 - December 2006 :
- Gregory Bittan RRDWeather $VERSION\n---------------\n\n";
print "Please specify a city to display.\n\n";
print "Example : $uri?zip=12345";
exit 1;
}
# Fetching city name from XML file
my $xml = new XML::Simple;
my $xmlfile = "$tmp_dir/$zip.xml";
# If XML is not available, wait 3 seconds and try again
# If still not available, display the error message which will try to reload the page after 5 seconds
if ( ! -r $xmlfile) {
sleep 3;
if ( ! -r $xmlfile) {
print "Content-Type: text/html\n\n";
print "";
print "";
print "";
print "";
print "";
print "
RRDWeather $VERSION\n---------------\n\n";
print "XML source cannot be read !\n\n";
print "Make sure you are trying to display a city monitored by RRDWeather.\n\n";
print "The XML source may temporarily be unavailable. The page will reload within 5 seconds.\n\n";
print "If the problem persists, there's a problem with this configuration.";
exit 1;
}
}
my $xmldata = $xml->XMLin("$xmlfile");
my $city = $xmldata->{loc}->{dnam};
# Variables
my $date = strftime "%a %b %e %Y %I.%M%p", localtime;
my $points_per_sample = 3;
my $ypoints_err = 96;
my $db_real = "$db_dir/$zip/real.rrd";
my $db_dew = "$db_dir/$zip/dew.rrd";
my $db_felt = "$db_dir/$zip/felt.rrd";
my $db_humidity = "$db_dir/$zip/humidity.rrd";
my $db_wind = "$db_dir/$zip/wind.rrd";
my $db_pressure = "$db_dir/$zip/pressure.rrd";
my $db_uv = "$db_dir/$zip/uv.rrd";
if($system eq "m") {
$speed = 'kph';
$pressurelowlimit = '980';
$pressureuplimit = '1100';
}
elsif($system eq "e") {
$speed = 'mph';
$pressurelowlimit = '20';
$pressureuplimit = '40';
}
my @graphs = (
{ title => 'Daily Graphs', seconds => 3600*24, },
{ title => 'Weekly Graphs', seconds => 3600*24*7, },
{ title => 'Monthly Graphs', seconds => 3600*24*31, },
{ title => 'Yearly Graphs', seconds => 3600*24*365, },
);
sub graph_temperature($$$)
{
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
"--title= Real & felt temp. in $city",
'--vertical-label', 'Real & felt temp.',
'--units-exponent', 0,
'--lazy',
'-Y',
"DEF:real_c=$db_real:real:AVERAGE",
"DEF:felt_c=$db_felt:felt:AVERAGE",
"DEF:dew_c=$db_dew:dew:AVERAGE",
"COMMENT: Min Max Ave Last\\n",
'LINE2:real_c#DD3F4A:Real', 'GPRINT:real_c:MIN: %5.2lf C',
'GPRINT:real_c:MAX: %5.2lf C', 'GPRINT:real_c:AVERAGE: %5.2lf C',
'GPRINT:real_c:LAST: %5.2lf C\\n',
'LINE1:felt_c#3F4ADD:Felt', , 'GPRINT:felt_c:MIN: %5.2lf C',
'GPRINT:felt_c:MAX: %5.2lf C', 'GPRINT:felt_c:AVERAGE: %5.2lf C',
'GPRINT:felt_c:LAST: %5.2lf C\\n',
'LINE1:dew_c#4ADD3F:Dew ', , 'GPRINT:dew_c:MIN: %5.2lf C',
'GPRINT:dew_c:MAX: %5.2lf C', 'GPRINT:dew_c:AVERAGE: %5.2lf C',
'GPRINT:dew_c:LAST: %5.2lf C\\n',
"COMMENT: \\n",
"COMMENT:RRDWeather $VERSION - $date",
);
my $ERR=RRDs::error;
die "ERROR : $ERR\n" if $ERR;
}
sub graph_humidity($$$)
{
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
"--title= Humidity in $city",
'--vertical-label', 'Humidity',
'--lower-limit', 0,
'--upper-limit', 100,
'--units-exponent', 0,
'--lazy',
'-Y',
"DEF:humidity_pc=$db_humidity:humidity:AVERAGE",
'COMMENT: ', "COMMENT: Min Max Ave Last\\n",
'LINE1:humidity_pc#4DD34A:Humidity', 'GPRINT:humidity_pc:MIN: %5.2lf pc',
'GPRINT:humidity_pc:MAX: %5.2lf pc', 'GPRINT:humidity_pc:AVERAGE: %5.2lf pc',
'GPRINT:humidity_pc:LAST: %5.2lf pc\\n',
"COMMENT: \\n",
"COMMENT: \\n",
"COMMENT: \\n",
"COMMENT:RRDWeather $VERSION - $date",
);
my $ERR=RRDs::error;
die "ERROR : $ERR\n" if $ERR;
}
sub graph_wind($$$)
{
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
"--title= Wind in $city",
'--vertical-label', 'Wind',
'--units-exponent', 0,
'--lazy',
'-Y',
"DEF:wind_s=$db_wind:wind:AVERAGE",
"COMMENT: Min Max Ave Last\\n",
'LINE2:wind_s#DD3F4A:Wind', "GPRINT:wind_s:MIN: %5.2lf $speed",
"GPRINT:wind_s:MAX: %5.2lf $speed", "GPRINT:wind_s:AVERAGE: %5.2lf $speed",
"GPRINT:wind_s:LAST: %5.2lf $speed\\n",
"COMMENT: \\n",
"COMMENT:RRDWeather $VERSION - $date",
);
my $ERR=RRDs::error;
die "ERROR : $ERR\n" if $ERR;
}
sub graph_pressure($$$)
{
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
"--title= Pressure in $city",
'--vertical-label', 'Pressure',
'--lower-limit', $pressurelowlimit,
'--upper-limit', $pressureuplimit,
'--units-exponent', 0,
'--lazy',
'-Y',
"DEF:pressure_hpa=$db_pressure:pressure:AVERAGE",
'COMMENT: ', "COMMENT: Min Max Last\\n",
'LINE1:pressure_hpa#DD3F4A:Pressure', 'GPRINT:pressure_hpa:MIN: %5.2lf hPa',
'GPRINT:pressure_hpa:MAX: %5.2lf hPa',
'GPRINT:pressure_hpa:LAST: %5.2lf hPa\\n',
"COMMENT: \\n",
"COMMENT:RRDWeather $VERSION - $date",
);
my $ERR=RRDs::error;
die "ERROR : $ERR\n" if $ERR;
}
sub graph_uv($$$)
{
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
"--title= UV index in $city",
'--vertical-label', 'UV index',
'--lower-limit', 0,
'--upper-limit', 10,
'--units-exponent', 0,
'--lazy',
'-y', '1:5',
"DEF:uv_index=$db_uv:uv:AVERAGE",
'COMMENT: ', "COMMENT: Min Max Ave Last\\n",
'AREA:uv_index#DD3F4A:UV index', 'GPRINT:uv_index:MIN: %5.2lf',
'GPRINT:uv_index:MAX: %5.2lf', 'GPRINT:uv_index:AVERAGE: %5.2lf',
'GPRINT:uv_index:LAST: %5.2lf\\n',
"COMMENT: \\n",
"COMMENT:RRDWeather $VERSION - $date",
);
my $ERR=RRDs::error;
die "ERROR : $ERR\n" if $ERR;
}
sub print_html()
{
print "Content-Type: application/xhtml+xml\n\n";
print <
Weather in $city
\n";
print "According to weather.com
\n";
for my $n (0..$#graphs) {
print "
RRDWeather $VERSION by Sebastien Wains |