jablonka.czprosek.czf

hotsanic

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

 

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;
77for (@res) {
78 ($link_name = $_) =~ s/_/:/;
79print IDXFILE "
802## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
812## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
82}
83$num=@res;
84for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n2## <td></td><td></td>";}
85 
86@res = grep /load/, @db;
87for (@res) {
88 ($link_name = $_) =~ s/_/:/;
89print IDXFILE "
903## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
913## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
92}
93$num=@res;
94for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n3## <td></td><td></td>";}
95 
96@res = grep /mem/, @db;
97for (@res) {
98 ($link_name = $_) =~ s/_/:/;
99print IDXFILE "
1004## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1014## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
102}
103$num=@res;
104for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n4## <td></td><td></td>";}
105 
106@res = grep /swap/, @db;
107for (@res) {
108 ($link_name = $_) =~ s/_/:/;
109print IDXFILE "
1105## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1115## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
112}
113$num=@res;
114for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n5## <td></td><td></td>";}
115 
116@res = grep /users/, @db;
117for (@res) {
118 ($link_name = $_) =~ s/_/:/;
119print IDXFILE "
1206## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1216## <td valign=top><a href=\"",$MODNAME,"/$_.html\">$link_name</a></td>";
122}
123$num=@res;
124for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n6## <td></td><td></td>";}
125 
126@res = grep /irq/, @db;
127for (@res) {
128print IDXFILE "
1297## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1307## <td valign=top><a href=\"",$MODNAME,"/$_.html\">interrupts</a></td>";
131}
132$num=@res;
133for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n7## <td></td><td></td>";}
134 
135@res = grep /uptime/, @db;
136for (@res) {
137print IDXFILE "
1388## <td><a href=\"",$MODNAME,"/$_.html\"><img src=\"system/thumb-$_.",$IMAGEFORMAT,"\"></a></td>
1398## <td valign=top><a href=\"",$MODNAME,"/$_.html\">uptime</a></td>";
140}
141$num=@res;
142for ($nn=$num;$nn<$count;$nn++) { print IDXFILE "\n8## <td></td><td></td>";}
143 
144close IDXFILE;
145 
146foreach $index (@db) {
147 print "writing $index\n";
148 open (FILE,">index/$index.html");
149 print FILE "<html>\n";
150 if ($REFRESH > 0) {
151 print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
152<META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\">
153<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
154 }
155 print FILE "<body>\n";
156 if ( index ($index,"uptime") <0 ) { print FILE "<img src=\"",$index,"-hour.",$IMAGEFORMAT,"\">\n"; }
157 print FILE "<img src=\"",$index,"-day.",$IMAGEFORMAT,"\">\n";
158 print FILE "<img src=\"",$index,"-week.",$IMAGEFORMAT,"\">\n";
159 print FILE "<img src=\"",$index,"-month.",$IMAGEFORMAT,"\">\n";
160 print FILE "<img src=\"",$index,"-year.",$IMAGEFORMAT,"\">\n</body>\n</html>\n";
161 close FILE;
162 }
163 

Powered by WebSVN 2.2.1