jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [ntp/] [diagrams.pl] - Blame information for rev 18

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.5 2004/06/02 23:25:10 bernisys Exp $
4 
5# include PERL libraries
6use strict;
7use warnings;
8use diagnostics;
9 
10# include HotSaNIC libraries
11use lib "../../lib";
12use lib "./platform";
13use HotSaNICparser;
14use HotSaNICdiagram;
15use common;
16 
17(my $VERSION = '$Revision: 1.5 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.5 2004/06/02 23:25:10 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;
19 
20# read all settings
21#
22my $MODNAME=HotSaNICparser::get_module_name();
23my %CONFIG=HotSaNICparser::get_config("../..");
24my %MODULECONFIG=HotSaNICmod::common::configure();
25 
26my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"};
27 
28my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME;
29if ( ! -e $OUTDIR ) { mkdir $OUTDIR,0755; }
30 
31my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV);
32my @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG);
33 
34# handle module-specific stuff
35#
36my @GRAPHS=("stratum","distance","dispersion","frequency","stability");
37my %LEGENDS=("stratum"=>" ","distance"=>"seconds","dispersion"=>"seconds","frequency"=>"ppm","stability"=>"ppm");
38push @OPTIONS,(
39 "--alt-autoscale-max"); # alternate scaling
40 
41foreach my $graph (@GRAPHS) {
42 foreach my $entry (@{$MODULECONFIG{HOST}}) {
43 my (undef,undef,$item,$DB_FILE,$name,$file,$description)=HotSaNICmod::common::get_names($entry,$graph);
44 
45 if (%PLOT) { next if ! defined $PLOT{$name}; }
46 
47 my $LEGEND=$LEGENDS{$graph};
48 
49 # generate diagrams
50 #
51 $DB_FILE="./rrd/$DB_FILE.rrd";
52 
53 # if database exists, create images...
54 if ( -e $DB_FILE) {
55 
56 print "creating images for $name ($description) ...\n";
57 my $title = "NTP $description";
58 
59 foreach my $range ("1h","6h","1day","1week","1month","1year") {
60 my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
61 
62 my @EXTOPTIONS=("-s","-$fullrange", "-v", $LEGEND, "--title", "$title - last $fullrange ($DATESTRING)");
63 my @COMMANDS;
64 
65 if ($range eq "1h") {
66 @COMMANDS=("DEF:avg=$DB_FILE:$graph:AVERAGE",
67 "AREA:avg#".$MODULECONFIG{COLOR_AREA}.":",
68 HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
69 HotSaNICdiagram::insert_lines(%MODULECONFIG));
70 }
71 
72 else {
73 @COMMANDS=("DEF:avg=$DB_FILE:$graph:AVERAGE",
74 "DEF:max=$DB_FILE:$graph:MAX",
75 "DEF:min=$DB_FILE:$graph:MIN",
76 HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
77 HotSaNICdiagram::insert_data("LINE2","avg" ,$MODULECONFIG{COLOR_LINE} ,"average","min avg max",$LEGEND,1),
78 HotSaNICdiagram::insert_lines(%MODULECONFIG));
79 }
80 
81 my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
82 HotSaNICdiagram::graph(%CONF);
83 }
84 print "\n";
85 }
86 else { print " No database \"$DB_FILE\" found.\n Please check if the daemon is running.\n\n"; }
87 }
88 
89 }
90 
91exit 0;
92 

Powered by WebSVN 2.2.1