jablonka.czprosek.czf

hotsanic

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

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: diagrams.pl,v 1.17 2004/05/26 17:22:26 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.17 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.17 2004/05/26 17:22:26 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="sec.";

# common options
#
push @OPTIONS,(
    "-v",$LEGEND);            # Y-legend


# generate diagrams
#
foreach my $entry (@{$MODULECONFIG{HOST}}) {
  my (undef,undef,undef,$DB_FILE,$name,$file,$description)=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 ("1h","6h","1day","1week","1month","1year") {
      my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);

      my @EXTOPTIONS=("-s","-$fullrange", "--title", "ping-times to $name - last $timelong ($DATESTRING)");
      my @COMMANDS;

      if ($range eq "1h") {
        my $legends="min avg max cur";
        @COMMANDS=("DEF:min=$DB_FILE:min:AVERAGE",
          "DEF:avg=$DB_FILE:avg:AVERAGE",
          "DEF:max=$DB_FILE:max:AVERAGE",
          "CDEF:wrong=max,0,EQ,INF,UNKN,IF",
          HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_AREA_MINMAX},"","min/max",$LEGEND,1),
          HotSaNICdiagram::insert_data("LINE1","max",$MODULECONFIG{COLOR_LINE_MAX}    ,"max",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("LINE1","avg",$MODULECONFIG{COLOR_LINE_AVERAGE},"avg",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("LINE1","min",$MODULECONFIG{COLOR_LINE_MIN}    ,"min",$legends,$LEGEND,1),
          "AREA:wrong#".$MODULECONFIG{COLOR_WRONGDATA}.":unreachable",
          HotSaNICdiagram::insert_lines(%MODULECONFIG));
        }
      else {
        my $legends="min avg max";
        @COMMANDS=("DEF:mini=$DB_FILE:min:MIN",
          "DEF:mina=$DB_FILE:min:AVERAGE",
          "DEF:minx=$DB_FILE:min:MAX",
          "DEF:avgi=$DB_FILE:avg:MIN",
          "DEF:avga=$DB_FILE:avg:AVERAGE",
          "DEF:avgx=$DB_FILE:avg:MAX",
          "DEF:maxi=$DB_FILE:max:MIN",
          "DEF:maxa=$DB_FILE:max:AVERAGE",
          "DEF:maxx=$DB_FILE:max:MAX",
          "CDEF:wrong=maxx,0,EQ,INF,UNKN,IF");
        if ($MODULECONFIG{TYPE} eq "simple") {
          push @COMMANDS,(
            HotSaNICdiagram::insert_minmax("mini maxx",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"",$LEGEND,1),
            HotSaNICdiagram::insert_data("LINE1","maxx maxi maxa maxx",$MODULECONFIG{COLOR_LINE_MAX}    ,"max",$legends,$LEGEND,1),
            HotSaNICdiagram::insert_data("LINE1","avga avgi avga avgx",$MODULECONFIG{COLOR_LINE_AVERAGE},"avg",$legends,$LEGEND,1),
            HotSaNICdiagram::insert_data("LINE1","mini mini mina minx",$MODULECONFIG{COLOR_LINE_MIN}    ,"min",$legends,$LEGEND,1),
            "AREA:wrong#".$MODULECONFIG{COLOR_WRONGDATA}.":unreachable",
            HotSaNICdiagram::insert_lines(%MODULECONFIG));
          }
        else {
          push @COMMANDS,(
            HotSaNICdiagram::insert_data("AREA","maxx maxi maxa maxx",$MODULECONFIG{COLOR_AREA_MAX}    ,"max range",$legends,$LEGEND,1),
            "AREA:maxi#ffffff:",
            HotSaNICdiagram::insert_data("AREA","avgx avgi avga avgx",$MODULECONFIG{COLOR_AREA_AVERAGE},"avg range",$legends,$LEGEND,1),
            "AREA:avgi#ffffff:",
            HotSaNICdiagram::insert_data("AREA","minx mini mina minx",$MODULECONFIG{COLOR_AREA_MIN}    ,"min range",$legends,$LEGEND,1),
            "AREA:mini#ffffff:",
            "LINE1:maxa#".$MODULECONFIG{COLOR_LINE_MAX}.":max",
            "LINE1:avga#".$MODULECONFIG{COLOR_LINE_AVERAGE}.":avg",
            "LINE1:mina#".$MODULECONFIG{COLOR_LINE_MIN}.":min\\n",
            "AREA:wrong#".$MODULECONFIG{COLOR_WRONGDATA}.":unreachable",
            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";
  }
exit 0;


Powered by WebSVN 2.2.1