hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/usr/bin/env perl
# $Id: diagrams.pl,v 1.23 2004/05/26 18:15:02 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.23 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.23 2004/05/26 18:15:02 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="processes";
# common options
#
push @OPTIONS,(
"-v",$LEGEND, # Y-legend
"--alt-autoscale-max"); # alternate scaling
# generate diagrams
#
foreach my $entry (@{$MODULECONFIG{APP}}) {
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", "$name - last $timelong ($DATESTRING)");
my @COMMANDS;
if ($range eq "1h") {
@COMMANDS=("DEF:avg=$DB_FILE:data:AVERAGE",
"AREA:avg#".$MODULECONFIG{COLOR_AREA}.":",
HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
HotSaNICdiagram::insert_lines(%MODULECONFIG));
}
else {
@COMMANDS=("DEF:avg=$DB_FILE:data:AVERAGE",
"DEF:max=$DB_FILE:data:MAX",
"DEF:min=$DB_FILE:data:MIN",
HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
HotSaNICdiagram::insert_data("LINE2","avg" ,$MODULECONFIG{COLOR_LINE} ,"average","min avg max",$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);
}
print "\n";
}
else { print " No database \"$DB_FILE\" found.\n Please check if the daemon is running.\n\n"; }
}
exit 0;