[mrtg] Target and its mapping to RRD

Niall O'Reilly Niall.oReilly at ucd.ie
Wed Jun 29 12:38:50 CEST 2011


On 28 Jun 2011, at 15:09, Daniele Sluijters wrote:

> Is it even possible to use such "complex" Target-lines with RRD as a backend?

	You'll have seen earlier replies.
	What you can display is limited only by your imagination and daring
	(or those qualities in the author of your display system).

	For historical reasons, we use a home-grown display system based on
	HTML::Mason.  Here's a fragment showing how client counts are
	aggregated over all our base stations.

	The result is the top graph at http://mrtg.ucd.ie/mrtg/wifi/.

<%perl>
  push @rrdargs,
    "$graph_path/aggregate$tag\+$width" . "x$height.png",  
    '--lazy', 
    '--interlaced',
    '--height', $height,
    '--width', $width,
    '--imginfo', $img_info,
    (($height > 60) ? ( ) : ( '--only-graph', '--color', 'CANVAS#ffffcc99' )),
    '--start', {'-week' => '-180h', '-month' => '-33d', '-year' => '-400d'}->{$tag} || '-30h';
  my $count = scalar(@$logs);
  if ($count > 0) {
    foreach my $f ( @$logs ) {
      push @rrdargs, sprintf("DEF:%s=%s:ds0:AVERAGE", $var++, $f);
    }
    for (my $i=0; $i++<$count;) {
      push @rrdargs, sprintf("CDEF:%s%05d=%s%05d,UN,0,%s%05d,IF",
                             'sam', $i, 'raw', $i, 'raw', $i);
    }
    for (my ($i, $j, $k) = ($count)x3; 1 < $i--; $j--) {
      push @rrdargs, sprintf("CDEF:%s%05d=%s%2\$05d,%s%05d,+",
                             'agg', $i, 'sam',
                             (($j == $k) ? 'sam' : 'agg'), $j);
    }
    for (my ($i, $j, $k) = ($count)x3; 1 < $i--; $j--) {
      if ($j == $k) {
        push @rrdargs,
        sprintf("CDEF:%s%05d=10,%s%2\$05d,GT,0,%3\$s%2\$05d,IF,10,%3\$s%05d,GT,%3\$s%4\$05d,0,IF,+",
                    'bsy', $i, 'sam', $j);
      }
      else {
        push @rrdargs, 
        sprintf("CDEF:%s%05d=10,%s%2\$05d,GT,0,%3\$s%2\$05d,IF,%1\$s%05d,+",
                'bsy', $i, 'sam', $j);
      }
    }
    push @rrdargs,
      'LINE:agg00001#0000a0:' . rrdgraph_legend_escape('Reported wireless associations: all APs');
    push @rrdargs,
      'AREA:bsy00001#00a000:' . rrdgraph_legend_escape('Reported wireless associations: busy APs');
  
    my ($text, $hsize, $vsize) = RRDs::graph(@rrdargs);
    if (defined $text) {
</%perl>



More information about the mrtg mailing list