#! /usr/bin/perl # # $Id: index.cgi,v 1.14 2003/01/07 18:44:49 ajlill Exp $ # # Print something interesting from the OWW use CGI; $q = new CGI; $time = localtime(); $title = "Current Weather - $time"; print $q->header(-title => $title, -expires => "+100s", -refresh => 300, -style => {'src'=>'/default.css'}); print $q->start_html($title); print "

$title

\n"; chop($foo=`tail -1 /var/log/oww`); #12.8 30.4 -0.1 0.0 0.4 4.2 6 10 0.000 0.000 0.000 0.000 if( $foo =~ s/^.*oww(nogui)*\[\d+\]: // ) { ($curT,$maxT,$minT,$curW,$gustW,$maxW,$curV,$maxV,$rainRate,$rainDay,$rainWeek,$rainMonth,$rainCount) = split(/\s+/,$foo); } @dirNames = ("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW" ); $curKMH = $curW*3.6; $gustKMH = $gustW*3.6; # Twind_chill = 13.12 + 0.6215*T - 11.37*(v0.16) + 0.3965*T*(v0.16) $v16 = $curKMH**0.16; $chill = 13.12 + ( 0.6215 * $curT ) - ( 11.37 * $v16 ) + ( 0.3965 * $curT * $v16 ); print "\n"; print "\n"; print "\n"; if( $curKMH > .1 && $chill < $curT ) { printf "\n"; print "
Current ConditionsRain\n"; print "
Temp$curT °Ccurrent$rainRate in/hour\n"; print "
Wind$dirNames[$curV] $curKMH km/hday $rainDay in
Gusts$gustKMH km/hweek $rainWeek in
Wind Chill%2.1f °C",$chill; } else { print "
" } print "month $rainMonth in
\n"; print "

Historical Charts:\n"; print "

"; print "\"Daily\" Temperature Graph
\n"; print "\"daily"; print "
\n"; print "

"; print "\"Daily\" Pond Temperature Graph
\n"; print "\"daily"; print "
\n"; print "

"; print "\"Daily\" Wind Speed Graph
\n"; print "\"daily"; print "
\n"; print "

"; print "\"Daily\" Rain Graph
\n"; print "\"daily"; print "
\n"; print $q->end_html; exit 0; # $Log: index.cgi,v $ # Revision 1.14 2003/01/07 18:44:49 ajlill # Fix windchill display # # Revision 1.13 2003/01/07 06:16:53 ajlill # Add wind chill # # Revision 1.12 2001/09/13 23:01:32 ajlill # Added pond graphs # # Revision 1.11 2001/09/13 22:39:39 ajlill # Re did oww to log all 8 T sensors after the arne data # # Revision 1.10 2001/08/17 04:22:09 ajlill # Updated for rain gauge # # Revision 1.9 2001/07/22 02:09:18 ajlill # Redid oww to syslog data and added raw rain guage count for graphs # # Revision 1.8 2001/07/22 00:08:20 ajlill # Working with rain output from oww # # Revision 1.7 2001/07/18 22:13:10 ajlill # Added a rainfall graph # # Revision 1.6 2001/06/24 01:34:33 ajlill # Updated blurb, added stylesheets # # Revision 1.5 2001/06/15 18:23:54 ajlill # Works and is pretty # # Revision 1.4 2001/06/11 03:08:27 ajlill # Added drilldown # # Revision 1.3 2001/06/10 08:17:01 ajlill # Does daily charts for both speed and T # # Revision 1.2 2001/06/10 08:01:57 ajlill # Works, but ugly # # Revision 1.1 2001/06/10 07:42:31 ajlill # First stab at weather page #