jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.12 2004/05/28 18:54:40 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.12 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.12 2004/05/28 18:54:40 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#
36push @OPTIONS,(
37 "--alt-autoscale-max"); # alternate scaling
38 
39# generate diagrams
40#
41 
42my $DB_FILE="./rrd/bind.rrd";
43 
44if ( -e $DB_FILE) {
45 foreach my $stat ("success", "referral", "nxrrset", "nxdomain", "recursion", "failure") {
46 
47 if (%PLOT) { next if ! defined $PLOT{$stat}; }
48 
49 print "creating images for bind ".$stat."s...\n";
50 
51 my $LEGEND=$stat."s";
52 $LEGEND=~ s/ss$/ses/;
53 
54 foreach my $range ("1h","6h","1day","1week","1month","1year") {
55 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
56 
57 my @EXTOPTIONS=("-v", $LEGEND, "-s","-$fullrange", "--title", "$stat - last $descr ($DATESTRING)");
58 my @COMMANDS;
59 
60 if ($range eq "1h") {
61 @COMMANDS=("DEF:avg=$DB_FILE:$stat:AVERAGE",
62 "AREA:avg#$MODULECONFIG{COLOR_AREA}:",
63 HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
64 HotSaNICdiagram::insert_lines(%MODULECONFIG));
65 }
66 else {
67 @COMMANDS=("DEF:min=$DB_FILE:$stat:MIN",
68 "DEF:avg=$DB_FILE:$stat:AVERAGE",
69 "DEF:max=$DB_FILE:$stat:MAX",
70 HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
71 HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
72 HotSaNICdiagram::insert_lines(%MODULECONFIG));
73 }
74 
75 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$stat-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL);
76 HotSaNICdiagram::graph(%CONF);
77 }
78 print "\n";
79 }
80 
81 if ( ! (%PLOT) or (defined $PLOT{all}) ) {
82 #do 'all' graph
83 
84 print "creating images for bind (all)...\n";
85 foreach my $range ("1h","6h","1day","1week","1month","1year") {
86 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
87 
88 my $FILENAME="$OUTDIR/all-$file.$IMGFMT";
89 
90 my $LEGEND="requests /s";
91 
92 my @EXTOPTIONS=("-v", $LEGEND, "-s","-$fullrange", "--title", "All DNS Requests - last $descr ($DATESTRING)"),
93 my @COMMANDS;
94 
95 if ($range eq "1h") {
96 @COMMANDS=("DEF:avgsuc=$DB_FILE:success:AVERAGE",
97 "DEF:avgref=$DB_FILE:referral:AVERAGE",
98 "DEF:avgnxr=$DB_FILE:nxrrset:AVERAGE",
99 "DEF:avgnxd=$DB_FILE:nxdomain:AVERAGE",
100 "DEF:avgrec=$DB_FILE:recursion:AVERAGE",
101 "DEF:avgfai=$DB_FILE:failure:AVERAGE",
102 "CDEF:avg=avgsuc,avgref,+,avgnxr,+,avgnxd,+,avgrec,+,avgfai,+",
103 "AREA:avg#$MODULECONFIG{COLOR_AREA}:",
104 HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
105 HotSaNICdiagram::insert_lines(%MODULECONFIG));
106 }
107 else {
108 @COMMANDS=("DEF:sucavg=$DB_FILE:success:AVERAGE",
109 "DEF:sucmax=$DB_FILE:success:MAX",
110 "DEF:sucmin=$DB_FILE:success:MIN",
111 "DEF:refavg=$DB_FILE:referral:AVERAGE",
112 "DEF:refmax=$DB_FILE:referral:MAX",
113 "DEF:refmin=$DB_FILE:referral:MIN",
114 "DEF:nxravg=$DB_FILE:nxrrset:AVERAGE",
115 "DEF:nxrmax=$DB_FILE:nxrrset:MAX",
116 "DEF:nxrmin=$DB_FILE:nxrrset:MIN",
117 "DEF:nxdavg=$DB_FILE:nxdomain:AVERAGE",
118 "DEF:nxdmax=$DB_FILE:nxdomain:MAX",
119 "DEF:nxdmin=$DB_FILE:nxdomain:MIN",
120 "DEF:recavg=$DB_FILE:recursion:AVERAGE",
121 "DEF:recmax=$DB_FILE:recursion:MAX",
122 "DEF:recmin=$DB_FILE:recursion:MIN",
123 "DEF:faiavg=$DB_FILE:failure:AVERAGE",
124 "DEF:faimax=$DB_FILE:failure:MAX",
125 "DEF:faimin=$DB_FILE:failure:MIN",
126 "CDEF:avg=sucavg,refavg,+,nxravg,+,nxdavg,+,recavg,+,faiavg,+",
127 "CDEF:min=sucmin,refmin,+,nxrmin,+,nxdmin,+,recmin,+,faimin,+",
128 "CDEF:max=sucmax,refmax,+,nxrmax,+,nxdmax,+,recmax,+,faimax,+",
129 HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
130 HotSaNICdiagram::insert_data("LINE2","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1),
131 HotSaNICdiagram::insert_lines(%MODULECONFIG));
132 }
133 
134 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/all-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL);
135 HotSaNICdiagram::graph(%CONF);
136 }
137 print "\n";
138 }
139 } else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n\n" }
140exit 0;
141 
142 

Powered by WebSVN 2.2.1