1 | 1 | simandl | #!/usr/bin/env perl |
2 | | | |
3 | | | # $Id: diagrams.pl,v 1.18 2004/05/26 18:09:43 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.18 $') =~ s/.*(\d+\.\d+).*/$1/; |
18 | | | (my $IDENTIFIER = '$Id: diagrams.pl,v 1.18 2004/05/26 18:09:43 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 | | | my $LEGEND="bytes"; |
37 | | | |
38 | | | # common options |
39 | | | # |
40 | | | push @OPTIONS,( |
41 | | | "-v",$LEGEND, # Y-legend |
42 | | | "--alt-autoscale-max"); # alternate scaling |
43 | | | |
44 | | | # generate diagrams |
45 | | | # |
46 | | | foreach my $entry (@{$MODULECONFIG{DRIVE}}) { |
47 | | | my (undef,undef,undef,$DB_FILE,$name,$file,$description)=HotSaNICmod::common::get_names($entry); |
48 | | | |
49 | | | if (%PLOT) { next if ! defined $PLOT{$name}; } |
50 | | | |
51 | | | $DB_FILE="./rrd/$DB_FILE.rrd"; |
52 | | | |
53 | | | # if database exists, create images... |
54 | | | if ( -e $DB_FILE) { |
55 | | | |
56 | | | print "creating images for $name ($description) ...\n"; |
57 | | | foreach my $range ("1h","6h","1day","1week","1month","1year") { |
58 | | | my ($timelong,$time,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
59 | | | |
60 | | | my $legends="min avg max"; |
61 | | | if ($range eq "1h") { $legends="min avg max cur"; } |
62 | | | |
63 | | | my @EXTOPTIONS=("-s","-$fullrange", "--title", "free space on $name - last $timelong ($DATESTRING)"); |
64 | | | my @COMMANDS=("DEF:max=$DB_FILE:max:MAX", |
65 | | | "DEF:used=$DB_FILE:used:AVERAGE", |
66 | | | "DEF:maxused=$DB_FILE:used:MAX", |
67 | | | "DEF:minused=$DB_FILE:used:MIN", |
68 | | | "CDEF:free=max,used,-", |
69 | | | "CDEF:minfree=max,maxused,-", |
70 | | | "CDEF:maxfree=max,minused,-", |
71 | | | "CDEF:minmax=maxused,minused,-", |
72 | | | HotSaNICdiagram::insert_data("AREA","max minfree free maxfree free" ,$MODULECONFIG{COLOR_FREE},"free",$legends,$LEGEND,1), |
73 | | | "AREA:maxused#".$MODULECONFIG{COLOR_CHANGE}.":", |
74 | | | HotSaNICdiagram::insert_data("AREA","minused minused used maxused used",$MODULECONFIG{COLOR_USED},"used",$legends,$LEGEND,1), |
75 | | | HotSaNICdiagram::insert_lines(%MODULECONFIG)); |
76 | | | |
77 | | | my %CONF=(RANGE=>$timelong,FILENAME=>"$OUTDIR/$file-$time",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME); |
78 | | | HotSaNICdiagram::graph(%CONF); |
79 | | | } |
80 | | | } |
81 | | | else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; } |
82 | | | print "\n"; |
83 | | | } |
84 | | | exit 0; |
85 | | | |