jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [makeindex.pl] - Blame information for rev 36

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2use strict;
3use warnings;
4use diagnostics;
5 
6#
7# $Id: makeindex.pl,v 1.10 2003/07/12 20:57:27 bernisys Exp $
8#
9# use Getopt::Long;
10use FindBin;
11use lib "./lib";
12use lib $FindBin::RealBin;
13use HotSaNICparser;
14 
15# let all outputs be flushed directly
16$|=1;
17 
18(my $CALLDIR=$FindBin::RealBin) =~ s/\/rrdtimer//g;
19(my $VERSION = '$Revision: 1.10 $') =~ s/.*(\d+\.\d+).*/$1/;
20 
21my %CONFIG=HotSaNICparser::get_config($CALLDIR);
22 
23 
24my $DAEMONDIR=$CONFIG{"DAEMONDIR"};
25my $WEBDIR=$CONFIG{"WEBDIR"};
26my $ORDER=$CONFIG{"ORDER"};
27my $SHOW=$CONFIG{"SHOW"};
28my $CONVERTMETHOD=$CONFIG{"CONVERTMETHOD"};
29my $THUMBSIZE=$CONFIG{"THUMBSIZE"};
30my $WIDTH=$CONFIG{"WIDTH"};
31$THUMBSIZE=~s/%//g;
32$THUMBSIZE=~ s/,/\./g;
33$THUMBSIZE=int($THUMBSIZE*$WIDTH/100);
34 
35my @modules=HotSaNICparser::scan_for_modules("$DAEMONDIR/modules",-1,$SHOW);
36 
37my (@order,$subdirs,@ITEMS,$item,%count,%lines,$dir,$MAXLINES,$num,$value,$modname,$i,$out);
38 
39# create webdir if necessary
40#
41if ( ! -e $WEBDIR ) {
42 print "creating HTTP output directory:\n $WEBDIR\n";
43 umask 000;
44 mkdir $WEBDIR,0755 or die "ERROR: $!\n\n";
45 }
46 
47@order=split(/ /,$ORDER);
48 
49# first add all existing modules in the order they are listed
50# in the "ORDER" config-string
51#
52$subdirs=join(" ",@modules);
53foreach $item (@order) {
54 if (index($subdirs,$item) >=0) { push @ITEMS,$item; }
55 }
56 
57# then add all not ordered but wanted modules in alphabetical order
58#
59$subdirs=join(" ",@ITEMS);
60foreach $item (@modules) {
61 if (index($subdirs,$item) <0) { push @ITEMS,$item; }
62 }
63 
64$MAXLINES=0;
65print "generating index-files for each plugin...\n";
66 
67foreach $modname (sort @ITEMS) {
68 my $subdir="$DAEMONDIR/modules/$modname";
69 print $modname,"\n";
70 $count{$modname}=1;
71 if ( ! -e "$subdir/index" ) { mkdir "$subdir/index",0755; }
72 if ( -e "$subdir/makeindex.pl") { system("cd \"$subdir\"; ./makeindex.pl >/dev/null"); }
73 elsif ( -e "$subdir/makeindex") { system("cd \"$subdir\"; ./makeindex >/dev/null"); }
74 open FILE,"$subdir/idxdata";
75 while (<FILE>) {
76 ($num,$value)=split(/##/,$_);
77 if ($MAXLINES < $num) { $MAXLINES=$num; }
78 if ( (defined $value) && ($value ne "") ) { push @{ $lines{$modname} },"$_"; } elsif ($num ne "") { $count{$modname} = $num; }
79 }
80 close FILE;
81 unlink "$subdir/idxdata";
82 
83 # create module-subdir if necessary and copy the module's
84 # html files there.
85 # (this may vanish in future because it could also be
86 # handled by each module itself!)
87 #
88 if ( ! -e "$WEBDIR/$modname" ) {
89 print " creating directory $WEBDIR/$modname\n";
90 mkdir "$WEBDIR/$modname",0755 or die "ERROR: $!\n";
91 }
92 print " moving index-files to webdir\n";
93 system ("mv -f \"$subdir/index/\"* \"$WEBDIR/$modname/\"");
94 print "\n";
95 }
96 
97print "\nbuilding $WEBDIR/index.html ...\n";
98 
99if ( ! -e "$WEBDIR/rrdtool.gif" ) { system("cp -f images/rrdtool.gif $WEBDIR"); }
100if ( ! -e "$WEBDIR/HotSaNIC.gif" ) { system("cp -f images/HotSaNIC.gif $WEBDIR"); }
101 
102open INDEXFILE,">$WEBDIR/index.html";
103print INDEXFILE "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
104<html>
105<HEAD>
106 <META NAME=\"Author\" CONTENT=\"Bernd Pissny\">
107 <META NAME=\"GENERATOR\" CONTENT=\"perl-script\">
108 <TITLE>System statistics</TITLE>
109 </HEAD>
110<body>
111<center>
112<table border=0>\n";
113 
114print "table-size: ",$MAXLINES+1," lines.\n\n";
115print "Modules are added in this order:\n";
116 
117# scan array from 0 to $MAXLINES to create the table lines.
118# if no line was found corrosponding to actual line-number
119# then output a table row with no entries
120for ($i=0; $i<=$MAXLINES; $i++) {
121 print INDEXFILE " <tr valign=top>\n";
122 foreach $modname (@ITEMS) {
123 if ($i == 0) { print $modname,"\n"; }
124 $out=0;
125 foreach (@{ $lines{$modname} }) {
126 ($num,$value)=split(/##/);
127 if ($num == $i) {
128 if ($CONVERTMETHOD eq "HTML") {
129 $value=~ s/thumb-//g;
130 $value=~ s/.gif"/-week.gif" width="$THUMBSIZE"/g;
131 $value=~ s/.png"/-week.png" width="$THUMBSIZE"/g;
132 }
133 print INDEXFILE $value; $out=1;
134 }
135 }
136 if ( $out == 0 ) { for (my $nn=1; $nn<=$count{$modname}; $nn++) { print INDEXFILE " <td></td><td></td>\n"; } }
137 }
138 print INDEXFILE " </tr>\n";
139 }
140 print INDEXFILE "</table><br><hr><br>
141<a href=\"http://hotsanic.sourceforge.net\"><img src=\"HotSaNIC.gif\" width=97 height=34 alt=\"HotSaNIC\" border=0></a>&nbsp;<a href=\"http://ee-staff.ethz.ch/~oetiker/webtools/rrdtool/\"><img src=\"rrdtool.gif\" width=120 height=34 alt=\"rrdtool\" border=0></a><br>
142HTML overview to System and Network Information Center
143</center>
144</body>
145</html>\n";
146 
147close INDEXFILE;
148 
149print "\ndone.\n\n";
150 

Powered by WebSVN 2.2.1