jablonka.czprosek.czf

hotsanic

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

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: diagrams.pl,v 1.17 2004/05/23 23:53:39 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/23 23:53:39 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);

# generate diagrams
#
my $DB_FILE="./rrd/queue.rrd";

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

  # handle module-specific settings
  #
  my $LEGEND="bytes";
  my $name=$LEGEND;
  my $title="bytes in Queue";

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

  # graph "bytes in queue"
  #
  print "creating images for bytes in queue ...\n";

  foreach my $range ("1h","6h","1day","1week","1month","1year") {
    my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);

    my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)");
    my @COMMANDS=();

    if ($range eq "1h") {
      @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE",
        "CDEF:avg=avg1,1024,*",
        "AREA:avg#".$MODULECONFIG{COLOR_AREA}.":",
        HotSaNICdiagram::insert_data("LINE1","avg",$MODULECONFIG{COLOR_LINE},"avg","min avg max cur",$LEGEND,1),
        HotSaNICdiagram::insert_lines(%MODULECONFIG));
      }
    else {
      @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE",
        "DEF:max1=$DB_FILE:kbytes:MAX",
        "DEF:min1=$DB_FILE:kbytes:MIN",
        "CDEF:min=min1,1024,*",
        "CDEF:avg=avg1,1024,*",
        "CDEF:max=max1,1024,*",
        HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
        HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE},"avg    ","min avg max",$LEGEND,1),
        HotSaNICdiagram::insert_lines(%MODULECONFIG));
      }

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

  @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG);

  $LEGEND="requests";
  $name="req";
  $title="requests in queue";

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

# graph "items in queue"
  print "creating images for requests ...\n";

  foreach my $range ("1h","6h","1day","1week","1month","1year") {
    my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);

    my $legends="min avg max";
    if ($range eq "1h") { $legends="min avg max cur"; }

    my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)");
    my @COMMANDS=(
      "DEF:req=$DB_FILE:req:AVERAGE",
      "DEF:crefused=$DB_FILE:crefused:AVERAGE",
      "DEF:msrefused=$DB_FILE:msrefused:AVERAGE",
      "DEF:ctimeout=$DB_FILE:ctimeout:AVERAGE",
      "DEF:rtimeout=$DB_FILE:rtimeout:AVERAGE",
      "DEF:nohost=$DB_FILE:nohost:AVERAGE",
      "DEF:other=$DB_FILE:other:AVERAGE",
      "CDEF:active=req,crefused,-,msrefused,-,ctimeout,-,rtimeout,-,nohost,-,other,-,");

    if ($range ne "1h") {
      push @COMMANDS,("DEF:maxreq=$DB_FILE:req:MAX",
        HotSaNICdiagram::insert_data("AREA","maxreq",$MODULECONFIG{COLOR_MINMAX},"abs. maximum        ",$legends,$LEGEND,1),
        "LINE1:maxreq#".$MODULECONFIG{COLOR_LINE}.":");
      }
    # draw "unseen" line for "total" with "other"-value to have it on top of the legend
    push @COMMANDS,(
      HotSaNICdiagram::insert_data("LINE1","other req",$MODULECONFIG{COLOR_LINE}          ,"total               ",$legends,$LEGEND,1),
      HotSaNICdiagram::insert_data("AREA" ,"msrefused",$MODULECONFIG{COLOR_AREA_MSREFUSED},"mail service refused",$legends,$LEGEND,1),
      HotSaNICdiagram::insert_data("STACK","crefused" ,$MODULECONFIG{COLOR_AREA_CREFUSED} ,"connection refused  ",$legends,$LEGEND,1),
      HotSaNICdiagram::insert_data("STACK","other"    ,$MODULECONFIG{COLOR_AREA_OTHER}    ,"other               ",$legends,$LEGEND,1),
      HotSaNICdiagram::insert_data("STACK","nohost"   ,$MODULECONFIG{COLOR_AREA_NOHOST}   ,"host not found      ",$legends,$LEGEND,1),
      HotSaNICdiagram::insert_data("STACK","ctimeout" ,$MODULECONFIG{COLOR_AREA_CTIMEOUT} ,"connection timed out",$legends,$LEGEND,1),
      HotSaNICdiagram::insert_data("STACK","rtimeout" ,$MODULECONFIG{COLOR_AREA_RTIMEOUT} ,"read timed out      ",$legends,$LEGEND,1),
      HotSaNICdiagram::insert_data("STACK","active"   ,$MODULECONFIG{COLOR_AREA}          ,"active              ",$legends,$LEGEND,1),
      "LINE1:req#".$MODULECONFIG{COLOR_LINE}.":",
      HotSaNICdiagram::insert_lines(%MODULECONFIG));

    my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$name-$file",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