#!/usr/bin/perl use strict; # Edit the following three variables my $title = "Weather in Lexington Kentucky"; my $bgcolor = "#b0b0b0"; # In order, name your data files here, example: "temp" for temp.html my @datapoints = ("temp","humid","pressure","precipitation","wind","vis"); # Hopefully you won't have to fiddle below here! print "Content-type: text/html\n\n"; print "$title\n\n"; # Setup simple css for links print "\n\n"; print "\n\n"; print "\n"; print "

$title


\n\n"; # Cycle through the data points from MRTG to pull out html foreach my $data (@datapoints) { my $printed = 0; my $printlines; my $filename = "$data" . ".html"; my $page = "$data" . ".html"; open(file,$filename) or die ("Can't open file: $!"); my @ary = ; close(file); foreach my $line (@ary) { chomp($line); # Pull out a title if ( $line =~ /\/i ) { my ($foo,$title) = split(/\/i,$line); my ($title,$foo) = split(/\<\/TITLE\>/i,$title); print "

$title

\n"; } # The following line is where we want to start (one line down in reality) if ( $line =~ /Begin .Daily. Graph/ ) { $printlines = 1 } # This is where we want to stop.. if ( $line =~ /End .Daily. Graph/ ) { $printlines = 0; print "
\n\n"; } # Once we've 'printed' at least one line, we output the HTML if ( $printlines ) { if ( $printed >1 ) { # Create a link to the page around the IMG tag if ($line =~ /\\n"; } if ($line =~ /\\n"; } # Strip out a line we don't want to see unless ($line =~ /5 Minute Average/ ) { print "$line\n"; } } $printed++; } } } print "Get this script (should work with any mrtg!)
\n"; print "Get this MRTG config for weather\n"; print "\n";