1 | 16 | simandl | #!/usr/bin/env perl |
2 | | | use warnings; |
3 | | | use diagnostics; |
4 | | | |
5 | | | use lib "../../lib"; |
6 | | | use 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 | | | undef %DEVS; |
20 | | | foreach (HotSaNICparser::read_settings(".")) { |
21 | | | ($var,$value)=HotSaNICparser::parse_line($_); |
22 | | | if ($var eq "IFACE") { |
23 | | | ($ip,$name)=split(/,/,$value); |
24 | | | $DEVS{$ip}=$name; |
25 | | | } |
26 | | | } |
27 | | | @DIAGRAMS=("hour","6h","day","week","month","year"); |
28 | | | |
29 | | | # build time-based .html files |
30 | | | # |
31 | | | foreach $time ("6h","week") { |
32 | | | open (FILE,">index/$time.html"); |
33 | | | print FILE "<html>\n"; |
34 | | | if ($REFRESH > 0) { |
35 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
36 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
37 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
38 | | | } |
39 | | | print FILE "<body>\n<table>\n"; |
40 | | | foreach $dev (sort keys(%DEVS)) { |
41 | | | $name=$DEVS{$dev}; |
42 | | | if ( $name eq "" ) { $name=$dev; } |
43 | | | print FILE " <tr><td><a href=\"",$dev,".html\"><img src=\"",$dev,"-",$time,".",$IMAGEFORMAT,"\"></a></td> |
44 | | | <td valign=top><a href=\"",$dev,".html\"><h2>",$dev,"</h2></a><br>",$name,"</td></tr>\n"; |
45 | | | } |
46 | | | print FILE "</table>\n</body>\n</html>\n"; |
47 | | | close FILE; |
48 | | | } |
49 | | | |
50 | | | # build device-based .html files and complete index |
51 | | | # |
52 | | | open (IDXFILE,">idxdata"); |
53 | | | print IDXFILE "0## <td colspan=2 align=center valign=top> <font size=\"+3\">",$MODNAME,"</font><br> |
54 | | | 0## <a href=\"",$MODNAME,"/6h.html\">6 hours</a> |
55 | | | 0## <a href=\"",$MODNAME,"/week.html\">week</a><br> |
56 | | | 0## <hr width=90%> |
57 | | | 0## </td>\n"; |
58 | | | $nn=0; |
59 | | | foreach $dev (sort keys(%DEVS)) { |
60 | | | $nn++; |
61 | | | $name=$DEVS{$dev}; |
62 | | | if ( $name eq "" ) { $name=$dev; } |
63 | | | |
64 | | | print IDXFILE $nn,"## <td><a href=\"",$MODNAME,"/",$dev,".html\"><img src=\"",$MODNAME,"/thumb-",$dev,".",$IMAGEFORMAT,"\"></a></td> |
65 | | | ",$nn,"## <td valign=top><a href=\"",$MODNAME,"/",$dev,".html\">",$dev,"</a><br><font size=\"-2\">",$name,"</font></td>\n"; |
66 | | | |
67 | | | # build device-based .html |
68 | | | # |
69 | | | open (FILE,">index/$dev.html"); |
70 | | | print FILE "<html>\n"; |
71 | | | if ($REFRESH > 0) { |
72 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
73 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
74 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
75 | | | } |
76 | | | print FILE "<body>\n"; |
77 | | | foreach $diagram (@DIAGRAMS) { |
78 | | | print FILE "<img src=\"",$dev,"-",$diagram,".",$IMAGEFORMAT,"\">\n"; |
79 | | | } |
80 | | | print FILE "</body>\n</html>\n"; |
81 | | | close FILE; |
82 | | | } |
83 | | | |
84 | | | close IDXFILE; |
85 | | | |