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