ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/statgrab/statgrab-make-mrtg-index.in
Revision: 1.1
Committed: Thu Aug 28 11:26:42 2003 UTC (21 years, 3 months ago) by ats
Branch: MAIN
CVS Tags: LIBSTATGRAB_0_6, LIBSTATGRAB_0_5_1
Log Message:
Add scripts to generate MRTG config and index page from statgrab output.

File Contents

# User Rev Content
1 ats 1.1 #!/usr/bin/perl -w
2     # i-scream central monitoring system
3     # http://www.i-scream.org
4     # Copyright (C) 2000-2003 i-scream
5     #
6     # This program is free software; you can redistribute it and/or
7     # modify it under the terms of the GNU General Public License
8     # as published by the Free Software Foundation; either version 2
9     # of the License, or (at your option) any later version.
10     #
11     # This program is distributed in the hope that it will be useful,
12     # but WITHOUT ANY WARRANTY; without even the implied warranty of
13     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     # GNU General Public License for more details.
15     #
16     # You should have received a copy of the GNU General Public License
17     # along with this program; if not, write to the Free Software
18     # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19    
20     use strict;
21     use Getopt::Long;
22    
23     my $progname = "statgrab-make-mrtg-config";
24    
25     my $package_version = '@PACKAGE_VERSION@';
26     my $package_bugreport = '@PACKAGE_BUGREPORT@';
27     my $help_text = <<EOF;
28     Usage: $progname [OPTION]... [CONFIGFILE]...
29     Generate an XHTML index page on stdout from MRTG config files specified
30     on the command line or read from stdin.
31    
32     --help Display this help and exit
33    
34     Version $package_version - report bugs to $package_bugreport.
35     EOF
36    
37     sub main () {
38     GetOptions('help' => \my $help) or die $help_text;
39     if ($help) {
40     print "$help_text";
41     exit 0;
42     }
43    
44     my %pages = ();
45     while (<>) {
46     /^Title\[([^\]]+)\]: (.*)$/ or next;
47     $pages{$2} = $1;
48     }
49     print <<EOF;
50     <?xml version="1.0" encoding="ISO-8859-1"?>
51     <!DOCTYPE html
52     PUBLIC "-//W3C//DTD XHTML 1.1//EN"
53     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
54     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
55     <head>
56     <title>MRTG</title>
57     </head>
58     <body>
59     <h1>MRTG</h1>
60     EOF
61     foreach my $title (sort keys %pages) {
62     my $page = $pages{$title};
63     print "<h2><a href=\"$page.html\">$title</a></h2>\n";
64     print "<img src=\"$page-day.png\" />\n";
65     }
66     print <<EOF;
67     </body>
68     </html>
69     EOF
70     }
71    
72     main();