jablonka.czprosek.czf

hotsanic

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

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: diagrams.pl,v 1.21 2004/05/26 18:16:44 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.21 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.21 2004/05/26 18:16:44 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="bytes/s";

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

# generate diagrams
#
foreach my $entry (@{$MODULECONFIG{DEV}}) {
  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", "I/O rates on $name - last $timelong ($DATESTRING)");
      my @COMMANDS;

      if ($^O =~ /linux/) {
        @COMMANDS=("DEF:iracc=$DB_FILE:racc:MIN",
          "DEF:iwacc=$DB_FILE:wacc:MIN",
          "DEF:irbyt=$DB_FILE:rbyt:MIN",
          "DEF:iwbyt=$DB_FILE:wbyt:MIN",
          "DEF:aracc=$DB_FILE:racc:AVERAGE",
          "DEF:awacc=$DB_FILE:wacc:AVERAGE",
          "DEF:arbyt=$DB_FILE:rbyt:AVERAGE",
          "DEF:awbyt=$DB_FILE:wbyt:AVERAGE",
          "DEF:xracc=$DB_FILE:racc:MAX",
          "DEF:xwacc=$DB_FILE:wacc:MAX",
          "DEF:xrbyt=$DB_FILE:rbyt:MAX",
          "DEF:xwbyt=$DB_FILE:wbyt:MAX",
          "CDEF:iwbyt_inv=0,iwbyt,-",
          "CDEF:awbyt_inv=0,awbyt,-",
          "CDEF:xwbyt_inv=0,xwbyt,-",
          "AREA:xrbyt#".$MODULECONFIG{COLOR_READ_MINMAX}.":",
          "AREA:irbyt#".$MODULECONFIG{COLOR_READ_AREA}.":",
          HotSaNICdiagram::insert_data("LINE1","arbyt irbyt arbyt xrbyt",$MODULECONFIG{COLOR_READ_LINE},"read ","min avg max cur",$LEGEND     ,1),
          HotSaNICdiagram::insert_data(""     ,"0 iracc aracc xracc"    ,"000000"                     ,"     ","min avg max cur","accesses/s",1),
          "COMMENT:\\s",
          "AREA:xwbyt_inv#".$MODULECONFIG{COLOR_WRITE_MINMAX}.":",
          "AREA:iwbyt_inv#".$MODULECONFIG{COLOR_WRITE_AREA}.":",
          HotSaNICdiagram::insert_data("LINE1","awbyt_inv iwbyt awbyt xwbyt",$MODULECONFIG{COLOR_WRITE_LINE},"write","min avg max cur",$LEGEND     ,1),
          HotSaNICdiagram::insert_data(""     ,"0 iwacc awacc xwacc"        ,"000000"                      ,"     ","min avg max cur","accesses/s",1),
          HotSaNICdiagram::insert_lines(%MODULECONFIG));
        }
      elsif ($^O =~ /bsd/) {
        @COMMANDS=("DEF:ikbt=$DB_FILE:kbt:MIN",
          "DEF:akbt=$DB_FILE:kbt:AVERAGE",
          "DEF:xkbt=$DB_FILE:kbt:MAX",
          "DEF:ixfr=$DB_FILE:xfr:MIN",
          "DEF:axfr=$DB_FILE:xfr:AVERAGE",
          "DEF:xxfr=$DB_FILE:xfr:MAX",
          "DEF:itime=$DB_FILE:time:MIN",
          "DEF:atime=$DB_FILE:time:AVERAGE",
          "DEF:xtime=$DB_FILE:time:MAX",
          "DEF:imb=$DB_FILE:mb:MIN",
          "DEF:amb=$DB_FILE:mb:AVERAGE",
          "DEF:xmb=$DB_FILE:mb:MAX",
          HotSaNICdiagram::insert_minmax("imb xmb",$MODULECONFIG{COLOR_READ_MINMAX},$MODULECONFIG{COLOR_BORDER},"max/min",$LEGEND,1),
          HotSaNICdiagram::insert_data("LINE1","amb imb amb xmb",$MODULECONFIG{COLOR_READ_LINE},"Disk Transfer","min avg max cur",$LEGEND,1),
#          HotSaNICdiagram::insert_data("AREA","amb imb amb xmb",$MODULECONFIG{COLOR_WRITE_LINE},"Disk Transfer","min avg max cur",$LEGEND,1),
#         "AREA:amb#FF4040:Disk Transfer\\g",
#         "GPRINT:imb:MIN:  min\\:%7.2lf %s",
#         "GPRINT:amb:AVERAGE: avg\\:%7.2lf %s",
#         "GPRINT:xmb:MAX: max\\:%7.2lf %s bytes/s\\n",
          "COMMENT:\\s",
          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