1 | 1 | simandl | #!/usr/bin/env perl |
2 | | | |
3 | | | # $Id: makeindex.pl,v 1.25 2004/05/30 23:30:41 bernisys Exp $ |
4 | | | |
5 | | | # include PERL libraries |
6 | | | use warnings; |
7 | | | use diagnostics; |
8 | | | |
9 | | | # include HotSaNIC libraries |
10 | | | use lib "../../lib"; |
11 | | | use lib "./platform"; |
12 | | | use HotSaNICparser; |
13 | | | use HotSaNIChtml; |
14 | | | use common; |
15 | | | |
16 | | | (my $VERSION = '$Revision: 1.25 $') =~ s/.*(\d+\.\d+).*/$1/; |
17 | | | (my $IDENTIFIER = '$Id: makeindex.pl,v 1.25 2004/05/30 23:30:41 bernisys Exp $') =~ s/.*,v (.*) \$/$1/; |
18 | | | |
19 | | | # read global settings |
20 | | | # |
21 | | | $MODNAME=lc HotSaNICparser::get_module_name(); |
22 | | | %CONFIG=HotSaNICparser::get_config("../.."); |
23 | | | $IMAGEFORMAT=$CONFIG{IMAGEFORMAT}; |
24 | | | $WEBDIR=$CONFIG{WEBDIR}."/".lc $MODNAME; |
25 | | | $VARDIR=$CONFIG{VARDIR}."/modules/".lc $MODNAME; |
26 | | | $REFRESH=$CONFIG{REFRESH}; |
27 | | | $REFRESH=0 if !defined $REFRESH; |
28 | | | |
29 | | | %MODCONFIG=HotSaNICmod::common::configure(); |
30 | | | @DIAGRAMS=("hour","6h","day","week","month","year"); |
31 | | | @TIMES=("hour","week"); |
32 | | | |
33 | | | unshift @{$MODCONFIG{HOST}},",,".$MODCONFIG{SECTIONS}; |
34 | | | |
35 | | | # check, which of the sections are needed at all |
36 | | | # |
37 | | | undef my @sections; |
38 | | | foreach my $section ("proc","cpu","load","mem","swap","users","irq","uptime") { |
39 | | | my $use=0; |
40 | | | foreach my $entry (@{$MODCONFIG{HOST}}) { |
41 | | | ($host,$community,$item,$dbname,$name,$file,$description,$targets)=HotSaNICmod::common::get_names($entry); |
42 | | | if (index($targets,$section)>=0) { $use=1; } |
43 | | | } |
44 | | | if ($use == 1) { push @sections,$section; } |
45 | | | } |
46 | | | |
47 | | | # build time-based .html files |
48 | | | # |
49 | | | foreach $time (@TIMES) { |
50 | | | open (FILE,">$WEBDIR/$time.html"); |
51 | | | print FILE HotSaNIChtml::create_header($MODNAME,$REFRESH,"$time overview page")." <table>\n"; |
52 | | | |
53 | | | foreach $target (@sections) { |
54 | | | next if ( ($target eq "uptime") and ($time eq "hour") ); |
55 | | | foreach my $entry (@{$MODCONFIG{HOST}}) { |
56 | | | ($host,$community,$item,$dbname,$name,$file,$description,$targets)=HotSaNICmod::common::get_names($entry); |
57 | | | next if ( ($host ne "") and ($target eq "uptime") ); # uptime via SNMP not implemented! |
58 | | | next if ( ($host ne "") and ($target eq "irq") ); # interrupts via SNMP not implemented! |
59 | | | my $file1=$target; |
60 | | | if ($file ne "") { $file1=$target."_$name"; } |
61 | | | my $name1=$target; |
62 | | | if ($name ne "") { $name1="$target on $name"; } |
63 | | | my $description1=$target; |
64 | | | if ($description ne "") { $description1="$target on $description"; } |
65 | | | print FILE HotSaNIChtml::create_table_entry($IMAGEFORMAT,$file1,$time,$name1,$description1,1); |
66 | | | |
67 | | | # handle multi-CPU systems |
68 | | | # |
69 | | | if ( ($host eq "") and ($target eq "cpu") and ($MODCONFIG{NUMCPU}>1) ) { |
70 | | | for ($nn=0;$nn<$MODCONFIG{NUMCPU};$nn++) { |
71 | | | print FILE HotSaNIChtml::create_table_entry($IMAGEFORMAT,"$file1$nn",$time,"$name1$nn",$description1,1); |
72 | | | } |
73 | | | } |
74 | | | } |
75 | | | } |
76 | | | |
77 | | | print FILE " </table>\n".HotSaNIChtml::create_footer($MODNAME); |
78 | | | close FILE; |
79 | | | } |
80 | | | |
81 | | | my $maxcols = scalar@{$MODCONFIG{HOST}}; |
82 | | | open (IDXFILE,">$VARDIR/idxdata"); |
83 | | | |
84 | | | print IDXFILE HotSaNIChtml::create_overview_table_header($MODNAME,"hour week",$maxcols); |
85 | | | |
86 | | | my $num=0; |
87 | | | foreach my $target (@sections) { |
88 | | | $num++; |
89 | | | foreach my $entry (@{$MODCONFIG{HOST}}) { |
90 | | | ($host,$community,$item,$dbname,$name,$file,$description,$targets)=HotSaNICmod::common::get_names($entry); |
91 | | | if (index($targets,$target)>=0) { |
92 | | | # uptime via SNMP not implemented! |
93 | | | # interrupts via SNMP not implemented! |
94 | | | # |
95 | | | if ( ($host ne "") and ( ($target eq "uptime") or ($target eq "irq") ) ) { |
96 | | | print IDXFILE HotSaNIChtml::create_overview_table_entry_empty($num,1); |
97 | | | next; |
98 | | | } |
99 | | | my $file1=$target; |
100 | | | if ($file ne "") { $file1=$target."_$name"; } |
101 | | | my $description1=$target; |
102 | | | if ($description ne "") { $description1="$target on $description"; } |
103 | | | print IDXFILE HotSaNIChtml::create_overview_table_entry($MODNAME,$IMAGEFORMAT,$num,$file1,$description1); |
104 | | | HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,$file1,$description1,@DIAGRAMS); |
105 | | | } |
106 | | | else { print IDXFILE HotSaNIChtml::create_overview_table_entry_empty($num,1); } |
107 | | | } |
108 | | | |
109 | | | if ( ($target eq "cpu") and ($MODCONFIG{NUMCPU}>1) ) { |
110 | | | for ($nn=0;$nn<$MODCONFIG{NUMCPU};$nn++) { |
111 | | | $num++; |
112 | | | print IDXFILE HotSaNIChtml::create_overview_table_entry($MODNAME,$IMAGEFORMAT,$num,"cpu$nn","cpu$nn"); |
113 | | | print IDXFILE HotSaNIChtml::create_overview_table_entry_empty($num,scalar @{$MODCONFIG{HOST}}-1); |
114 | | | HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,"cpu$nn","cpu$nn",@DIAGRAMS); |
115 | | | } |
116 | | | } |
117 | | | } |
118 | | | |
119 | | | close IDXFILE; |
120 | | | |