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.7
Committed: Tue Apr 6 14:53:00 2004 UTC (20 years, 8 months ago) by tdb
Branch: MAIN
CVS Tags: LIBSTATGRAB_0_17, LIBSTATGRAB_0_16, LIBSTATGRAB_0_15, LIBSTATGRAB_0_14, LIBSTATGRAB_0_13, LIBSTATGRAB_0_12, LIBSTATGRAB_0_11_1, LIBSTATGRAB_0_11, LIBSTATGRAB_0_10_3, LIBSTATGRAB_0_10_2, LIBSTATGRAB_0_10_1, LIBSTATGRAB_0_10, HEAD
Changes since 1.6: +2 -2 lines
Log Message:
Update name of project at the top of all soure files. These files now exist
in their own right, rather than as part of the "CMS".

File Contents

# Content
1 #!/usr/bin/perl -w
2 # i-scream libstatgrab
3 # http://www.i-scream.org
4 # Copyright (C) 2000-2004 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 # $Id: statgrab-make-mrtg-index.in,v 1.6 2004/01/19 16:49:23 tdb Exp $
21
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 --title TITLE Use TITLE as the title of the generated page
35 --help Display this help and exit
36
37 Version $package_version - report bugs to $package_bugreport.
38 EOF
39
40 sub main () {
41 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 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 <title>$pagetitle</title>
65 </head>
66 <body>
67 <h1>$pagetitle</h1>
68 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 print "<p><img src=\"$page-day.png\" alt=\"$page\" /></p>\n";
73 }
74 print <<EOF;
75 <p>Generated by <a href="http://www.i-scream.org/libstatgrab">
76 libstatgrab</a> version $package_version.</p>
77 </body>
78 </html>
79 EOF
80 }
81
82 main();