jablonka.czprosek.czf

hotsanic

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

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: diagrams.pl,v 1.10 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.10 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.10 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);

# handle module-specific stuff
#
my $LEGEND="connections";
push @OPTIONS,(
  "-v",$LEGEND,             # Y-legend
  "--alt-autoscale-max");   # alternate scaling

# closing connection:  ESTA -> FW1 -> CLSWT -> FW2 -> LACK -> TWT -> CLOSE
# establishing connection:  CLOSE -> LSTN -> SYNS -> SYNR -> ESTA 
# CLOSING:  both sides shutdown, but data still to be sent (kind of an error state)
            
# generate diagrams
#
foreach my $dev ("connections") {
  my $name=$dev;

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

  print "creating images for $dev netstats...\n";
# if database exists, create images...
  if ( -e $DB_FILE) {

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

      my $FILENAME="$OUTDIR/$name-$file.$IMGFMT";

#  01=ESTABLISHED  02=SYN_SENT  03=SYN_RECV    04=FIN_WAIT1  05=FIN_WAIT2
#  06=TIME_WAIT    07=CLOSE     08=CLOSE_WAIT  09=LAST_ACK  0A=LISTEN     0B=CLOSING

      my @EXTOPTIONS=("-s","-$range", "--title", "socket stats for $name - last $descr ($DATESTRING)");
      my @COMMANDS;

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

      if ($^O =~ /linux/) {
        @COMMANDS=("DEF:aunkn=$DB_FILE:unknown:AVERAGE",
          "DEF:aesta=$DB_FILE:established:AVERAGE",
          "DEF:asyns=$DB_FILE:synsent:AVERAGE",
          "DEF:asynr=$DB_FILE:synrecv:AVERAGE",
          "DEF:afwt1=$DB_FILE:finwait1:AVERAGE",
          "DEF:afwt2=$DB_FILE:finwait2:AVERAGE",
          "DEF:atmwt=$DB_FILE:timewait:AVERAGE",
          "DEF:aclse=$DB_FILE:close:AVERAGE",
          "DEF:aclwt=$DB_FILE:closewait:AVERAGE",
          "DEF:alack=$DB_FILE:lastack:AVERAGE",
          "DEF:alstn=$DB_FILE:listen:AVERAGE",
          "DEF:acsng=$DB_FILE:closing:AVERAGE",
          "DEF:iunkn=$DB_FILE:unknown:MIN",
          "DEF:iesta=$DB_FILE:established:MIN",
          "DEF:isyns=$DB_FILE:synsent:MIN",
          "DEF:isynr=$DB_FILE:synrecv:MIN",
          "DEF:ifwt1=$DB_FILE:finwait1:MIN",
          "DEF:ifwt2=$DB_FILE:finwait2:MIN",
          "DEF:itmwt=$DB_FILE:timewait:MIN",
          "DEF:iclse=$DB_FILE:close:MIN",
          "DEF:iclwt=$DB_FILE:closewait:MIN",
          "DEF:ilack=$DB_FILE:lastack:MIN",
          "DEF:ilstn=$DB_FILE:listen:MIN",
          "DEF:icsng=$DB_FILE:closing:MIN",
          "DEF:xunkn=$DB_FILE:unknown:MAX",
          "DEF:xesta=$DB_FILE:established:MAX",
          "DEF:xsyns=$DB_FILE:synsent:MAX",
          "DEF:xsynr=$DB_FILE:synrecv:MAX",
          "DEF:xfwt1=$DB_FILE:finwait1:MAX",
          "DEF:xfwt2=$DB_FILE:finwait2:MAX",
          "DEF:xtmwt=$DB_FILE:timewait:MAX",
          "DEF:xclse=$DB_FILE:close:MAX",
          "DEF:xclwt=$DB_FILE:closewait:MAX",
          "DEF:xlack=$DB_FILE:lastack:MAX",
          "DEF:xlstn=$DB_FILE:listen:MAX",
          "DEF:xcsng=$DB_FILE:closing:MAX",
          HotSaNICdiagram::insert_data("AREA" ,"alstn ilstn alstn xlstn alstn",$MODULECONFIG{COLOR_LISTEN}    ,"listen      ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","asyns isyns asyns xsyns asyns",$MODULECONFIG{COLOR_SYNSENT}    ,"syn sent    ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","asynr isynr asynr xsynr asynr",$MODULECONFIG{COLOR_SYNRECV}    ,"syn received",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","aesta iesta aesta xesta aesta",$MODULECONFIG{COLOR_ESTABLISHED},"established ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","afwt1 ifwt1 afwt1 xfwt1 afwt1",$MODULECONFIG{COLOR_FINWAIT1}   ,"fin wait 1  ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","aclwt iclwt aclwt xclwt aclwt",$MODULECONFIG{COLOR_CLOSEWAIT}  ,"close wait  ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","afwt2 ifwt2 afwt2 xfwt2 afwt2",$MODULECONFIG{COLOR_FINWAIT2}   ,"fin wait 2  ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","alack ilack alack xlack alack",$MODULECONFIG{COLOR_LASTACK}    ,"last ack    ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","atmwt itmwt atmwt xtmwt atmwt",$MODULECONFIG{COLOR_TIMEWAIT}   ,"time wait   ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","acsng icsng acsng xcsng acsng",$MODULECONFIG{COLOR_CLOSING}    ,"closing     ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","aclse iclse aclse xclse aclse",$MODULECONFIG{COLOR_CLOSE}      ,"close       ",$legends,$LEGEND,1),
          HotSaNICdiagram::insert_data("STACK","aunkn iunkn aunkn xunkn aunkn",$MODULECONFIG{COLOR_UNKNOWN}    ,"unknown     ",$legends,$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";
    }
  else { print "  No database \"$DB_FILE\" found\n  Please check if the daemon is running.\n\n"; }
  }
exit 0;



Powered by WebSVN 2.2.1