jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.13 2004/05/23 23:53:38 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.13 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.13 2004/05/23 23:53:38 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 
39my @COLORS=("#a00000","#00a000","#0000a0","#00a0a0","#a000a0","#a0a000","#a0a0a0",
40 "#f00000","#00f000","#0000f0","#00f0f0","#f000f0","#f0f000","#f0f0f0");
41 
42opendir DIR,"rrd";
43my @files=grep /\.rrd/,readdir DIR;
44closedir DIR;
45 
46# generate diagrams
47#
48foreach my $dev ("rc5","des","ogr","csc") {
49 
50 if (%PLOT) { next if ! defined $PLOT{$dev}; }
51 
52 my $name=$dev;
53 my $description=$dev;
54 my $LEGEND="keys/s";
55 if ($dev eq "ogr") { $LEGEND="nodes/s"; }
56 
57# if ($var eq "NETWORK") {
58# unshift @ITEMS,$value;
59 
60# if database exists, create images...
61 print "creating images for $description...\n";
62 
63 if (@files) {
64 
65 foreach my $range ("1week","1month","1year") {
66 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
67 
68 my @EXTOPTIONS=("-v", $LEGEND, "-s","-$range", "--title", "$name stats - last $descr ($DATESTRING)");
69 my @COMMANDS=();
70 
71 my $COLOR_NUM=0;
72 my $FIRST="true";
73 
74 foreach (sort @{$MODULECONFIG{NETWORK}}) {
75 (my $item)=split /:/;
76 my $DB_FILE="./rrd/$item.rrd";
77 
78 my $COLOR=$COLORS[$COLOR_NUM%$#COLORS];
79 $COLOR_NUM++;
80 
81 push @COMMANDS,"DEF:ip_$item=$DB_FILE:$dev:AVERAGE";
82 if ($FIRST eq "true") {
83 push @COMMANDS,"AREA:ip_$item$COLOR:$item";
84 $FIRST="false";
85 } else {
86 push @COMMANDS,"STACK:ip_$item$COLOR:$item";
87 }
88 }
89 push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
90 
91 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$name-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
92 HotSaNICdiagram::graph(%CONF);
93 
94 }
95 print "\n";
96 }
97 else { print " No database found\n Please check if the daemon is running.\n\n" }
98 }
99exit 0;
100 
101 

Powered by WebSVN 2.2.1