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.6
Committed: Mon Jan 19 16:49:23 2004 UTC (20 years, 10 months ago) by tdb
Branch: MAIN
CVS Tags: LIBSTATGRAB_0_9, LIBSTATGRAB_0_8_2, LIBSTATGRAB_0_8_1
Changes since 1.5: +2 -0 lines
Log Message:
A whole bunch of minor cosmetic changes.

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 tdb 1.5 # Copyright (C) 2000-2004 i-scream
5 ats 1.1 #
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 tdb 1.6 #
20     # $Id$
21 ats 1.1
22     use strict;
23     use Getopt::Long;
24    
25     my $progname = "statgrab-make-mrtg-config";
26    
27     my $package_version = '@PACKAGE_VERSION@';
28     my $package_bugreport = '@PACKAGE_BUGREPORT@';
29     my $help_text = <<EOF;
30     Usage: $progname [OPTION]... [CONFIGFILE]...
31     Generate an XHTML index page on stdout from MRTG config files specified
32     on the command line or read from stdin.
33    
34 ats 1.2 --title TITLE Use TITLE as the title of the generated page
35 ats 1.1 --help Display this help and exit
36    
37     Version $package_version - report bugs to $package_bugreport.
38     EOF
39    
40     sub main () {
41 ats 1.2 my $hostname = `hostname`;
42     chomp $hostname;
43     my $pagetitle = "MRTG: $hostname";
44    
45     GetOptions('title=s' => \$pagetitle,
46     'help' => \my $help) or die $help_text;
47 ats 1.1 if ($help) {
48     print "$help_text";
49     exit 0;
50     }
51    
52     my %pages = ();
53     while (<>) {
54     /^Title\[([^\]]+)\]: (.*)$/ or next;
55     $pages{$2} = $1;
56     }
57     print <<EOF;
58     <?xml version="1.0" encoding="ISO-8859-1"?>
59     <!DOCTYPE html
60     PUBLIC "-//W3C//DTD XHTML 1.1//EN"
61     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
62     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
63     <head>
64 ats 1.2 <title>$pagetitle</title>
65 ats 1.1 </head>
66     <body>
67 ats 1.2 <h1>$pagetitle</h1>
68 ats 1.1 EOF
69     foreach my $title (sort keys %pages) {
70     my $page = $pages{$title};
71     print "<h2><a href=\"$page.html\">$title</a></h2>\n";
72 tdb 1.4 print "<p><img src=\"$page-day.png\" alt=\"$page\" /></p>\n";
73 ats 1.1 }
74     print <<EOF;
75 tdb 1.3 <p>Generated by <a href="http://www.i-scream.org/libstatgrab">
76     libstatgrab</a> version $package_version.</p>
77 ats 1.1 </body>
78     </html>
79     EOF
80     }
81    
82     main();