jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [system/] [makeindex.pl] - Blame information for rev 28

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2use warnings;
3use diagnostics;
4 
5use lib "../../lib";
6use HotSaNICparser;
7 
8# read global settings
9#
10$MODNAME=lc HotSaNICparser::get_module_name();
11 
12%CONFIG=HotSaNICparser::get_config("../..");
13$IMAGEFORMAT=$CONFIG{"IMAGEFORMAT"};
14$REFRESH=$CONFIG{"REFRESH"};
15$REFRESH=0 if !defined $REFRESH;
16 
17# read module-specific settings
18#
19 
20# evaluate number of CPUs
21#
22opendir DIR,"rrd";
23@DBs = grep /^[^.].*/, readdir DIR;
24closedir DIR;
25foreach (@DBs) { chomp; s/\.rrd//g;
26 push @db,$_;
27 if (/mem/) { s/mem/swap/g; push @db,$_; }
28 }
29 
30 @db=sort(@db);
31 
32# build time-based .html files
33#
34foreach $index ("hour","week") {
35 open (FILE,">index/$index.html");
36 print FILE "<html>\n";
37 if ($REFRESH > 0) {
38 print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
39<META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\">
40<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
41 }
42 print FILE "<body>\n<table>\n";
43 
44 for (@db) {
45 ($link_name = $_) =~ s/_/:/;
46 print FILE "<tr><td><a href=\"$_.html\"><img src=\"$_-",$index,".",$IMAGEFORMAT,"\"></a></td>\n
47 <td valign=top><a href=\"proc.html\"><h2>$link_name</h2></a></td></tr>\n";
48 }
49 
50 print FILE "</table>\n</body>\n</html>\n";
51 close FILE;
52 }
53 
54$count = 0;
55for (@db) { $count += 1 if /cpu/; }
56 
57open (IDXFILE,">idxdata");
58if ($count>1) { print IDXFILE "$count\n"; }
59 
60print IDXFILE "0## <td colspan=".2*$count." align=center> <font size=\"+3\">",$MODNAME,"</font><br>
610## <a href=\"",$MODNAME,"/hour.html\">hour</a>
620## <a href=\"",$MODNAME,"/week.html\">week</a><br>
630## <hr width=90%>
640## </td>";
65 
66@res = grep /proc/, @db;
67for (@res) {
68 ($link_name = $_) =~ s/_/:/;
69print IDXFILE "
701## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
711## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
72}
73$num=@res;
74for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n1## <td></td><td></td>";}
75 
76@res = grep /cpu/, @db;
7727simandlprint IDXFILE "
782## <td>";
791simandlfor (@res) {
80 ($link_name = $_) =~ s/_/:/;
81print IDXFILE "
8227simandl2## <a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a>
832## <a href=\"",$MODNAME,"/$_.html\">$link_name</a>";
841simandl}
8527simandlprint IDXFILE "
862## </td>";
87for ($i = 0; $i < 2 * @res - 1; ++$i) {
88print IDXFILE "
892## <td></td>";
90}
911simandl$num=@res;
92for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n2## <td></td><td></td>";}
93 
94@res = grep /load/, @db;
95for (@res) {
96 ($link_name = $_) =~ s/_/:/;
97print IDXFILE "
983## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
993## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
100}
101$num=@res;
102for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n3## <td></td><td></td>";}
103 
104@res = grep /mem/, @db;
105for (@res) {
106 ($link_name = $_) =~ s/_/:/;
107print IDXFILE "
1084## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1094## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
110}
111$num=@res;
112for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n4## <td></td><td></td>";}
113 
114@res = grep /swap/, @db;
115for (@res) {
116 ($link_name = $_) =~ s/_/:/;
117print IDXFILE "
1185## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1195## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
120}
121$num=@res;
122for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n5## <td></td><td></td>";}
123 
124@res = grep /users/, @db;
125for (@res) {
126 ($link_name = $_) =~ s/_/:/;
127print IDXFILE "
1286## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1296## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
130}
131$num=@res;
132for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n6## <td></td><td></td>";}
133 
134@res = grep /irq/, @db;
135for (@res) {
136print IDXFILE "
1377## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1387## <td valign=top><a href=\"",$MODNAME,"/$_.html\">interrupts</a></td>";
139}
140$num=@res;
141for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n7## <td></td><td></td>";}
142 
143@res = grep /uptime/, @db;
144for (@res) {
145print IDXFILE "
1468## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1478## <td valign=top><a href=\"",$MODNAME,"/$_.html\">uptime</a></td>";
148}
149$num=@res;
150for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n8## <td></td><td></td>";}
151 
152close IDXFILE;
153 
154foreach $index (@db) {
155 print "writing $index\n";
156 open (FILE,">index/$index.html");
157 print FILE "<html>\n";
158 if ($REFRESH > 0) {
159 print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
160<META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\">
161<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
162 }
163 print FILE "<body>\n";
164 if ( index ($index,"uptime") <0 ) { print FILE "<img src=\"",$index,"-hour.",$IMAGEFORMAT,"\">\n"; }
165 print FILE "<img src=\"",$index,"-day.",$IMAGEFORMAT,"\">\n";
166 print FILE "<img src=\"",$index,"-week.",$IMAGEFORMAT,"\">\n";
167 print FILE "<img src=\"",$index,"-month.",$IMAGEFORMAT,"\">\n";
168 print FILE "<img src=\"",$index,"-year.",$IMAGEFORMAT,"\">\n</body>\n</html>\n";
169 close FILE;
170 }
171 

Powered by WebSVN 2.2.1