hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/usr/bin/env perl
# $Id: diagrams.pl,v 1.12 2004/05/28 18:54:40 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.12 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.12 2004/05/28 18:54:40 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
#
push @OPTIONS,(
"--alt-autoscale-max"); # alternate scaling
# generate diagrams
#
my $DB_FILE="./rrd/bind.rrd";
if ( -e $DB_FILE) {
foreach my $stat ("success", "referral", "nxrrset", "nxdomain", "recursion", "failure") {
if (%PLOT) { next if ! defined $PLOT{$stat}; }
print "creating images for bind ".$stat."s...\n";
my $LEGEND=$stat."s";
$LEGEND=~ s/ss$/ses/;
foreach my $range ("1h","6h","1day","1week","1month","1year") {
my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
my @EXTOPTIONS=("-v", $LEGEND, "-s","-$fullrange", "--title", "$stat - last $descr ($DATESTRING)");
my @COMMANDS;
if ($range eq "1h") {
@COMMANDS=("DEF:avg=$DB_FILE:$stat: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:min=$DB_FILE:$stat:MIN",
"DEF:avg=$DB_FILE:$stat:AVERAGE",
"DEF:max=$DB_FILE:$stat:MAX",
HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
HotSaNICdiagram::insert_lines(%MODULECONFIG));
}
my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$stat-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL);
HotSaNICdiagram::graph(%CONF);
}
print "\n";
}
if ( ! (%PLOT) or (defined $PLOT{all}) ) {
#do 'all' graph
print "creating images for bind (all)...\n";
foreach my $range ("1h","6h","1day","1week","1month","1year") {
my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
my $FILENAME="$OUTDIR/all-$file.$IMGFMT";
my $LEGEND="requests /s";
my @EXTOPTIONS=("-v", $LEGEND, "-s","-$fullrange", "--title", "All DNS Requests - last $descr ($DATESTRING)"),
my @COMMANDS;
if ($range eq "1h") {
@COMMANDS=("DEF:avgsuc=$DB_FILE:success:AVERAGE",
"DEF:avgref=$DB_FILE:referral:AVERAGE",
"DEF:avgnxr=$DB_FILE:nxrrset:AVERAGE",
"DEF:avgnxd=$DB_FILE:nxdomain:AVERAGE",
"DEF:avgrec=$DB_FILE:recursion:AVERAGE",
"DEF:avgfai=$DB_FILE:failure:AVERAGE",
"CDEF:avg=avgsuc,avgref,+,avgnxr,+,avgnxd,+,avgrec,+,avgfai,+",
"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:sucavg=$DB_FILE:success:AVERAGE",
"DEF:sucmax=$DB_FILE:success:MAX",
"DEF:sucmin=$DB_FILE:success:MIN",
"DEF:refavg=$DB_FILE:referral:AVERAGE",
"DEF:refmax=$DB_FILE:referral:MAX",
"DEF:refmin=$DB_FILE:referral:MIN",
"DEF:nxravg=$DB_FILE:nxrrset:AVERAGE",
"DEF:nxrmax=$DB_FILE:nxrrset:MAX",
"DEF:nxrmin=$DB_FILE:nxrrset:MIN",
"DEF:nxdavg=$DB_FILE:nxdomain:AVERAGE",
"DEF:nxdmax=$DB_FILE:nxdomain:MAX",
"DEF:nxdmin=$DB_FILE:nxdomain:MIN",
"DEF:recavg=$DB_FILE:recursion:AVERAGE",
"DEF:recmax=$DB_FILE:recursion:MAX",
"DEF:recmin=$DB_FILE:recursion:MIN",
"DEF:faiavg=$DB_FILE:failure:AVERAGE",
"DEF:faimax=$DB_FILE:failure:MAX",
"DEF:faimin=$DB_FILE:failure:MIN",
"CDEF:avg=sucavg,refavg,+,nxravg,+,nxdavg,+,recavg,+,faiavg,+",
"CDEF:min=sucmin,refmin,+,nxrmin,+,nxdmin,+,recmin,+,faimin,+",
"CDEF:max=sucmax,refmax,+,nxrmax,+,nxdmax,+,recmax,+,faimax,+",
HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
HotSaNICdiagram::insert_lines(%MODULECONFIG));
}
my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/all-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL);
HotSaNICdiagram::graph(%CONF);
}
print "\n";
}
} else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n\n" }
exit 0;