1 | 1 | simandl | #!/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 |
6 | | | use strict; |
7 | | | use warnings; |
8 | | | use diagnostics; |
9 | | | |
10 | | | # include HotSaNIC libraries |
11 | | | use lib "../../lib"; |
12 | | | use lib "./platform"; |
13 | | | use HotSaNICparser; |
14 | | | use HotSaNICdiagram; |
15 | | | use 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 | | | # |
22 | | | my $MODNAME=HotSaNICparser::get_module_name(); |
23 | | | my %CONFIG=HotSaNICparser::get_config("../.."); |
24 | | | my %MODULECONFIG=HotSaNICmod::common::configure(); |
25 | | | |
26 | | | my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"}; |
27 | | | |
28 | | | my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME; |
29 | | | if ( ! -e $OUTDIR ) { mkdir $OUTDIR,0755; } |
30 | | | |
31 | | | my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV); |
32 | | | my @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG); |
33 | | | |
34 | | | # handle module-specific stuff |
35 | | | # |
36 | | | push @OPTIONS,( |
37 | | | "--alt-autoscale-max"); # alternate scaling |
38 | | | |
39 | | | my @COLORS=("#a00000","#00a000","#0000a0","#00a0a0","#a000a0","#a0a000","#a0a0a0", |
40 | | | "#f00000","#00f000","#0000f0","#00f0f0","#f000f0","#f0f000","#f0f0f0"); |
41 | | | |
42 | | | opendir DIR,"rrd"; |
43 | | | my @files=grep /\.rrd/,readdir DIR; |
44 | | | closedir DIR; |
45 | | | |
46 | | | # generate diagrams |
47 | | | # |
48 | | | foreach 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 | | | } |
99 | | | exit 0; |
100 | | | |
101 | | | |