jablonka.czprosek.czf

hotsanic

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

Compare with Previous - Blame - Download


#!/usr/bin/env perl

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

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

# generate diagrams
#
foreach my $entry (@{$MODULECONFIG{DRIVE}}) {
  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 $legends="min avg max";
      if ($range eq "1h") { $legends="min avg max cur"; }

      my @EXTOPTIONS=("-s","-$fullrange", "--title", "free space on $name - last $timelong ($DATESTRING)");
      my @COMMANDS=("DEF:max=$DB_FILE:max:MAX",
        "DEF:used=$DB_FILE:used:AVERAGE",
        "DEF:maxused=$DB_FILE:used:MAX",
        "DEF:minused=$DB_FILE:used:MIN",
        "CDEF:free=max,used,-",
        "CDEF:minfree=max,maxused,-",
        "CDEF:maxfree=max,minused,-",
        "CDEF:minmax=maxused,minused,-",
        HotSaNICdiagram::insert_data("AREA","max minfree free maxfree free"    ,$MODULECONFIG{COLOR_FREE},"free",$legends,$LEGEND,1),
        "AREA:maxused#".$MODULECONFIG{COLOR_CHANGE}.":",
        HotSaNICdiagram::insert_data("AREA","minused minused used maxused used",$MODULECONFIG{COLOR_USED},"used",$legends,$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";
  }
exit 0;


Powered by WebSVN 2.2.1