jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.32 2004/06/06 08:39:51 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.32 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.32 2004/06/06 08:39:51 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=$MODULECONFIG{GRAPH_BASE}."/s";
37 
38# generate diagrams
39#
40foreach my $entry (@{$MODULECONFIG{DEV}}) {
41 my (undef,undef,undef,$DB_FILE,$name,$file,$description,$maxin,$maxout)=HotSaNICmod::common::get_names($entry);
42 
43 if (%PLOT) { next if ! defined $PLOT{$name}; }
44 
45 $DB_FILE="./rrd/$DB_FILE.rrd";
46 
47# if database exists, create images...
48 if (-e $DB_FILE) {
49 
50 print "creating images for $name ($description) ...\n";
51 if ((! defined $maxin) || ($maxin eq "") || ($maxin == 0)) {
52 print " Maximum input speed not set!\n Please check settings-file!\n setting speed to 100 MBit\n";
53 $maxin=12500000;
54 }
55 if ((! defined $maxout) || ($maxout eq "") || ($maxout == 0)) {
56 print " Maximum output speed not set!\n Please check settings-file!\n setting speed to 100 MBit\n";
57 $maxout=12500000;
58 }
59 if ($MODULECONFIG{GRAPH_BASE} eq "bits") {
60 $maxin*=8;
61 $maxout*=8;
62 }
63 
64 foreach my $range ("1h","6h","1day","1week","1month","1year") {
65 my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
66 
67# $name =~ s/:/\\:/g;
68 
69 my @EXTOPTIONS=("-s", "-$range", "-v","$LEGEND", "--title", "traffic on $name - last $timelong ($DATESTRING)");
70 my @COMMANDS;
71 if ($MODULECONFIG{GRAPH_BASE} eq "bits") {
72 @COMMANDS=("DEF:dbminin=$DB_FILE:in:MIN",
73 "DEF:dbmaxin=$DB_FILE:in:MAX",
74 "DEF:dbavgin=$DB_FILE:in:AVERAGE",
75 "DEF:dbminout=$DB_FILE:out:MIN",
76 "DEF:dbmaxout=$DB_FILE:out:MAX",
77 "DEF:dbavgout=$DB_FILE:out:AVERAGE",
78 "CDEF:minin=dbminin,8,*",
79 "CDEF:maxin=dbmaxin,8,*",
80 "CDEF:avgin=dbavgin,8,*",
81 "CDEF:minout=dbminout,8,*",
82 "CDEF:maxout=dbmaxout,8,*",
83 "CDEF:avgout=dbavgout,8,*");
84 }
85 else {
86 @COMMANDS=("DEF:minin=$DB_FILE:in:MIN",
87 "DEF:maxin=$DB_FILE:in:MAX",
88 "DEF:avgin=$DB_FILE:in:AVERAGE",
89 "DEF:minout=$DB_FILE:out:MIN",
90 "DEF:maxout=$DB_FILE:out:MAX",
91 "DEF:avgout=$DB_FILE:out:AVERAGE");
92 }
93 push @COMMANDS,("CDEF:totin=avgin,$fullrange,*",
94 "CDEF:totout=avgout,$fullrange,*",
95 "CDEF:pctin=avgin,100,*,$maxin,/",
96 "CDEF:pctout=avgout,100,*,$maxout,/",
97 HotSaNICdiagram::insert_unknown_area("maxin maxout",$MODULECONFIG{COLOR_WRONGDATA},"device may be down"));
98 if ($MODULECONFIG{SWAPIO}==1) {
99 push @COMMANDS,("CDEF:minin_draw=minin,-1,*",
100 "CDEF:maxin_draw=maxin,-1,*",
101 "CDEF:avgin_draw=avgin,-1,*",
102 "CDEF:minout_draw=minout",
103 "CDEF:maxout_draw=maxout",
104 "CDEF:avgout_draw=avgout");
105 }
106 else {
107 push @COMMANDS,("CDEF:minin_draw=minin",
108 "CDEF:maxin_draw=maxin",
109 "CDEF:avgin_draw=avgin",
110 "CDEF:minout_draw=minout,-1,*",
111 "CDEF:maxout_draw=maxout,-1,*",
112 "CDEF:avgout_draw=avgout,-1,*");
113 }
114 if ($range eq "1h") {
115 push @COMMANDS,(
116 "AREA:avgin_draw#".$MODULECONFIG{COLOR_IN_AREA}.":",
117 HotSaNICdiagram::insert_data("LINE1","avgin_draw minin avgin maxin" ,$MODULECONFIG{COLOR_IN_LINE} ,"input ","min avg max cur",$LEGEND,1),
118 "AREA:avgout_draw#".$MODULECONFIG{COLOR_OUT_AREA}.":",
119 HotSaNICdiagram::insert_data("LINE1","avgout_draw minout avgout maxout",$MODULECONFIG{COLOR_OUT_LINE},"output","min avg max cur",$LEGEND,1),
120 "HRULE:$maxin#".$MODULECONFIG{COLOR_MAXSPEED}.":Maximum transmission speed without compression (in\\: $maxin / out\\: $maxout $LEGEND)\\n",
121 "HRULE:-$maxout#".$MODULECONFIG{COLOR_MAXSPEED},
122 "GPRINT:totin:AVERAGE: totals for last hour\\:%7.2lf %s ".$MODULECONFIG{GRAPH_BASE},
123 "GPRINT:pctin:AVERAGE:(%5.2lf %%) input",
124 "GPRINT:totout:AVERAGE: / %7.2lf %s ".$MODULECONFIG{GRAPH_BASE},
125 "GPRINT:pctout:AVERAGE:(%5.2lf %%) output\\n"
126 );
127 }
128 else {
129 push @COMMANDS,(
130 HotSaNICdiagram::insert_minmax("minin_draw maxin_draw minin maxin",$MODULECONFIG{COLOR_IN_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max in ",$LEGEND,1),
131 HotSaNICdiagram::insert_data("LINE2","avgin_draw avgin" ,$MODULECONFIG{COLOR_IN_LINE} ,"avg in ","min avg max",$LEGEND,1),
132 HotSaNICdiagram::insert_minmax("maxout_draw minout_draw minout maxout",$MODULECONFIG{COLOR_OUT_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max out",$LEGEND,1),
133 HotSaNICdiagram::insert_data("LINE2","avgout_draw avgout",$MODULECONFIG{COLOR_OUT_LINE},"avg out ","min avg max",$LEGEND,1),
134 "HRULE:$maxin#".$MODULECONFIG{COLOR_MAXSPEED}.":Maximum transmission speed without compression (in\\: $maxin / out\\: $maxout $LEGEND)",
135 "HRULE:-$maxout#".$MODULECONFIG{COLOR_MAXSPEED},
136 "GPRINT:totin:AVERAGE: totals for last $timelong\\:%7.2lf %s ".$MODULECONFIG{GRAPH_BASE},
137 "GPRINT:pctin:AVERAGE:(%5.2lf %%) input",
138 "GPRINT:totout:AVERAGE: / %7.2lf %s ".$MODULECONFIG{GRAPH_BASE},
139 "GPRINT:pctout:AVERAGE:(%5.2lf %%) output\\n"
140 );
141 }
142 push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
143 
144 my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
145 HotSaNICdiagram::graph(%CONF);
146 }
147 }
148 
149 else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; }
150 print "\n";
151 }
152 

Powered by WebSVN 2.2.1