jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.17 2004/05/23 23:53:39 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/23 23:53:39 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# generate diagrams
35#
36my $DB_FILE="./rrd/queue.rrd";
37 
38# if database exists, create images...
39if ( -e $DB_FILE) {
40 
41 # handle module-specific settings
42 #
43 my $LEGEND="bytes";
44 my $name=$LEGEND;
45 my $title="bytes in Queue";
46 
47 # common options
48 #
49 push @OPTIONS,(
50 "-v", $LEGEND, # Y-legend
51 "--alt-autoscale-max"); # alternate scaling
52 
53 # graph "bytes in queue"
54 #
55 print "creating images for bytes in queue ...\n";
56 
57 foreach my $range ("1h","6h","1day","1week","1month","1year") {
58 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
59 
60 my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)");
61 my @COMMANDS=();
62 
63 if ($range eq "1h") {
64 @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE",
65 "CDEF:avg=avg1,1024,*",
66 "AREA:avg#".$MODULECONFIG{COLOR_AREA}.":",
67 HotSaNICdiagram::insert_data("LINE1","avg",$MODULECONFIG{COLOR_LINE},"avg","min avg max cur",$LEGEND,1),
68 HotSaNICdiagram::insert_lines(%MODULECONFIG));
69 }
70 else {
71 @COMMANDS=("DEF:avg1=$DB_FILE:kbytes:AVERAGE",
72 "DEF:max1=$DB_FILE:kbytes:MAX",
73 "DEF:min1=$DB_FILE:kbytes:MIN",
74 "CDEF:min=min1,1024,*",
75 "CDEF:avg=avg1,1024,*",
76 "CDEF:max=max1,1024,*",
77 HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
78 HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE},"avg ","min avg max",$LEGEND,1),
79 HotSaNICdiagram::insert_lines(%MODULECONFIG));
80 }
81 
82 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$name-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
83 HotSaNICdiagram::graph(%CONF);
84 }
85 print "\n";
86 
87 @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG);
88 
89 $LEGEND="requests";
90 $name="req";
91 $title="requests in queue";
92 
93 # common options
94 #
95 push @OPTIONS,(
96 "-v",$LEGEND, # Y-legend
97 "--alt-autoscale-max"); # alternate scaling
98 
99# graph "items in queue"
100 print "creating images for requests ...\n";
101 
102 foreach my $range ("1h","6h","1day","1week","1month","1year") {
103 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
104 
105 my $legends="min avg max";
106 if ($range eq "1h") { $legends="min avg max cur"; }
107 
108 my @EXTOPTIONS=("-s","-$fullrange", "--title", "$title - last $descr ($DATESTRING)");
109 my @COMMANDS=(
110 "DEF:req=$DB_FILE:req:AVERAGE",
111 "DEF:crefused=$DB_FILE:crefused:AVERAGE",
112 "DEF:msrefused=$DB_FILE:msrefused:AVERAGE",
113 "DEF:ctimeout=$DB_FILE:ctimeout:AVERAGE",
114 "DEF:rtimeout=$DB_FILE:rtimeout:AVERAGE",
115 "DEF:nohost=$DB_FILE:nohost:AVERAGE",
116 "DEF:other=$DB_FILE:other:AVERAGE",
117 "CDEF:active=req,crefused,-,msrefused,-,ctimeout,-,rtimeout,-,nohost,-,other,-,");
118 
119 if ($range ne "1h") {
120 push @COMMANDS,("DEF:maxreq=$DB_FILE:req:MAX",
121 HotSaNICdiagram::insert_data("AREA","maxreq",$MODULECONFIG{COLOR_MINMAX},"abs. maximum ",$legends,$LEGEND,1),
122 "LINE1:maxreq#".$MODULECONFIG{COLOR_LINE}.":");
123 }
124 # draw "unseen" line for "total" with "other"-value to have it on top of the legend
125 push @COMMANDS,(
126 HotSaNICdiagram::insert_data("LINE1","other req",$MODULECONFIG{COLOR_LINE} ,"total ",$legends,$LEGEND,1),
127 HotSaNICdiagram::insert_data("AREA" ,"msrefused",$MODULECONFIG{COLOR_AREA_MSREFUSED},"mail service refused",$legends,$LEGEND,1),
128 HotSaNICdiagram::insert_data("STACK","crefused" ,$MODULECONFIG{COLOR_AREA_CREFUSED} ,"connection refused ",$legends,$LEGEND,1),
129 HotSaNICdiagram::insert_data("STACK","other" ,$MODULECONFIG{COLOR_AREA_OTHER} ,"other ",$legends,$LEGEND,1),
130 HotSaNICdiagram::insert_data("STACK","nohost" ,$MODULECONFIG{COLOR_AREA_NOHOST} ,"host not found ",$legends,$LEGEND,1),
131 HotSaNICdiagram::insert_data("STACK","ctimeout" ,$MODULECONFIG{COLOR_AREA_CTIMEOUT} ,"connection timed out",$legends,$LEGEND,1),
132 HotSaNICdiagram::insert_data("STACK","rtimeout" ,$MODULECONFIG{COLOR_AREA_RTIMEOUT} ,"read timed out ",$legends,$LEGEND,1),
133 HotSaNICdiagram::insert_data("STACK","active" ,$MODULECONFIG{COLOR_AREA} ,"active ",$legends,$LEGEND,1),
134 "LINE1:req#".$MODULECONFIG{COLOR_LINE}.":",
135 HotSaNICdiagram::insert_lines(%MODULECONFIG));
136 
137 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$name-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
138 HotSaNICdiagram::graph(%CONF);
139 
140 }
141 }
142else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; }
143print "\n";
144 
145exit 0;
146 
147 

Powered by WebSVN 2.2.1