jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [system/] [makeindex.pl] - Rev 14 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: makeindex.pl,v 1.25 2004/05/30 23:30:41 bernisys Exp $

# include PERL libraries
use warnings;
use diagnostics;

# include HotSaNIC libraries
use lib "../../lib";
use lib "./platform";
use HotSaNICparser;
use HotSaNIChtml;
use common;

(my $VERSION = '$Revision: 1.25 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: makeindex.pl,v 1.25 2004/05/30 23:30:41 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;

# read global settings
#
$MODNAME=lc HotSaNICparser::get_module_name();
%CONFIG=HotSaNICparser::get_config("../..");
$IMAGEFORMAT=$CONFIG{IMAGEFORMAT};
$WEBDIR=$CONFIG{WEBDIR}."/".lc $MODNAME;
$VARDIR=$CONFIG{VARDIR}."/modules/".lc $MODNAME;
$REFRESH=$CONFIG{REFRESH};
$REFRESH=0 if !defined $REFRESH;

%MODCONFIG=HotSaNICmod::common::configure();
@DIAGRAMS=("hour","6h","day","week","month","year");
@TIMES=("hour","week");

unshift @{$MODCONFIG{HOST}},",,".$MODCONFIG{SECTIONS};

# check, which of the sections are needed at all
#
undef my @sections;
foreach my $section ("proc","cpu","load","mem","swap","users","irq","uptime") {
  my $use=0;
  foreach my $entry (@{$MODCONFIG{HOST}}) {
    ($host,$community,$item,$dbname,$name,$file,$description,$targets)=HotSaNICmod::common::get_names($entry);
    if (index($targets,$section)>=0) { $use=1; }
    }
  if ($use == 1) { push @sections,$section; }
  }

# build time-based .html files
#
foreach $time (@TIMES) {
  open (FILE,">$WEBDIR/$time.html");
  print FILE HotSaNIChtml::create_header($MODNAME,$REFRESH,"$time overview page")."   <table>\n";

  foreach $target (@sections) {
    next if ( ($target eq "uptime") and ($time eq "hour") );
    foreach my $entry (@{$MODCONFIG{HOST}}) {
      ($host,$community,$item,$dbname,$name,$file,$description,$targets)=HotSaNICmod::common::get_names($entry);
      next if ( ($host ne "") and ($target eq "uptime") );  # uptime via SNMP not implemented!
      next if ( ($host ne "") and ($target eq "irq") );     # interrupts via SNMP not implemented!
      my $file1=$target;
      if ($file ne "") { $file1=$target."_$name"; }
      my $name1=$target;
      if ($name ne "") { $name1="$target on $name"; }
      my $description1=$target;
      if ($description ne "") { $description1="$target on $description"; }
      print FILE HotSaNIChtml::create_table_entry($IMAGEFORMAT,$file1,$time,$name1,$description1,1);

      # handle multi-CPU systems
      #
      if ( ($host eq "") and ($target eq "cpu") and ($MODCONFIG{NUMCPU}>1) ) {
        for ($nn=0;$nn<$MODCONFIG{NUMCPU};$nn++) {
          print FILE HotSaNIChtml::create_table_entry($IMAGEFORMAT,"$file1$nn",$time,"$name1$nn",$description1,1);
          }
        }
      }
    }

  print FILE "    </table>\n".HotSaNIChtml::create_footer($MODNAME);
  close FILE;
  }

my $maxcols = scalar@{$MODCONFIG{HOST}};
open (IDXFILE,">$VARDIR/idxdata");

print IDXFILE HotSaNIChtml::create_overview_table_header($MODNAME,"hour week",$maxcols);

my $num=0;
foreach my $target (@sections) {
  $num++;
  foreach my $entry (@{$MODCONFIG{HOST}}) {
    ($host,$community,$item,$dbname,$name,$file,$description,$targets)=HotSaNICmod::common::get_names($entry);
    if (index($targets,$target)>=0) {
      # uptime via SNMP not implemented!
      # interrupts via SNMP not implemented!
      #
      if ( ($host ne "") and ( ($target eq "uptime") or ($target eq "irq") ) ) {
        print IDXFILE HotSaNIChtml::create_overview_table_entry_empty($num,1);
        next;
        }
      my $file1=$target;
      if ($file ne "") { $file1=$target."_$name"; }
      my $description1=$target;
      if ($description ne "") { $description1="$target on $description"; }
      print IDXFILE HotSaNIChtml::create_overview_table_entry($MODNAME,$IMAGEFORMAT,$num,$file1,$description1);
      HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,$file1,$description1,@DIAGRAMS);
      }
    else { print IDXFILE HotSaNIChtml::create_overview_table_entry_empty($num,1); }
    }

  if ( ($target eq "cpu") and ($MODCONFIG{NUMCPU}>1) ) {
    for ($nn=0;$nn<$MODCONFIG{NUMCPU};$nn++) {
      $num++;
      print IDXFILE HotSaNIChtml::create_overview_table_entry($MODNAME,$IMAGEFORMAT,$num,"cpu$nn","cpu$nn");
      print IDXFILE HotSaNIChtml::create_overview_table_entry_empty($num,scalar @{$MODCONFIG{HOST}}-1);
      HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,"cpu$nn","cpu$nn",@DIAGRAMS);
      }
    }
  }

close IDXFILE;


Powered by WebSVN 2.2.1