[Orca-dev] another new feature

Alex Howansky alex at wankwood.com
Wed Sep 6 12:26:21 PDT 2000


-------------------------- eGroups Sponsor -------------------------~-~>
GET A NEXTCARD VISA, in 30 seconds!  Get rates
of 2.9% Intro or 9.9% Ongoing APR* and no annual fee!
Apply NOW!
http://click.egroups.com/1/9146/11/_/576655/_/968268442/
---------------------------------------------------------------------_->


Attached are three small patches for orca, Config.pm, and ImageFile.pm. They
add the ability to specify a formatting string for the summary values at the
bottom of the graph. For example, previously, a graph might have looked
something like:

Things  Current:    4.2 k  Average:    3.9 k  Min:    0.1 k  Max:   19.1 k

All the numbers were formatted with a hard-coded "%9.3lf %s". By using the
summary_format option in the plot section of the config file, you can specify
this:

plot {
source things
data things
summary_format %.0lf
}

which would cause the summary to look like this:

Things  Current: 4213  Average: 3931  Min: 142  Max: 19103

The same format is used for each number within a single summary line, but you
can specify multiple summary_format options if there are multiple plots on the
graph:

plot {
source things
data things
data other
summary_format %.0lf
summary_format %4.1f%s
color 0000ff
color ff0000
}

Including the %s in the format string will cause RRDTool to auto-scale the
value and add the appropriate "k" or "M" or whatever.

-- 
Alex Howansky
Wankwood Associates
http://www.wankwood.com/


-------------- next part --------------
*** orca.old	Wed Sep  6 10:14:13 2000
--- orca	Wed Sep  6 13:37:35 2000
***************
*** 1896,1901 ****
--- 1896,1906 ----
  The B<legend> option specifies for a single data source the comment
  that is placed below the PNG plot.
  
+ =item B<summary_format> I<format>
+ 
+ The B<summary_format> option specifies the format for the summary values,
+ as passed to the RRDTool GPRINT function. The default is %9.3lf %s.
+ 
  =back
  
  =head1 IMPLEMENTATION NOTES
-------------- next part --------------
*** Config.pm.old	Tue Sep  5 13:53:31 2000
--- Config.pm	Wed Sep  6 13:37:49 2000
***************
*** 76,87 ****
                                      required
                                      rigid_min_max
                                      source
                                      title
                                      y_legend);
  my @pcl_plot_append_elements   = qw(color
                                      data
                                      legend
!                                     line_type);
  my @pcl_filepath_elements      = qw(find_files
                                      html_dir
                                      rrd_dir
--- 76,89 ----
                                      required
                                      rigid_min_max
                                      source
+                                     summary_format
                                      title
                                      y_legend);
  my @pcl_plot_append_elements   = qw(color
                                      data
                                      legend
!                                     line_type
!                                     summary_format);
  my @pcl_filepath_elements      = qw(find_files
                                      html_dir
                                      rrd_dir
***************
*** 464,469 ****
--- 466,478 ----
          $plot->{line_type}[$k] = $line_type;
        } else {
          $plot->{line_type}[$k] = 'LINE1';
+       }
+     }
+ 
+     # If the format is not set, use a safe default.
+     for (my $k=0; $k<$number_datas; ++$k) {
+       unless (defined $plot->{summary_format}[$k]) {
+         $plot->{summary_format}[$k] = '%9.3lf %s';
        }
      }
  
-------------- next part --------------
*** ImageFile.pm.old	Wed Sep  6 13:05:07 2000
--- ImageFile.pm	Wed Sep  6 13:24:48 2000
***************
*** 190,199 ****
    for (my $i=0; $i<$data_sources; ++$i) {
      my $legend = $legends[$i];
      $legend   .= ' ' x ($max_legend_length - length($legend));
!     push(@options, "GPRINT:average$i:LAST:$legend  Current\\: %9.3lf %S",
!                    "GPRINT:average$i:AVERAGE:Average\\: %9.3lf %S",
!                    "GPRINT:average$i:MIN:Min\\: %9.3lf %S",
!                    "GPRINT:average$i:MAX:Max\\: %9.3lf %S\\l"
          );
    }
  
--- 190,204 ----
    for (my $i=0; $i<$data_sources; ++$i) {
      my $legend = $legends[$i];
      $legend   .= ' ' x ($max_legend_length - length($legend));
!     push(@options, "GPRINT:average$i:LAST:$legend  Current\\: " .
!                    $plot_ref->{summary_format}[$i],
!                    "GPRINT:average$i:AVERAGE:Average\\: " .
!                    $plot_ref->{summary_format}[$i],
!                    "GPRINT:average$i:MIN:Min\\: " .
!                    $plot_ref->{summary_format}[$i],
!                    "GPRINT:average$i:MAX:Max\\: " .
!                    $plot_ref->{summary_format}[$i] .
!                    "\\l"
          );
    }
  


More information about the Orca-dev mailing list