jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [worms/] [diagrams.pl] - Rev 10 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: diagrams.pl,v 1.14 2004/05/28 22:19:00 bernisys Exp $

# include PERL libraries
use strict;
use warnings;
use diagnostics;

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

(my $VERSION = '$Revision: 1.14 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.14 2004/05/28 22:19:00 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;

# read all settings
#
my $MODNAME=HotSaNICparser::get_module_name();
my %CONFIG=HotSaNICparser::get_config("../..");
my %MODULECONFIG=HotSaNICmod::common::configure();

my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"};

my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME;
if ( ! -e $OUTDIR ) { mkdir $OUTDIR,0755; }

my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV);
my @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG);

# handle module-specific stuff
#
my $LEGEND="accesses";

push @OPTIONS,(
  "-v",$LEGEND,             # Y-legend
  "--alt-autoscale-max");   # alternate scaling

# generate diagrams
#
foreach my $entry (@{$MODULECONFIG{ITEM}}) {
  my (undef,undef,undef,$DB_FILE,$name,$file,$description,$maxin,$maxout)=HotSaNICmod::common::get_names($entry);

  if (%PLOT) { next if ! defined $PLOT{$name}; }

  $DB_FILE="./rrd/$DB_FILE.rrd";

# if database exists, create images...
  if (-e $DB_FILE) {

    print "creating images for $name ($description) ...\n";
    foreach my $range ("1week","1month","1year") {
      my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);

      my @EXTOPTIONS=("-s","-$range", "--title", "worm-accesses to $name - last $timelong ($DATESTRING)");
      my @COMMANDS=("DEF:min=$DB_FILE:hits:MIN",
        "DEF:max=$DB_FILE:hits:MAX",
        "DEF:avg=$DB_FILE:hits:AVERAGE",
        "AREA:max#".$MODULECONFIG{COLOR_AREA}.":",
        "LINE1:max#".$MODULECONFIG{COLOR_LINE_MAX}.":",
        "AREA:min#ffffff:",
        "LINE1:min#".$MODULECONFIG{COLOR_LINE_MIN}.":",
        HotSaNICdiagram::insert_data("LINE2","avg min avg max",$MODULECONFIG{COLOR_LINE_AVERAGE},"$name","min avg max",$LEGEND,1),
        HotSaNICdiagram::insert_lines(%MODULECONFIG));

      my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
      HotSaNICdiagram::graph(%CONF);
      }
    }

  else { print "  No database \"$DB_FILE\" found\n  Please check if the daemon is running.\n"; }
  print "\n";
  }


Powered by WebSVN 2.2.1