jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.17 2004/05/26 17:22:26 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.17 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.17 2004/05/26 17:22:26 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 $LEGEND="sec.";
37 
38# common options
39#
40push @OPTIONS,(
41 "-v",$LEGEND); # Y-legend
42 
43 
44# generate diagrams
45#
46foreach my $entry (@{$MODULECONFIG{HOST}}) {
47 my (undef,undef,undef,$DB_FILE,$name,$file,$description)=HotSaNICmod::common::get_names($entry);
48 
49 if (%PLOT) { next if ! defined $PLOT{$name}; }
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 foreach my $range ("1h","6h","1day","1week","1month","1year") {
58 my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
59 
60 my @EXTOPTIONS=("-s","-$fullrange", "--title", "ping-times to $name - last $timelong ($DATESTRING)");
61 my @COMMANDS;
62 
63 if ($range eq "1h") {
64 my $legends="min avg max cur";
65 @COMMANDS=("DEF:min=$DB_FILE:min:AVERAGE",
66 "DEF:avg=$DB_FILE:avg:AVERAGE",
67 "DEF:max=$DB_FILE:max:AVERAGE",
68 "CDEF:wrong=max,0,EQ,INF,UNKN,IF",
69 HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_AREA_MINMAX},"","min/max",$LEGEND,1),
70 HotSaNICdiagram::insert_data("LINE1","max",$MODULECONFIG{COLOR_LINE_MAX} ,"max",$legends,$LEGEND,1),
71 HotSaNICdiagram::insert_data("LINE1","avg",$MODULECONFIG{COLOR_LINE_AVERAGE},"avg",$legends,$LEGEND,1),
72 HotSaNICdiagram::insert_data("LINE1","min",$MODULECONFIG{COLOR_LINE_MIN} ,"min",$legends,$LEGEND,1),
73 "AREA:wrong#".$MODULECONFIG{COLOR_WRONGDATA}.":unreachable",
74 HotSaNICdiagram::insert_lines(%MODULECONFIG));
75 }
76 else {
77 my $legends="min avg max";
78 @COMMANDS=("DEF:mini=$DB_FILE:min:MIN",
79 "DEF:mina=$DB_FILE:min:AVERAGE",
80 "DEF:minx=$DB_FILE:min:MAX",
81 "DEF:avgi=$DB_FILE:avg:MIN",
82 "DEF:avga=$DB_FILE:avg:AVERAGE",
83 "DEF:avgx=$DB_FILE:avg:MAX",
84 "DEF:maxi=$DB_FILE:max:MIN",
85 "DEF:maxa=$DB_FILE:max:AVERAGE",
86 "DEF:maxx=$DB_FILE:max:MAX",
87 "CDEF:wrong=maxx,0,EQ,INF,UNKN,IF");
88 if ($MODULECONFIG{TYPE} eq "simple") {
89 push @COMMANDS,(
90 HotSaNICdiagram::insert_minmax("mini maxx",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"",$LEGEND,1),
91 HotSaNICdiagram::insert_data("LINE1","maxx maxi maxa maxx",$MODULECONFIG{COLOR_LINE_MAX} ,"max",$legends,$LEGEND,1),
92 HotSaNICdiagram::insert_data("LINE1","avga avgi avga avgx",$MODULECONFIG{COLOR_LINE_AVERAGE},"avg",$legends,$LEGEND,1),
93 HotSaNICdiagram::insert_data("LINE1","mini mini mina minx",$MODULECONFIG{COLOR_LINE_MIN} ,"min",$legends,$LEGEND,1),
94 "AREA:wrong#".$MODULECONFIG{COLOR_WRONGDATA}.":unreachable",
95 HotSaNICdiagram::insert_lines(%MODULECONFIG));
96 }
97 else {
98 push @COMMANDS,(
99 HotSaNICdiagram::insert_data("AREA","maxx maxi maxa maxx",$MODULECONFIG{COLOR_AREA_MAX} ,"max range",$legends,$LEGEND,1),
100 "AREA:maxi#ffffff:",
101 HotSaNICdiagram::insert_data("AREA","avgx avgi avga avgx",$MODULECONFIG{COLOR_AREA_AVERAGE},"avg range",$legends,$LEGEND,1),
102 "AREA:avgi#ffffff:",
103 HotSaNICdiagram::insert_data("AREA","minx mini mina minx",$MODULECONFIG{COLOR_AREA_MIN} ,"min range",$legends,$LEGEND,1),
104 "AREA:mini#ffffff:",
105 "LINE1:maxa#".$MODULECONFIG{COLOR_LINE_MAX}.":max",
106 "LINE1:avga#".$MODULECONFIG{COLOR_LINE_AVERAGE}.":avg",
107 "LINE1:mina#".$MODULECONFIG{COLOR_LINE_MIN}.":min\\n",
108 "AREA:wrong#".$MODULECONFIG{COLOR_WRONGDATA}.":unreachable",
109 HotSaNICdiagram::insert_lines(%MODULECONFIG));
110 }
111 }
112 my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
113 HotSaNICdiagram::graph(%CONF);
114 }
115 }
116 else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; }
117 print "\n";
118 }
119exit 0;
120 

Powered by WebSVN 2.2.1