#!/usr/bin/env perl # $Id: diagrams.pl,v 1.5 2004/06/02 23:25:10 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.5 $') =~ s/.*(\d+\.\d+).*/$1/; (my $IDENTIFIER = '$Id: diagrams.pl,v 1.5 2004/06/02 23:25:10 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 @GRAPHS=("stratum","distance","dispersion","frequency","stability"); my %LEGENDS=("stratum"=>" ","distance"=>"seconds","dispersion"=>"seconds","frequency"=>"ppm","stability"=>"ppm"); push @OPTIONS,( "--alt-autoscale-max"); # alternate scaling foreach my $graph (@GRAPHS) { foreach my $entry (@{$MODULECONFIG{HOST}}) { my (undef,undef,$item,$DB_FILE,$name,$file,$description)=HotSaNICmod::common::get_names($entry,$graph); if (%PLOT) { next if ! defined $PLOT{$name}; } my $LEGEND=$LEGENDS{$graph}; # generate diagrams # $DB_FILE="./rrd/$DB_FILE.rrd"; # if database exists, create images... if ( -e $DB_FILE) { print "creating images for $name ($description) ...\n"; my $title = "NTP $description"; foreach my $range ("1h","6h","1day","1week","1month","1year") { my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); my @EXTOPTIONS=("-s","-$fullrange", "-v", $LEGEND, "--title", "$title - last $fullrange ($DATESTRING)"); my @COMMANDS; if ($range eq "1h") { @COMMANDS=("DEF:avg=$DB_FILE:$graph: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:$graph:AVERAGE", "DEF:max=$DB_FILE:$graph:MAX", "DEF:min=$DB_FILE:$graph: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;
hotsanic |
Subversion Repositories: |
Line No. | Rev | Author | Line |
---|