jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.17 2004/05/26 18:21:13 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 18:21:13 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";
37push @OPTIONS,(
38 "-v",$LEGEND, # Y-legend
39 "--alt-autoscale", # alternate scaling
40 "-a",uc($IMGFMT)); # image format
41 
42# generate diagrams
43#
44foreach my $entry (@{$MODULECONFIG{DEV}}) {
45 my (undef,undef,$item,$DB_FILE,$name,$file,$description)=HotSaNICmod::common::get_names($entry);
46 
47 if (%PLOT) { next if ! defined $PLOT{$item}; }
48 
49 $DB_FILE="./rrd/$DB_FILE.rrd";
50 
51# if database exists, create images...
52 if ( -e $DB_FILE) {
53 
54 print "creating images for $name ($description) ...\n";
55 foreach my $range ("1h","6h","1day","1week","1month","1year") {
56 my ($descr,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
57 
58 my $MULT=1;
59 my $legends="min avg max";
60 if ($range eq "1h") { $legends="min avg max cur"; }
61 my @EXTOPTIONS=("-s","-$range", "--title", "traffic to $name - last $descr ($DATESTRING)");
62 my @COMMANDS=("DEF:dbtcpin=$DB_FILE:tcpin:AVERAGE",
63 "DEF:dbudpin=$DB_FILE:udpin:AVERAGE",
64 "DEF:dbicmpin=$DB_FILE:icmpin:AVERAGE",
65 "DEF:dbtcpout=$DB_FILE:tcpout:AVERAGE",
66 "DEF:dbudpout=$DB_FILE:udpout:AVERAGE",
67 "DEF:dbicmpout=$DB_FILE:icmpout:AVERAGE");
68 if ($MODULECONFIG{GRAPH_BASE} eq "bits") {
69 push @COMMANDS,("CDEF:tcpin=dbtcpin,8,*",
70 "CDEF:udpin=dbudpin,8,*",
71 "CDEF:icmpin=dbicmpin,8,*",
72 "CDEF:tcpout=dbtcpout,8,*",
73 "CDEF:udpout=dbudpout,8,*",
74 "CDEF:icmpout=dbicmpout,8,*");
75 }
76 else {
77 push @COMMANDS,("CDEF:tcpin=dbtcpin",
78 "CDEF:udpin=dbudpin",
79 "CDEF:icmpin=dbicmpin",
80 "CDEF:tcpout=dbtcpout",
81 "CDEF:udpout=dbudpout",
82 "CDEF:icmpout=dbicmpout");
83 }
84 push @COMMANDS,("CDEF:allin=tcpin,udpin,icmpin,+,+",
85 "CDEF:spanin=allin,$fullrange,*",
86 "CDEF:tcpout_inv=0,tcpout,-",
87 "CDEF:udpout_inv=0,udpout,-",
88 "CDEF:icmpout_inv=0,icmpout,-",
89 "CDEF:allout=tcpout,udpout,icmpout,+,+",
90 "CDEF:spanout=allout,$fullrange,*",
91 HotSaNICdiagram::insert_data("AREA" ,"tcpin" ,$MODULECONFIG{COLOR_IN_TCP} ,"tcp in ",$legends,$LEGEND,1),
92 HotSaNICdiagram::insert_data("STACK","udpin" ,$MODULECONFIG{COLOR_IN_UDP} ,"udp in ",$legends,$LEGEND,1),
93 HotSaNICdiagram::insert_data("STACK","icmpin",$MODULECONFIG{COLOR_IN_ICMP},"icmp in ",$legends,$LEGEND,1),
94 "GPRINT:allin:AVERAGE: total average\\: %6.2lf %s $LEGEND",
95 "GPRINT:spanin:AVERAGE: - %6.2lf %s ".$MODULECONFIG{GRAPH_BASE}."/$descr\\n",
96 HotSaNICdiagram::insert_data("AREA" ,"tcpout_inv tcpout" ,$MODULECONFIG{COLOR_OUT_TCP} ,"tcp out",$legends,$LEGEND,1),
97 HotSaNICdiagram::insert_data("STACK","udpout_inv udpout" ,$MODULECONFIG{COLOR_OUT_UDP} ,"udp out",$legends,$LEGEND,1),
98 HotSaNICdiagram::insert_data("STACK","icmpout_inv icmpout",$MODULECONFIG{COLOR_OUT_ICMP},"icmp out",$legends,$LEGEND,1),
99 "GPRINT:allout:AVERAGE: total average\\: %6.2lf %s $LEGEND",
100 "GPRINT:spanout:AVERAGE: - %6.2lf %s ".$MODULECONFIG{GRAPH_BASE}."/$descr\\n",
101 HotSaNICdiagram::insert_lines(%MODULECONFIG));
102 
103 my %CONF=(RANGE=>$time,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
104 HotSaNICdiagram::graph(%CONF);
105 }
106 }
107 else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; }
108 print "\n";
109 }
110exit 0;
111 
112 

Powered by WebSVN 2.2.1