[Orca-dev] Patch: possible fix for multiple 'volatile' data graphs in orcallator
John Garner
jcgarner at douglas.co.us
Wed Apr 30 16:05:43 PDT 2003
All,
I've seen some discussions regarding multiple filesystem and disk plots
from orcallator whenever new disks or filesystems are added or removed.
Due to the way that orca keeps track of things (with the data source
field name used directly in the resulting file), it appeared to be a
problem that was still persistent. (I still had the problem with version
220 out of the svn repository, and thanks to our the nightly vxfs
snapshots, it got really ugly for me)
After lots of traces and work to try and understand what i was getting
myself into, I made a few mods to lib/Orca/Config.pm,
lib/Orca/ImageFile.pm and lib/Orca/SourceFile.pm in an attempt to fix
the problem.
In the end, what i did was add a new param to a plot, volatile, that
tells orca that this particular plot will have data sources come and go
on a whim. Once orca sees this flag, it will treat that plot slightly
differently in terms of how it looks up the plot and keeps track of what
data is in the plot. It uses the value of the flag in place of the data
source names for the purpose of file names. Thus, the disk_runp plot
would look like this:
plot {
title %g Disk Run Percent
source orcallator
data
disk_runp_((?:c\d+t\d+d\d+)|(?:c\d+d\d+)|(?:[ms]d\d+)|(?:c\d+t([A-Z0-9]{32})d\d+))
line_type line2
legend $1
y_legend Run Percent
data_min 0
data_max 100
plot_min 0
volatile disk_runphttp://www.yahoo.com/
href
http://www.orcaware.com/orca/docs/orcallator.html#disk_run_percent
}
I've been running with these patches for about a month or so now, and
have not seen any ill effects other than the fact that once a filesystem
or disk is seen, it will always be in the plots (i'll take suggestions
on how to tell rrd to not plot things that it does not have enough data for)
If anybody has any comments or if i missed something (or need to re-read
the hacking file), please let me know.
thanks,
John Garner
System Administrator
Douglas County Government
Castle Rock, CO 80104
jcgarner at douglas.co.us
#> svn diff
Index: lib/Orca/Config.pm
===================================================================
--- lib/Orca/Config.pm (revision 220)
+++ lib/Orca/Config.pm (working copy)
@@ -107,7 +107,8 @@
source => 1,
summary_format => 1,
title => 1,
- y_legend => 1);
+ y_legend => 1,
+ volatile => 1);
# %pcl_group_append_elements and %pcl_plot_append_elements define
# those parameters that generate a list of values and every appearance
@@ -136,7 +137,8 @@
my %pcl_no_arg_elements = (flush_regexps => 1,
logarithmic => 1,
required => 1,
- rigid_min_max => 1);
+ rigid_min_max => 1,
+ volatile => 1);
# These are a list of parameters that keep all of the arguments to the
# parameter, not just the first one. Internally, the parameter value
@@ -182,7 +184,8 @@
href
late_interval
plot_width
- plot_height);
+ plot_height
+ volatile);
# These parameters are set to true if they do not appear in the
# configuration file.
Index: lib/Orca/SourceFile.pm
===================================================================
--- lib/Orca/SourceFile.pm (revision 220)
+++ lib/Orca/SourceFile.pm (working copy)
@@ -710,8 +710,23 @@
# Generate a new plot for these data.
my $image;
- my $all_names_with_subgroup = join(',', @name_with_subgroup);
+ my $plot_volatile="";
+ my $all_names_with_subgroup = join(',', sort @name_with_subgroup);
+
+ unless( "$plot->{volatile}" eq "" ) {
+ $all_names_with_subgroup = "${group_name}_${subgroup_name}_" .
lc($plot->{data_type}[0]) . "_" . $plot->{volatile};
+ $plot_volatile=$all_names_with_subgroup;
+ }
+
if (defined ($image =
$image_files_ref->{hash}{$all_names_with_subgroup})){+
+ # we have a volatile plot, so we should sync the two before we
+ # update the rrds (chances are that we made mods to a copy above.
+ # Or we didnt get the right one since the columns changed on us )
+ unless( "$plot->{volatile}" eq "" ) {
+ $image->update_plot($plot);
+ }
+
$image->add_rrds(@my_rrds);
} else {
$image = Orca::ImageFile->new($group_index,
@@ -720,7 +735,8 @@
join(',', @name_without_subgroup),
$plot,
$rrd_data_files_ref,
- \@my_rrds);
+ \@my_rrds,
+ $plot_volatile);
$image_files_ref->{hash}{$all_names_with_subgroup} = $image;
push(@{$image_files_ref->{list}}, $image);
push(@{$config_plots[$old_i]{creates}}, $image);
Index: lib/Orca/ImageFile.pm
===================================================================
--- lib/Orca/ImageFile.pm (revision 220)
+++ lib/Orca/ImageFile.pm (working copy)
@@ -45,7 +45,7 @@
sub I_PLOT_LEGEND_BASE () { I_PLOT_AGE_BASE + @IMAGE_PLOT_TYPES }
sub new {
- unless (@_ == 8) {
+ unless (@_ == 9) {
confess "$0: Orca::ImageFile::new $INCORRECT_NUMBER_OF_ARGS";
}
@@ -56,7 +56,8 @@
$no_subgroup_name,
$plot_ref,
$rrd_data_files_ref,
- $my_rrds_ref) = @_;
+ $my_rrds_ref,
+ $plot_volatile) = @_;
unless (@$my_rrds_ref) {
confess "$0: Orca::ImageFile::new passed empty \@rrds_ref
reference.\n";
@@ -73,7 +74,14 @@
if ($config_global{expire_images}) {
$max_length += 5;
}
- $name = name_to_fsname($name, $max_length);
+
+ # if the plot is 'volatile', then we use a shorter name to avoid the
+ # fact that it is always changing.
+ if ($plot_volatile eq "" ) {
+ $name = name_to_fsname($name, $max_length);
+ } else {
+ $name = name_to_fsname($plot_volatile, $max_length);
+ }
# Create the paths to the html directory and subdirectories.
my $html_dir = "$config_global{html_dir}/$subgroup_name";
@@ -217,6 +225,34 @@
$self->_update_graph_options;
}
+sub update_plot {
+
+ # lets merge the new volatile plot that we just found/created with
+ # the one that we already have so that everything matches.
+ my $self = shift;
+ my %exist_legend;
+ my $new_plot_ref=$_[0];
+ my $exist_plot_ref=$self->[I_PLOT_REF];
+ my $i;
+
+ for ($i=0; $i<@{$exist_plot_ref->{legend}}; $i++) {
+ $exist_legend{$exist_plot_ref->{legend}[$i]} = 1;
+ }
+
+ # $i should already be set to the number of elements, but i'm
paranoid....
+ $i= @{$exist_plot_ref->{legend}};
+ for (my $k=0; $k < @{$new_plot_ref->{legend}}; $k++) {
+ unless ( defined( $exist_legend{$new_plot_ref->{legend}[$k]} ) ) {
+ # there may be more attributes, but these are the ones that
seem to matter
+ $exist_plot_ref->{legend}[$i] = $new_plot_ref->{legend}[$k];
+ $exist_plot_ref->{line_type}[$i] =
$new_plot_ref->{line_type}[$k];
+ $exist_plot_ref->{color}[$i] = $new_plot_ref->{color}[$k];
+ $exist_plot_ref->{summary_format}[$i] =
$new_plot_ref->{summary_format}[$k];
+ $i++;
+ }
+ }
+}
+
sub image_width {
$_[0]->[I_IMAGE_WIDTH];
}
More information about the Orca-dev
mailing list