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.4
Committed: Fri Nov 7 12:57:00 2003 UTC (21 years, 1 month ago) by tdb
Branch: MAIN
CVS Tags: LIBSTATGRAB_0_8
Changes since 1.3: +1 -1 lines
Log Message:
Add a space I removed by accident.

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 ats 1.2 --title TITLE Use TITLE as the title of the generated page
33 ats 1.1 --help Display this help and exit
34    
35     Version $package_version - report bugs to $package_bugreport.
36     EOF
37    
38     sub main () {
39 ats 1.2 my $hostname = `hostname`;
40     chomp $hostname;
41     my $pagetitle = "MRTG: $hostname";
42    
43     GetOptions('title=s' => \$pagetitle,
44     'help' => \my $help) or die $help_text;
45 ats 1.1 if ($help) {
46     print "$help_text";
47     exit 0;
48     }
49    
50     my %pages = ();
51     while (<>) {
52     /^Title\[([^\]]+)\]: (.*)$/ or next;
53     $pages{$2} = $1;
54     }
55     print <<EOF;
56     <?xml version="1.0" encoding="ISO-8859-1"?>
57     <!DOCTYPE html
58     PUBLIC "-//W3C//DTD XHTML 1.1//EN"
59     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
60     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
61     <head>
62 ats 1.2 <title>$pagetitle</title>
63 ats 1.1 </head>
64     <body>
65 ats 1.2 <h1>$pagetitle</h1>
66 ats 1.1 EOF
67     foreach my $title (sort keys %pages) {
68     my $page = $pages{$title};
69     print "<h2><a href=\"$page.html\">$title</a></h2>\n";
70 tdb 1.4 print "<p><img src=\"$page-day.png\" alt=\"$page\" /></p>\n";
71 ats 1.1 }
72     print <<EOF;
73 tdb 1.3 <p>Generated by <a href="http://www.i-scream.org/libstatgrab">
74     libstatgrab</a> version $package_version.</p>
75 ats 1.1 </body>
76     </html>
77     EOF
78     }
79    
80     main();