jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.18 2004/05/27 21:45:20 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.18 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.18 2004/05/27 21:45:20 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#
36# delete upper & lower border configuration
37# these will be set separately for each graph
38#
39my $old="";
40my @newoptions=();
41foreach (@OPTIONS) {
42 my $ignore=0;
43 if ( ($_ eq "-u") or ($old eq "-u") ) { $ignore=1; }
44 if ( ($_ eq "-l") or ($old eq "-l") ) { $ignore=1; }
45 $old=$_;
46 push @newoptions,$_ unless $ignore == 1;
47 }
48@OPTIONS=@newoptions;
49 
50# generate diagrams
51#
52foreach my $entry (@{$MODULECONFIG{SENSOR}}) {
53 my (undef,undef,undef,$DB_FILE,$name,$file,$description,undef,undef,undef,$LEGEND,$MIN,$MAX)=HotSaNICmod::common::get_names($entry);
54 
55 if (%PLOT) { next if ! defined $PLOT{$name}; }
56 
57 $DB_FILE="./rrd/$DB_FILE.rrd";
58 
59# if database exists, create images...
60 if ( -e $DB_FILE) {
61 
62 print "creating images for $name ($description) ...\n";
63 foreach my $range ("1h","6h","1day","1week","1month","1year") {
64 my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
65 
66 my @EXTOPTIONS=("-v",$LEGEND, "-s","-$range", "--title", "$description - last $timelong ($DATESTRING)", "-u", $MAX);
67 my @COMMANDS;
68 
69 if ($range eq "1h") {
70 push @EXTOPTIONS,("-l", 0, "--alt-autoscale-max");
71 @COMMANDS=("DEF:avg=$DB_FILE:data:AVERAGE",
72 "AREA:avg#".$MODULECONFIG{COLOR_AREA}.":",
73 HotSaNICdiagram::insert_data("LINE1","avg",$MODULECONFIG{COLOR_LINE}," ","min avg max cur",$LEGEND,1));
74 }
75 else {
76 push @EXTOPTIONS,("-l", $MIN, "--alt-autoscale", "--alt-y-grid");
77 @COMMANDS=("DEF:avg=$DB_FILE:data:AVERAGE",
78 "DEF:max=$DB_FILE:data:MAX",
79 "DEF:min=$DB_FILE:data:MIN",
80 HotSaNICdiagram::insert_minmax("min max",$MODULECONFIG{COLOR_MINMAX},$MODULECONFIG{COLOR_BORDER},"min/max",$LEGEND,1),
81 HotSaNICdiagram::insert_data("LINE2","avg" ,$MODULECONFIG{COLOR_LINE} ,"average","min avg max",$LEGEND,1));
82 }
83 if (defined $MIN) {
84 push @COMMANDS,"HRULE:$MIN#".$MODULECONFIG{COLOR_LINE_ALARM_MIN}.":Warning threshold\\: $MIN $LEGEND";
85 if (defined $MAX) {
86 push @COMMANDS,("HRULE:$MAX#".$MODULECONFIG{COLOR_LINE_ALARM_MAX}.":",
87 "COMMENT:/ $MAX $LEGEND");
88 }
89 }
90 elsif (defined $MAX) {
91 push @COMMANDS,"HRULE:$MAX#".$MODULECONFIG{COLOR_LINE_ALARM_MAX}.":Warning threshold\\: $MAX $LEGEND";
92 }
93 push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
94 
95 my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
96 HotSaNICdiagram::graph(%CONF);
97 }
98 }
99 else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; }
100 print "\n";
101 }
102exit 0;
103 

Powered by WebSVN 2.2.1