Code

Merge remote-tracking branch 'github/pr/387'
[collectd.git] / contrib / collection.cgi
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Carp (qw(cluck confess));
7 use CGI (':cgi');
8 use CGI::Carp ('fatalsToBrowser');
9 use HTML::Entities ('encode_entities');
10 use URI::Escape ('uri_escape');
11 use RRDs ();
12 use Data::Dumper ();
14 our $Config = "/etc/collection.conf";
15 our @DataDirs = ();
16 our @DontShowTypes = ();
17 our $LibDir;
19 our $ValidTimespan =
20 {
21   hour => 3600,
22   day => 86400,
23   week => 7 * 86400,
24   month => 31 * 86400,
25   year => 366 * 86400
26 };
28 our @RRDDefaultArgs = ('-w', '400');
30 our $Args = {};
32 our $GraphDefs;
33 our $MetaGraphDefs = {};
34 load_graph_definitions ();
36 for (qw(action host plugin plugin_instance type type_instance timespan))
37 {
38         $Args->{$_} = param ($_);
39 }
41 exit (main ());
43 sub read_config
44 {
45         my $fh;
46         open ($fh, "< $Config") or confess ("open ($Config): $!");
47         while (my $line = <$fh>)
48         {
49                 chomp ($line);
50                 next if (!$line);
51                 next if ($line =~ m/^\s*#/);
52                 next if ($line =~ m/^\s*$/);
54                 my $key;
55                 my $value;
57                 if ($line =~ m/^([A-Za-z]+):\s*"((?:[^"\\]+|\\.)*)"$/)
58                 {
59                         $key = lc ($1); $value = $2;
60                         $value =~ s/\\(.)/$1/g;
61                 }
62                 elsif ($line =~ m/([A-Za-z]+):\s*([0-9]+)$/)
63                 {
64                         $key = lc ($1); $value = 0 + $2;
65                 }
66                 else
67                 {
68                         print STDERR "Cannot parse line: $line\n";
69                         next;
70                 }
72                 if ($key eq 'datadir')
73                 {
74                         $value =~ s#/*$##;
75                         push (@DataDirs, $value);
76                 }
77                 elsif ($key eq 'libdir')
78                 {
79                         $value =~ s#/*$##;
80                         $LibDir = $value;
81                 }
82                 elsif ($key eq 'dontshowtype')
83                 {
84                   push (@DontShowTypes, $value);
85                 }
86                 else
87                 {
88                         print STDERR "Unknown key: $key\n";
89                 }
90         }
91         close ($fh);
92 } # read_config
94 sub validate_args
95 {
96         if ($Args->{'action'} && ($Args->{'action'} =~ m/^(overview|show_host|show_plugin|show_type|show_graph)$/))
97         {
98                 $Args->{'action'} = $1;
99         }
100         else
101         {
102                 $Args->{'action'} = 'overview';
103         }
105         if ($Args->{'host'} && ($Args->{'host'} =~ m#/#))
106         {
107                 delete ($Args->{'host'});
108         }
110         if ($Args->{'plugin'} && ($Args->{'plugin'} =~ m#/#))
111         {
112                 delete ($Args->{'plugin'});
113         }
115         if ($Args->{'type'} && ($Args->{'type'} =~ m#/#))
116         {
117                 delete ($Args->{'type'});
118         }
120         if (!$Args->{'plugin'} || ($Args->{'plugin_instance'}
121                 && ($Args->{'plugin_instance'} =~ m#/#)))
122         {
123                 delete ($Args->{'plugin_instance'});
124         }
126         if (!$Args->{'type'} || ($Args->{'type_instance'}
127                 && ($Args->{'type_instance'} =~ m#/#)))
128         {
129                 delete ($Args->{'type_instance'});
130         }
132         if (defined ($Args->{'timespan'})
133           && ($Args->{'timespan'} =~ m/^(hour|day|week|month|year)$/))
134         {
135           $Args->{'timespan'} = $1;
136         }
137         else
138         {
139           $Args->{'timespan'} = 'day';
140         }
141 } # validate_args
144   my $hosts;
145   sub _find_hosts
146   {
147     if (defined ($hosts))
148     {
149       return (keys %$hosts);
150     }
152     $hosts = {};
154     for (my $i = 0; $i < @DataDirs; $i++)
155     {
156       my @tmp;
157       my $dh;
159       opendir ($dh, $DataDirs[$i]) or next;
160       @tmp = grep { ($_ !~ m/^\./) && (-d $DataDirs[$i] . '/' . $_) } (readdir ($dh));
161       closedir ($dh);
163       $hosts->{$_} = 1 for (@tmp);
164     } # for (@DataDirs)
166     return (keys %$hosts);
167   } # _find_hosts
170 sub _get_param_host
172   my %all_hosts = map { $_ => 1 } (_find_hosts ());
173   my @selected_hosts = ();
174   for (param ('host'))
175   {
176     if (defined ($all_hosts{$_}))
177     {
178       push (@selected_hosts, "$_");
179     }
180   }
181   return (@selected_hosts);
182 } # _get_param_host
184 sub _get_param_timespan
186   my $timespan = param ('timespan');
188   $timespan ||= 'day';
189   $timespan = lc ($timespan);
191   if (!defined ($ValidTimespan->{$timespan}))
192   {
193     $timespan = 'day';
194   }
196   return ($timespan);
197 } # _get_param_timespan
199 sub _find_plugins
201   my $host = shift;
202   my %plugins = ();
204   for (my $i = 0; $i < @DataDirs; $i++)
205   {
206     my $dir = $DataDirs[$i] . "/$host";
207     my @tmp;
208     my $dh;
210     opendir ($dh, $dir) or next;
211     @tmp = grep { ($_ !~ m/^\./) && (-d "$dir/$_") } (readdir ($dh));
212     closedir ($dh);
214     for (@tmp)
215     {
216       my ($plugin, $instance) = split (m/-/, $_, 2);
217       $plugins{$plugin} = [] if (!exists $plugins{$plugin});
218       push (@{$plugins{$plugin}}, $instance);
219     }
220   } # for (@DataDirs)
222   return (%plugins);
223 } # _find_plugins
225 sub _find_types
227   my $host = shift;
228   my $plugin = shift;
229   my $plugin_instance = shift;
230   my %types = ();
232   for (my $i = 0; $i < @DataDirs; $i++)
233   {
234     my $dir = $DataDirs[$i] . "/$host/$plugin" . (defined ($plugin_instance) ? "-$plugin_instance" : '');
235     my @tmp;
236     my $dh;
238     opendir ($dh, $dir) or next;
239     @tmp = grep { ($_ !~ m/^\./) && ($_ =~ m/\.rrd$/i) && (-f "$dir/$_") } (readdir ($dh));
240     closedir ($dh);
242     for (@tmp)
243     {
244       my $name = "$_";
245       $name =~ s/\.rrd$//i;
246       my ($type, $instance) = split (m/-/, $name, 2);
247       if (grep { $_ eq $type } @DontShowTypes) { next; }
248       $types{$type} = [] if (!$types{$type});
249       push (@{$types{$type}}, $instance) if (defined ($instance));
250     }
251   } # for (@DataDirs)
253   return (%types);
254 } # _find_types
256 sub _find_files_for_host
258   my $host = shift;
259   my $ret = {};
261   my %plugins = _find_plugins ($host);
262   for (keys %plugins)
263   {
264     my $plugin = $_;
265     my $plugin_instances = $plugins{$plugin};
267     if (!$plugin_instances || !@$plugin_instances)
268     {
269       $plugin_instances = ['-'];
270     }
272     $ret->{$plugin} = {};
274     for (@$plugin_instances)
275     {
276       my $plugin_instance = defined ($_) ? $_ : '-';
277       my %types = _find_types ($host, $plugin,
278         ($plugin_instance ne '-')
279         ? $plugin_instance
280         : undef);
282       $ret->{$plugin}{$plugin_instance} = {};
284       for (keys %types)
285       {
286         my $type = $_;
287         my $type_instances = $types{$type};
289         $ret->{$plugin}{$plugin_instance}{$type} = {};
291         for (@$type_instances)
292         {
293           $ret->{$plugin}{$plugin_instance}{$type}{$_} = 1;
294         }
296         if (!@$type_instances)
297         {
298           $ret->{$plugin}{$plugin_instance}{$type}{'-'} = 1;
299         }
300       } # for (keys %types)
301     } # for (@$plugin_instances)
302   } # for (keys %plugins)
304   return ($ret);
305 } # _find_files_for_host
307 sub _find_files_for_hosts
309   my @hosts = @_;
310   my $all_plugins = {};
312   for (my $i = 0; $i < @hosts; $i++)
313   {
314     my $tmp = _find_files_for_host ($hosts[$i]);
315     _files_union ($all_plugins, $tmp);
316   }
318   return ($all_plugins);
319 } # _find_files_for_hosts
321 sub _files_union
323   my $dest = shift;
324   my $src = shift;
326   for (keys %$src)
327   {
328     my $plugin = $_;
329     $dest->{$plugin} ||= {};
331     for (keys %{$src->{$plugin}})
332     {
333       my $pinst = $_;
334       $dest->{$plugin}{$pinst} ||= {};
336       for (keys %{$src->{$plugin}{$pinst}})
337       {
338         my $type = $_;
339         $dest->{$plugin}{$pinst}{$type} ||= {};
341         for (keys %{$src->{$plugin}{$pinst}{$type}})
342         {
343           my $tinst = $_;
344           $dest->{$plugin}{$pinst}{$type}{$tinst} = 1;
345         }
346       }
347     }
348   }
349 } # _files_union
351 sub _files_plugin_inst_count
353   my $src = shift;
354   my $i = 0;
356   for (keys %$src)
357   {
358     if (exists ($MetaGraphDefs->{$_}))
359     {
360       $i++;
361     }
362     else
363     {
364       $i = $i + keys %{$src->{$_}};
365     }
366   }
367   return ($i);
368 } # _files_plugin_count
370 sub list_hosts
372   my @hosts = _find_hosts ();
373   @hosts = sort (@hosts);
375   print "<ul>\n";
376   for (my $i = 0; $i < @hosts; $i++)
377   {
378     my $host_html = encode_entities ($hosts[$i]);
379     my $host_url = uri_escape ($hosts[$i]);
381     print qq(  <li><a href="${\script_name ()}?action=show_host;host=$host_url">$host_html</a></li>\n);
382   }
383   print "</ul>\n";
384 } # list_hosts
386 sub _string_to_color
388   my $color = shift;
389   if ($color =~ m/([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])/)
390   {
391     return ([hex ($1) / 255.0, hex ($2) / 255.0, hex ($3) / 255.0]);
392   }
393   return;
394 } # _string_to_color
396 sub _color_to_string
398   confess ("Wrong number of arguments") if (@_ != 1);
399   return (sprintf ('%02hx%02hx%02hx', map { int (255.0 * $_) } @{$_[0]}));
400 } # _color_to_string
402 sub _get_random_color
404   my ($r, $g, $b) = (rand (), rand ());
405   my $min = 0.0;
406   my $max = 1.0;
408   if (($r + $g) < 1.0)
409   {
410     $min = 1.0 - ($r + $g);
411   }
412   else
413   {
414     $max = 2.0 - ($r + $g);
415   }
417   $b = $min + (rand () * ($max - $min));
419   return ([$r, $g, $b]);
420 } # _get_random_color
422 sub _get_n_colors
424         my $instances = shift;
425         my $num = scalar @$instances;
426         my $ret = {};
428         for (my $i = 0; $i < $num; $i++)
429         {
430                 my $pos = 6 * $i / $num;
431                 my $n = int ($pos);
432                 my $p = $pos - $n;
433                 my $q = 1 - $p;
435                 my $red   = 0;
436                 my $green = 0;
437                 my $blue  = 0;
439                 my $color;
441                 if ($n == 0)
442                 {
443                         $red  = 255;
444                         $blue = 255 * $p;
445                 }
446                 elsif ($n == 1)
447                 {
448                         $red  = 255 * $q;
449                         $blue = 255;
450                 }
451                 elsif ($n == 2)
452                 {
453                         $green = 255 * $p;
454                         $blue  = 255;
455                 }
456                 elsif ($n == 3)
457                 {
458                         $green = 255;
459                         $blue  = 255 * $q;
460                 }
461                 elsif ($n == 4)
462                 {
463                         $red   = 255 * $p;
464                         $green = 255;
465                 }
466                 elsif ($n == 5)
467                 {
468                         $red   = 255;
469                         $green = 255 * $q;
470                 }
471                 else { die; }
473                 $color = sprintf ("%02x%02x%02x", $red, $green, $blue);
474                 $ret->{$instances->[$i]} = $color;
475         }
477         return ($ret);
478 } # _get_n_colors
480 sub _get_faded_color
482   my $fg = shift;
483   my $bg;
484   my %opts = @_;
485   my $ret = [undef, undef, undef];
487   $opts{'background'} ||= [1.0, 1.0, 1.0];
488   $opts{'alpha'} ||= 0.25;
490   if (!ref ($opts{'background'}))
491   {
492     $opts{'background'} = _string_to_color ($opts{'background'})
493       or confess ("Cannot parse background color " . $opts{'background'});
494   }
495   $bg = $opts{'background'};
497   for (my $i = 0; $i < 3; $i++)
498   {
499     $ret->[$i] = ($opts{'alpha'} * $fg->[$i])
500        + ((1.0 - $opts{'alpha'}) * $bg->[$i]);
501   }
503   return ($ret);
504 } # _get_faded_color
506 sub _custom_sort_arrayref
508   my $array_ref = shift;
509   my $array_sort = shift;
511   my %elements = map { $_ => 1 } (@$array_ref);
512   splice (@$array_ref, 0);
514   for (@$array_sort)
515   {
516     next if (!exists ($elements{$_}));
517     push (@$array_ref, $_);
518     delete ($elements{$_});
519   }
520   push (@$array_ref, sort (keys %elements));
521 } # _custom_sort_arrayref
523 sub action_show_host
525   my @hosts = _get_param_host ();
526   @hosts = sort (@hosts);
528   my $timespan = _get_param_timespan ();
529   my $all_plugins = _find_files_for_hosts (@hosts);
531   my $url_prefix = script_name () . '?action=show_plugin'
532   . join ('', map { ';host=' . uri_escape ($_) } (@hosts))
533   . ';timespan=' . uri_escape ($timespan);
535   print qq(    <div><a href="${\script_name ()}?action=overview">Back to list of hosts</a></div>\n);
537   print "    <p>Available plugins:</p>\n"
538   . "    <ul>\n";
539   for (sort (keys %$all_plugins))
540   {
541     my $plugin = $_;
542     my $plugin_html = encode_entities ($plugin);
543     my $url_plugin = $url_prefix . ';plugin=' . uri_escape ($plugin);
544     print qq(      <li><a href="$url_plugin">$plugin_html</a></li>\n);
545   }
546   print "   </ul>\n";
547 } # action_show_host
549 sub action_show_plugin
551   my @hosts = _get_param_host ();
552   my $plugin = shift;
553   my $plugin_instance = shift;
554   my $timespan = _get_param_timespan ();
556   my $hosts_url = join (';', map { 'host=' . uri_escape ($_) } (@hosts));
557   my $url_prefix = script_name () . "?$hosts_url";
559   my $all_plugins = {};
560   my $plugins_per_host = {};
561   my $selected_plugins = {};
563   for (my $i = 0; $i < @hosts; $i++)
564   {
565     $plugins_per_host->{$hosts[$i]} = _find_files_for_host ($hosts[$i]);
566     _files_union ($all_plugins, $plugins_per_host->{$hosts[$i]});
567   }
569   for (param ('plugin'))
570   {
571     if (defined ($all_plugins->{$_}))
572     {
573       $selected_plugins->{$_} = 1;
574     }
575   }
577   print qq(    <div><a href="${\script_name ()}?action=show_host;$hosts_url">Back to list of plugins</a></div>\n);
579   # Print table header
580   print <<HTML;
581     <table class="graphs">
582       <tr>
583         <th>Plugins</th>
584 HTML
585   for (@hosts)
586   {
587     print "\t<th>", encode_entities ($_), "</th>\n";
588   }
589   print "      </tr>\n";
591   for (sort (keys %$selected_plugins))
592   {
593     my $plugin = $_;
594     my $plugin_html = encode_entities ($plugin);
595     my $plugin_url = "$url_prefix;plugin=" . uri_escape ($plugin);
596     my $all_pinst = $all_plugins->{$plugin};
598     for (sort (keys %$all_pinst))
599     {
600       my $pinst = $_;
601       my $pinst_html = '';
602       my $pinst_url = $plugin_url;
604       if ($pinst ne '-')
605       {
606         $pinst_html = encode_entities ($pinst);
607         $pinst_url .= ';plugin_instance=' . uri_escape ($pinst);
608       }
610       my $files_printed = 0;
611       my $files_num = _files_plugin_inst_count ($all_pinst->{$pinst});
612       if ($files_num < 1)
613       {
614         next;
615       }
616       my $rowspan = ($files_num == 1) ? '' : qq( rowspan="$files_num");
618       for (sort (keys %{$all_plugins->{$plugin}{$pinst}}))
619       {
620         my $type = $_;
621         my $type_html = encode_entities ($type);
622         my $type_url = "$pinst_url;type=" . uri_escape ($type);
624         if ($files_printed == 0)
625         {
626           my $title = $plugin_html;
627           if ($pinst ne '-')
628           {
629             $title .= " ($pinst_html)";
630           }
631           print "      <tr>\n";
632           print "\t<td$rowspan>$title</td>\n";
633         }
635         if (exists ($MetaGraphDefs->{$type}))
636         {
637           my $graph_url = script_name () . '?action=show_graph'
638           . ';plugin=' . uri_escape ($plugin)
639           . ';type=' . uri_escape ($type)
640           . ';timespan=' . uri_escape ($timespan);
641           if ($pinst ne '-')
642           {
643             $graph_url .= ';plugin_instance=' . uri_escape ($pinst);
644           }
646           if ($files_printed != 0)
647           {
648             print "      <tr>\n";
649           }
651           for (@hosts)
652           {
653             my $host = $_;
654             my $host_graph_url = $graph_url . ';host=' . uri_escape ($host);
656             print "\t<td>";
657             if (exists $plugins_per_host->{$host}{$plugin}{$pinst}{$type})
658             {
659               print qq(<img src="$host_graph_url" />);
660               #print encode_entities (qq(<img src="${\script_name ()}?action=show_graph;host=$host_esc;$param_plugin;$param_type;timespan=$timespan" />));
661             }
662             print "</td>\n";
663           } # for (my $k = 0; $k < @hosts; $k++)
665           print "      </tr>\n";
667           $files_printed++;
668           next; # pinst
669         } # if (exists ($MetaGraphDefs->{$type}))
671         for (sort (keys %{$all_plugins->{$plugin}{$pinst}{$type}}))
672         {
673           my $tinst = $_;
674           my $tinst_esc = encode_entities ($tinst);
675           my $graph_url = script_name () . '?action=show_graph'
676           . ';plugin=' . uri_escape ($plugin)
677           . ';type=' . uri_escape ($type)
678           . ';timespan=' . uri_escape ($timespan);
679           if ($pinst ne '-')
680           {
681             $graph_url .= ';plugin_instance=' . uri_escape ($pinst);
682           }
683           if ($tinst ne '-')
684           {
685             $graph_url .= ';type_instance=' . uri_escape ($tinst);
686           }
688           if ($files_printed != 0)
689           {
690             print "      <tr>\n";
691           }
693           for (my $k = 0; $k < @hosts; $k++)
694           {
695             my $host = $hosts[$k];
696             my $host_graph_url = $graph_url . ';host=' . uri_escape ($host);
698             print "\t<td>";
699             if ($plugins_per_host->{$host}{$plugin}{$pinst}{$type}{$tinst})
700             {
701               print qq(<img src="$host_graph_url" />);
702               #print encode_entities (qq(<img src="${\script_name ()}?action=show_graph;host=$host_esc;$param_plugin;$param_type;timespan=$timespan" />));
703             }
704             print "</td>\n";
705           } # for (my $k = 0; $k < @hosts; $k++)
707           print "      </tr>\n";
709           $files_printed++;
710         } # for ($tinst)
711       } # for ($type)
712     } # for ($pinst)
713   } # for ($plugin)
714   print "   </table>\n";
715 } # action_show_plugin
717 sub action_show_type
719   my $host = shift;
720   my $plugin = shift;
721   my $plugin_instance = shift;
722   my $type = shift;
723   my $type_instance = shift;
725   my $host_url = uri_escape ($host);
726   my $plugin_url = uri_escape ($plugin);
727   my $plugin_html = encode_entities ($plugin);
728   my $plugin_instance_url = defined ($plugin_instance) ? uri_escape ($plugin_instance) : undef;
729   my $type_url = uri_escape ($type);
730   my $type_instance_url = defined ($type_instance) ? uri_escape ($type_instance) : undef;
732   my $url_prefix = script_name () . "?action=show_plugin;host=$host_url;plugin=$plugin_url";
733   $url_prefix .= ";plugin_instance=$plugin_instance_url" if (defined ($plugin_instance));
735   print qq(    <div><a href="$url_prefix">Back to plugin &quot;$plugin_html&quot;</a></div>\n);
737   $url_prefix = script_name () . "?action=show_graph;host=$host_url;plugin=$plugin_url";
738   $url_prefix .= ";plugin_instance=$plugin_instance_url" if (defined ($plugin_instance));
739   $url_prefix .= ";type=$type_url";
740   $url_prefix .= ";type_instance=$type_instance_url" if (defined ($type_instance));
742   for (qw(hour day week month year))
743   {
744     my $timespan = $_;
746     print qq#  <div><img src="$url_prefix;timespan=$timespan" /></div>\n#;
747   }
748 } # action_show_type
750 sub action_show_graph
752   my $host = shift;
753   my $plugin = shift;
754   my $plugin_instance = shift;
755   my $type = shift;
756   my $type_instance = shift;
757   my @rrd_args;
758   my $title;
759   
760   my %times = (hour => -3600, day => -86400, week => 7 * -86400, month => 31 * -86400, year => 366 * -86400);
761   my $start_time = $times{$Args->{'timespan'}} || -86400;
763   #print STDERR Data::Dumper->Dump ([$Args], ['Args']);
765   # FIXME
766   if (exists ($MetaGraphDefs->{$type}))
767   {
768     my %types = _find_types ($host, $plugin, $plugin_instance);
769     return $MetaGraphDefs->{$type}->($host, $plugin, $plugin_instance, $type, $types{$type});
770   }
772   return if (!defined ($GraphDefs->{$type}));
773   @rrd_args = @{$GraphDefs->{$type}};
775   $title = "$host/$plugin" . (defined ($plugin_instance) ? "-$plugin_instance" : '')
776   . "/$type" . (defined ($type_instance) ? "-$type_instance" : '');
778   for (my $i = 0; $i < @DataDirs; $i++)
779   {
780     my $file = $DataDirs[$i] . "/$title.rrd";
781     next if (!-f $file);
783     $file =~ s/:/\\:/g;
784     s/{file}/$file/ for (@rrd_args);
786     RRDs::graph ('-', '-a', 'PNG', '-s', $start_time, '-t', $title, @RRDDefaultArgs, @rrd_args);
787     if (my $err = RRDs::error ())
788     {
789       die ("RRDs::graph: $err");
790     }
791   }
792 } # action_show_graph
794 sub print_selector
796   my @hosts = _find_hosts ();
797   @hosts = sort (@hosts);
799   my %selected_hosts = map { $_ => 1 } (_get_param_host ());
800   my $timespan_selected = _get_param_timespan ();
802   print <<HTML;
803     <form action="${\script_name ()}" method="get">
804       <fieldset>
805         <legend>Selector</legend>
806         <select name="host" multiple="multiple" size="10">
807 HTML
808   for (my $i = 0; $i < @hosts; $i++)
809   {
810     my $host = encode_entities ($hosts[$i]);
811     my $selected = defined ($selected_hosts{$hosts[$i]}) ? ' selected="selected"' : '';
812     print qq(\t  <option value="$host"$selected>$host</option>\n);
813   }
814   print "\t</select>\n";
816   if (keys %selected_hosts)
817   {
818     my $all_plugins = _find_files_for_hosts (keys %selected_hosts);
819     my %selected_plugins = map { $_ => 1 } (param ('plugin'));
821     print qq(\t<select name="plugin" multiple="multiple" size="10">\n);
822     for (sort (keys %$all_plugins))
823     {
824       my $plugin = $_;
825       my $plugin_html = encode_entities ($plugin);
826       my $selected = (defined ($selected_plugins{$plugin})
827         ? ' selected="selected"' : '');
828       print qq(\t  <option value="$plugin_html"$selected>$plugin</option>\n);
829     }
830     print "</select>\n";
831   } # if (keys %selected_hosts)
833   print qq(\t<select name="timespan">\n);
834   for (qw(Hour Day Week Month Year))
835   {
836     my $timespan_uc = $_;
837     my $timespan_lc = lc ($_);
838     my $selected = ($timespan_selected eq $timespan_lc)
839       ? ' selected="selected"' : '';
840     print qq(\t  <option value="$timespan_lc"$selected>$timespan_uc</option>\n);
841   }
842   print <<HTML;
843         </select>
844         <input type="submit" name="button" value="Ok" />
845       </fieldset>
846     </form>
847 HTML
850 sub print_header
852   print <<HEAD;
853 Content-Type: application/xhtml+xml; charset=utf-8
854 Cache-Control: no-cache
856 <?xml version="1.0" encoding="utf-8"?>
857 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
858   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
860 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
861   <head>
862     <title>collection.cgi, Version 2</title>
863     <style type="text/css">
864       img
865       {
866         border: none;
867       }
868       table.graphs
869       {
870         border-collapse: collapse;
871       }
872       table.graphs td,
873       table.graphs th
874       {
875         border: 1px solid black;
876         empty-cells: hide;
877       }
878     </style>
879   </head>
881   <body>
882 HEAD
883   print_selector ();
884 } # print_header
886 sub print_footer
888   print <<FOOT;
889   </body>
890 </html>
891 FOOT
892 } # print_footer
894 sub main
896         read_config ();
897         validate_args ();
899         if (defined ($Args->{'host'})
900           && defined ($Args->{'plugin'})
901           && defined ($Args->{'type'})
902           && ($Args->{'action'} eq 'show_graph'))
903         {
904           $| = 1;
905           print STDOUT header (-Content_Type => 'image/png');
906           action_show_graph ($Args->{'host'},
907             $Args->{'plugin'}, $Args->{'plugin_instance'},
908             $Args->{'type'}, $Args->{'type_instance'});
909           return (0);
910         }
912         print_header ();
914         if (!$Args->{'host'})
915         {
916           list_hosts ();
917         }
918         elsif (!$Args->{'plugin'})
919         {
920           action_show_host ($Args->{'host'});
921         }
922         elsif (!$Args->{'type'})
923         {
924           action_show_plugin ($Args->{'plugin'}, $Args->{'plugin_instance'});
925         }
926         else
927         {
928           action_show_type ($Args->{'host'},
929             $Args->{'plugin'}, $Args->{'plugin_instance'},
930             $Args->{'type'}, $Args->{'type_instance'});
931         }
933         print_footer ();
935         return (0);
938 sub load_graph_definitions
940   my $Canvas = 'FFFFFF';
942   my $FullRed    = 'FF0000';
943   my $FullGreen  = '00E000';
944   my $FullBlue   = '0000FF';
945   my $FullYellow = 'F0A000';
946   my $FullCyan   = '00A0FF';
947   my $FullMagenta= 'A000FF';
949   my $HalfRed    = 'F7B7B7';
950   my $HalfGreen  = 'B7EFB7';
951   my $HalfBlue   = 'B7B7F7';
952   my $HalfYellow = 'F3DFB7';
953   my $HalfCyan   = 'B7DFF7';
954   my $HalfMagenta= 'DFB7F7';
956   my $HalfBlueGreen = '89B3C9';
958   $GraphDefs =
959   {
960     apache_bytes => ['DEF:min_raw={file}:count:MIN',
961     'DEF:avg_raw={file}:count:AVERAGE',
962     'DEF:max_raw={file}:count:MAX',
963     'CDEF:min=min_raw,8,*',
964     'CDEF:avg=avg_raw,8,*',
965     'CDEF:max=max_raw,8,*',
966     'CDEF:mytime=avg_raw,TIME,TIME,IF',
967     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
968     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
969     'CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*',
970     'CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+',
971     "AREA:avg#$HalfBlue",
972     "LINE1:avg#$FullBlue:Bit/s",
973     'GPRINT:min:MIN:%5.1lf%s Min,',
974     'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
975     'GPRINT:max:MAX:%5.1lf%s Max,',
976     'GPRINT:avg:LAST:%5.1lf%s Last',
977     'GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
978     ],
979    apache_connections => ['DEF:min={file}:count:MIN',
980     'DEF:avg={file}:count:AVERAGE',
981     'DEF:max={file}:count:MAX',
982     "AREA:max#$HalfBlue",
983     "AREA:min#$Canvas",
984     "LINE1:avg#$FullBlue:Connections",
985     'GPRINT:min:MIN:%6.2lf Min,',
986     'GPRINT:avg:AVERAGE:%6.2lf Avg,',
987     'GPRINT:max:MAX:%6.2lf Max,',
988     'GPRINT:avg:LAST:%6.2lf Last'
989     ],
990     apache_idle_workers => ['DEF:min={file}:count:MIN',
991     'DEF:avg={file}:count:AVERAGE',
992     'DEF:max={file}:count:MAX',
993     "AREA:max#$HalfBlue",
994     "AREA:min#$Canvas",
995     "LINE1:avg#$FullBlue:Idle Workers",
996     'GPRINT:min:MIN:%6.2lf Min,',
997     'GPRINT:avg:AVERAGE:%6.2lf Avg,',
998     'GPRINT:max:MAX:%6.2lf Max,',
999     'GPRINT:avg:LAST:%6.2lf Last'
1000     ],
1001     apache_requests => ['DEF:min={file}:count:MIN',
1002     'DEF:avg={file}:count:AVERAGE',
1003     'DEF:max={file}:count:MAX',
1004     "AREA:max#$HalfBlue",
1005     "AREA:min#$Canvas",
1006     "LINE1:avg#$FullBlue:Requests/s",
1007     'GPRINT:min:MIN:%6.2lf Min,',
1008     'GPRINT:avg:AVERAGE:%6.2lf Avg,',
1009     'GPRINT:max:MAX:%6.2lf Max,',
1010     'GPRINT:avg:LAST:%6.2lf Last'
1011     ],
1012     apache_scoreboard => ['DEF:min={file}:count:MIN',
1013     'DEF:avg={file}:count:AVERAGE',
1014     'DEF:max={file}:count:MAX',
1015     "AREA:max#$HalfBlue",
1016     "AREA:min#$Canvas",
1017     "LINE1:avg#$FullBlue:Processes",
1018     'GPRINT:min:MIN:%6.2lf Min,',
1019     'GPRINT:avg:AVERAGE:%6.2lf Avg,',
1020     'GPRINT:max:MAX:%6.2lf Max,',
1021     'GPRINT:avg:LAST:%6.2lf Last'
1022     ],
1023     bitrate => ['-v', 'Bits/s',
1024     'DEF:avg={file}:value:AVERAGE',
1025     'DEF:min={file}:value:MIN',
1026     'DEF:max={file}:value:MAX',
1027     "AREA:max#$HalfBlue",
1028     "AREA:min#$Canvas",
1029     "LINE1:avg#$FullBlue:Bits/s",
1030     'GPRINT:min:MIN:%5.1lf%s Min,',
1031     'GPRINT:avg:AVERAGE:%5.1lf%s Average,',
1032     'GPRINT:max:MAX:%5.1lf%s Max,',
1033     'GPRINT:avg:LAST:%5.1lf%s Last\l'
1034     ],
1035     charge => ['-v', 'Ah',
1036     'DEF:avg={file}:value:AVERAGE',
1037     'DEF:min={file}:value:MIN',
1038     'DEF:max={file}:value:MAX',
1039     "AREA:max#$HalfBlue",
1040     "AREA:min#$Canvas",
1041     "LINE1:avg#$FullBlue:Charge",
1042     'GPRINT:min:MIN:%5.1lf%sAh Min,',
1043     'GPRINT:avg:AVERAGE:%5.1lf%sAh Avg,',
1044     'GPRINT:max:MAX:%5.1lf%sAh Max,',
1045     'GPRINT:avg:LAST:%5.1lf%sAh Last\l'
1046     ],
1047     connections => ['-v', 'Connections',
1048     'DEF:avg={file}:value:AVERAGE',
1049     'DEF:min={file}:value:MIN',
1050     'DEF:max={file}:value:MAX',
1051     "AREA:max#$HalfBlue",
1052     "AREA:min#$Canvas",
1053     "LINE1:avg#$FullBlue:Connections",
1054     'GPRINT:min:MIN:%4.1lf Min,',
1055     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1056     'GPRINT:max:MAX:%4.1lf Max,',
1057     'GPRINT:avg:LAST:%4.1lf Last\l'
1058     ],
1059     cpu => ['-v', 'CPU load',
1060     'DEF:avg={file}:value:AVERAGE',
1061     'DEF:min={file}:value:MIN',
1062     'DEF:max={file}:value:MAX',
1063     "AREA:max#$HalfBlue",
1064     "AREA:min#$Canvas",
1065     "LINE1:avg#$FullBlue:Percent",
1066     'GPRINT:min:MIN:%6.2lf%% Min,',
1067     'GPRINT:avg:AVERAGE:%6.2lf%% Avg,',
1068     'GPRINT:max:MAX:%6.2lf%% Max,',
1069     'GPRINT:avg:LAST:%6.2lf%% Last\l'
1070     ],
1071     current => ['-v', 'Ampere',
1072     'DEF:avg={file}:value:AVERAGE',
1073     'DEF:min={file}:value:MIN',
1074     'DEF:max={file}:value:MAX',
1075     "AREA:max#$HalfBlue",
1076     "AREA:min#$Canvas",
1077     "LINE1:avg#$FullBlue:Current",
1078     'GPRINT:min:MIN:%5.1lf%sA Min,',
1079     'GPRINT:avg:AVERAGE:%5.1lf%sA Avg,',
1080     'GPRINT:max:MAX:%5.1lf%sA Max,',
1081     'GPRINT:avg:LAST:%5.1lf%sA Last\l'
1082     ],
1083     df => ['-v', 'Percent', '-l', '0',
1084     'DEF:free_avg={file}:free:AVERAGE',
1085     'DEF:free_min={file}:free:MIN',
1086     'DEF:free_max={file}:free:MAX',
1087     'DEF:used_avg={file}:used:AVERAGE',
1088     'DEF:used_min={file}:used:MIN',
1089     'DEF:used_max={file}:used:MAX',
1090     'CDEF:total=free_avg,used_avg,+',
1091     'CDEF:free_pct=100,free_avg,*,total,/',
1092     'CDEF:used_pct=100,used_avg,*,total,/',
1093     'CDEF:free_acc=free_pct,used_pct,+',
1094     'CDEF:used_acc=used_pct',
1095     "AREA:free_acc#$HalfGreen",
1096     "AREA:used_acc#$HalfRed",
1097     "LINE1:free_acc#$FullGreen:Free",
1098     'GPRINT:free_min:MIN:%5.1lf%sB Min,',
1099     'GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,',
1100     'GPRINT:free_max:MAX:%5.1lf%sB Max,',
1101     'GPRINT:free_avg:LAST:%5.1lf%sB Last\l',
1102     "LINE1:used_acc#$FullRed:Used",
1103     'GPRINT:used_min:MIN:%5.1lf%sB Min,',
1104     'GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,',
1105     'GPRINT:used_max:MAX:%5.1lf%sB Max,',
1106     'GPRINT:used_avg:LAST:%5.1lf%sB Last\l'
1107     ],
1108     disk => [
1109     'DEF:rtime_avg={file}:rtime:AVERAGE',
1110     'DEF:rtime_min={file}:rtime:MIN',
1111     'DEF:rtime_max={file}:rtime:MAX',
1112     'DEF:wtime_avg={file}:wtime:AVERAGE',
1113     'DEF:wtime_min={file}:wtime:MIN',
1114     'DEF:wtime_max={file}:wtime:MAX',
1115     'CDEF:rtime_avg_ms=rtime_avg,1000,/',
1116     'CDEF:rtime_min_ms=rtime_min,1000,/',
1117     'CDEF:rtime_max_ms=rtime_max,1000,/',
1118     'CDEF:wtime_avg_ms=wtime_avg,1000,/',
1119     'CDEF:wtime_min_ms=wtime_min,1000,/',
1120     'CDEF:wtime_max_ms=wtime_max,1000,/',
1121     'CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+',
1122     'CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+',
1123     'CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+',
1124     "AREA:total_max_ms#$HalfRed",
1125     "AREA:total_min_ms#$Canvas",
1126     "LINE1:wtime_avg_ms#$FullGreen:Write",
1127     'GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,',
1128     'GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
1129     'GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,',
1130     'GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n',
1131     "LINE1:rtime_avg_ms#$FullBlue:Read ",
1132     'GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,',
1133     'GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
1134     'GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,',
1135     'GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n',
1136     "LINE1:total_avg_ms#$FullRed:Total",
1137     'GPRINT:total_min_ms:MIN:%5.1lf%s Min,',
1138     'GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,',
1139     'GPRINT:total_max_ms:MAX:%5.1lf%s Max,',
1140     'GPRINT:total_avg_ms:LAST:%5.1lf%s Last'
1141     ],
1142     disk_octets => ['-v', 'Bytes/s',
1143     'DEF:out_min={file}:write:MIN',
1144     'DEF:out_avg={file}:write:AVERAGE',
1145     'DEF:out_max={file}:write:MAX',
1146     'DEF:inc_min={file}:read:MIN',
1147     'DEF:inc_avg={file}:read:AVERAGE',
1148     'DEF:inc_max={file}:read:MAX',
1149     'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
1150     'CDEF:mytime=out_avg,TIME,TIME,IF',
1151     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1152     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1153     'CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*',
1154     'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
1155     'CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*',
1156     'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
1157     "AREA:out_avg#$HalfGreen",
1158     "AREA:inc_avg#$HalfBlue",
1159     "AREA:overlap#$HalfBlueGreen",
1160     "LINE1:out_avg#$FullGreen:Written",
1161     'GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,',
1162     'GPRINT:out_max:MAX:%5.1lf%s Max,',
1163     'GPRINT:out_avg:LAST:%5.1lf%s Last',
1164     'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
1165     "LINE1:inc_avg#$FullBlue:Read   ",
1166     'GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,',
1167     'GPRINT:inc_max:MAX:%5.1lf%s Max,',
1168     'GPRINT:inc_avg:LAST:%5.1lf%s Last',
1169     'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1170     ],
1171     disk_merged => ['-v', 'Merged Ops/s',
1172     'DEF:out_min={file}:write:MIN',
1173     'DEF:out_avg={file}:write:AVERAGE',
1174     'DEF:out_max={file}:write:MAX',
1175     'DEF:inc_min={file}:read:MIN',
1176     'DEF:inc_avg={file}:read:AVERAGE',
1177     'DEF:inc_max={file}:read:MAX',
1178     'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
1179     "AREA:out_avg#$HalfGreen",
1180     "AREA:inc_avg#$HalfBlue",
1181     "AREA:overlap#$HalfBlueGreen",
1182     "LINE1:out_avg#$FullGreen:Written",
1183     'GPRINT:out_avg:AVERAGE:%6.2lf Avg,',
1184     'GPRINT:out_max:MAX:%6.2lf Max,',
1185     'GPRINT:out_avg:LAST:%6.2lf Last\l',
1186     "LINE1:inc_avg#$FullBlue:Read   ",
1187     'GPRINT:inc_avg:AVERAGE:%6.2lf Avg,',
1188     'GPRINT:inc_max:MAX:%6.2lf Max,',
1189     'GPRINT:inc_avg:LAST:%6.2lf Last\l'
1190     ],
1191     disk_ops => ['-v', 'Ops/s',
1192     'DEF:out_min={file}:write:MIN',
1193     'DEF:out_avg={file}:write:AVERAGE',
1194     'DEF:out_max={file}:write:MAX',
1195     'DEF:inc_min={file}:read:MIN',
1196     'DEF:inc_avg={file}:read:AVERAGE',
1197     'DEF:inc_max={file}:read:MAX',
1198     'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
1199     "AREA:out_avg#$HalfGreen",
1200     "AREA:inc_avg#$HalfBlue",
1201     "AREA:overlap#$HalfBlueGreen",
1202     "LINE1:out_avg#$FullGreen:Written",
1203     'GPRINT:out_avg:AVERAGE:%6.2lf Avg,',
1204     'GPRINT:out_max:MAX:%6.2lf Max,',
1205     'GPRINT:out_avg:LAST:%6.2lf Last\l',
1206     "LINE1:inc_avg#$FullBlue:Read   ",
1207     'GPRINT:inc_avg:AVERAGE:%6.2lf Avg,',
1208     'GPRINT:inc_max:MAX:%6.2lf Max,',
1209     'GPRINT:inc_avg:LAST:%6.2lf Last\l'
1210     ],
1211     disk_time => ['-v', 'Seconds/s',
1212     'DEF:out_min_raw={file}:write:MIN',
1213     'DEF:out_avg_raw={file}:write:AVERAGE',
1214     'DEF:out_max_raw={file}:write:MAX',
1215     'DEF:inc_min_raw={file}:read:MIN',
1216     'DEF:inc_avg_raw={file}:read:AVERAGE',
1217     'DEF:inc_max_raw={file}:read:MAX',
1218     'CDEF:out_min=out_min_raw,1000,/',
1219     'CDEF:out_avg=out_avg_raw,1000,/',
1220     'CDEF:out_max=out_max_raw,1000,/',
1221     'CDEF:inc_min=inc_min_raw,1000,/',
1222     'CDEF:inc_avg=inc_avg_raw,1000,/',
1223     'CDEF:inc_max=inc_max_raw,1000,/',
1224     'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
1225     "AREA:out_avg#$HalfGreen",
1226     "AREA:inc_avg#$HalfBlue",
1227     "AREA:overlap#$HalfBlueGreen",
1228     "LINE1:out_avg#$FullGreen:Written",
1229     'GPRINT:out_avg:AVERAGE:%5.1lf%ss Avg,',
1230     'GPRINT:out_max:MAX:%5.1lf%ss Max,',
1231     'GPRINT:out_avg:LAST:%5.1lf%ss Last\l',
1232     "LINE1:inc_avg#$FullBlue:Read   ",
1233     'GPRINT:inc_avg:AVERAGE:%5.1lf%ss Avg,',
1234     'GPRINT:inc_max:MAX:%5.1lf%ss Max,',
1235     'GPRINT:inc_avg:LAST:%5.1lf%ss Last\l'
1236     ],
1237     dns_octets => ['DEF:rsp_min_raw={file}:responses:MIN',
1238     'DEF:rsp_avg_raw={file}:responses:AVERAGE',
1239     'DEF:rsp_max_raw={file}:responses:MAX',
1240     'DEF:qry_min_raw={file}:queries:MIN',
1241     'DEF:qry_avg_raw={file}:queries:AVERAGE',
1242     'DEF:qry_max_raw={file}:queries:MAX',
1243     'CDEF:rsp_min=rsp_min_raw,8,*',
1244     'CDEF:rsp_avg=rsp_avg_raw,8,*',
1245     'CDEF:rsp_max=rsp_max_raw,8,*',
1246     'CDEF:qry_min=qry_min_raw,8,*',
1247     'CDEF:qry_avg=qry_avg_raw,8,*',
1248     'CDEF:qry_max=qry_max_raw,8,*',
1249     'CDEF:overlap=rsp_avg,qry_avg,GT,qry_avg,rsp_avg,IF',
1250     'CDEF:mytime=rsp_avg_raw,TIME,TIME,IF',
1251     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1252     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1253     'CDEF:rsp_avg_sample=rsp_avg_raw,UN,0,rsp_avg_raw,IF,sample_len,*',
1254     'CDEF:rsp_avg_sum=PREV,UN,0,PREV,IF,rsp_avg_sample,+',
1255     'CDEF:qry_avg_sample=qry_avg_raw,UN,0,qry_avg_raw,IF,sample_len,*',
1256     'CDEF:qry_avg_sum=PREV,UN,0,PREV,IF,qry_avg_sample,+',
1257     "AREA:rsp_avg#$HalfGreen",
1258     "AREA:qry_avg#$HalfBlue",
1259     "AREA:overlap#$HalfBlueGreen",
1260     "LINE1:rsp_avg#$FullGreen:Responses",
1261     'GPRINT:rsp_avg:AVERAGE:%5.1lf%s Avg,',
1262     'GPRINT:rsp_max:MAX:%5.1lf%s Max,',
1263     'GPRINT:rsp_avg:LAST:%5.1lf%s Last',
1264     'GPRINT:rsp_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
1265     "LINE1:qry_avg#$FullBlue:Queries  ",
1266     #'GPRINT:qry_min:MIN:%5.1lf %s Min,',
1267     'GPRINT:qry_avg:AVERAGE:%5.1lf%s Avg,',
1268     'GPRINT:qry_max:MAX:%5.1lf%s Max,',
1269     'GPRINT:qry_avg:LAST:%5.1lf%s Last',
1270     'GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1271     ],
1272     dns_opcode => [
1273     'DEF:avg={file}:value:AVERAGE',
1274     'DEF:min={file}:value:MIN',
1275     'DEF:max={file}:value:MAX',
1276     "AREA:max#$HalfBlue",
1277     "AREA:min#$Canvas",
1278     "LINE1:avg#$FullBlue:Queries/s",
1279     'GPRINT:min:MIN:%9.3lf Min,',
1280     'GPRINT:avg:AVERAGE:%9.3lf Average,',
1281     'GPRINT:max:MAX:%9.3lf Max,',
1282     'GPRINT:avg:LAST:%9.3lf Last\l'
1283     ],
1284     email_count => ['-v', 'Mails',
1285     'DEF:avg={file}:value:AVERAGE',
1286     'DEF:min={file}:value:MIN',
1287     'DEF:max={file}:value:MAX',
1288     "AREA:max#$HalfMagenta",
1289     "AREA:min#$Canvas",
1290     "LINE1:avg#$FullMagenta:Count ",
1291     'GPRINT:min:MIN:%4.1lf Min,',
1292     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1293     'GPRINT:max:MAX:%4.1lf Max,',
1294     'GPRINT:avg:LAST:%4.1lf Last\l'
1295     ],
1296     email_size => ['-v', 'Bytes',
1297     'DEF:avg={file}:value:AVERAGE',
1298     'DEF:min={file}:value:MIN',
1299     'DEF:max={file}:value:MAX',
1300     "AREA:max#$HalfMagenta",
1301     "AREA:min#$Canvas",
1302     "LINE1:avg#$FullMagenta:Count ",
1303     'GPRINT:min:MIN:%4.1lf Min,',
1304     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1305     'GPRINT:max:MAX:%4.1lf Max,',
1306     'GPRINT:avg:LAST:%4.1lf Last\l'
1307     ],
1308     spam_score => ['-v', 'Score',
1309     'DEF:avg={file}:value:AVERAGE',
1310     'DEF:min={file}:value:MIN',
1311     'DEF:max={file}:value:MAX',
1312     "AREA:max#$HalfBlue",
1313     "AREA:min#$Canvas",
1314     "LINE1:avg#$FullBlue:Score ",
1315     'GPRINT:min:MIN:%4.1lf Min,',
1316     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1317     'GPRINT:max:MAX:%4.1lf Max,',
1318     'GPRINT:avg:LAST:%4.1lf Last\l'
1319     ],
1320     spam_check => [
1321     'DEF:avg={file}:value:AVERAGE',
1322     'DEF:min={file}:value:MIN',
1323     'DEF:max={file}:value:MAX',
1324     "AREA:max#$HalfMagenta",
1325     "AREA:min#$Canvas",
1326     "LINE1:avg#$FullMagenta:Count ",
1327     'GPRINT:min:MIN:%4.1lf Min,',
1328     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1329     'GPRINT:max:MAX:%4.1lf Max,',
1330     'GPRINT:avg:LAST:%4.1lf Last\l'
1331     ],
1332     conntrack => ['-v', 'Entries',
1333     'DEF:avg={file}:entropy:AVERAGE',
1334     'DEF:min={file}:entropy:MIN',
1335     'DEF:max={file}:entropy:MAX',
1336     "AREA:max#$HalfBlue",
1337     "AREA:min#$Canvas",
1338     "LINE1:avg#$FullBlue:Count",
1339     'GPRINT:min:MIN:%4.0lf Min,',
1340     'GPRINT:avg:AVERAGE:%4.0lf Avg,',
1341     'GPRINT:max:MAX:%4.0lf Max,',
1342     'GPRINT:avg:LAST:%4.0lf Last\l'
1343     ],
1344     entropy => ['-v', 'Bits',
1345     'DEF:avg={file}:entropy:AVERAGE',
1346     'DEF:min={file}:entropy:MIN',
1347     'DEF:max={file}:entropy:MAX',
1348     "AREA:max#$HalfBlue",
1349     "AREA:min#$Canvas",
1350     "LINE1:avg#$FullBlue:Bits",
1351     'GPRINT:min:MIN:%4.0lfbit Min,',
1352     'GPRINT:avg:AVERAGE:%4.0lfbit Avg,',
1353     'GPRINT:max:MAX:%4.0lfbit Max,',
1354     'GPRINT:avg:LAST:%4.0lfbit Last\l'
1355     ],
1356     fanspeed => ['-v', 'RPM',
1357     'DEF:avg={file}:value:AVERAGE',
1358     'DEF:min={file}:value:MIN',
1359     'DEF:max={file}:value:MAX',
1360     "AREA:max#$HalfMagenta",
1361     "AREA:min#$Canvas",
1362     "LINE1:avg#$FullMagenta:RPM",
1363     'GPRINT:min:MIN:%4.1lf Min,',
1364     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1365     'GPRINT:max:MAX:%4.1lf Max,',
1366     'GPRINT:avg:LAST:%4.1lf Last\l'
1367     ],
1368     frequency => ['-v', 'Hertz',
1369     'DEF:avg={file}:frequency:AVERAGE',
1370     'DEF:min={file}:frequency:MIN',
1371     'DEF:max={file}:frequency:MAX',
1372     "AREA:max#$HalfBlue",
1373     "AREA:min#$Canvas",
1374     "LINE1:avg#$FullBlue:Frequency [Hz]",
1375     'GPRINT:min:MIN:%4.1lf Min,',
1376     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1377     'GPRINT:max:MAX:%4.1lf Max,',
1378     'GPRINT:avg:LAST:%4.1lf Last\l'
1379     ],
1380     frequency_offset => [ # NTPd
1381     'DEF:ppm_avg={file}:ppm:AVERAGE',
1382     'DEF:ppm_min={file}:ppm:MIN',
1383     'DEF:ppm_max={file}:ppm:MAX',
1384     "AREA:ppm_max#$HalfBlue",
1385     "AREA:ppm_min#$Canvas",
1386     "LINE1:ppm_avg#$FullBlue:{inst}",
1387     'GPRINT:ppm_min:MIN:%5.2lf Min,',
1388     'GPRINT:ppm_avg:AVERAGE:%5.2lf Avg,',
1389     'GPRINT:ppm_max:MAX:%5.2lf Max,',
1390     'GPRINT:ppm_avg:LAST:%5.2lf Last'
1391     ],
1392     gauge => ['-v', 'Exec value',
1393     'DEF:temp_avg={file}:value:AVERAGE',
1394     'DEF:temp_min={file}:value:MIN',
1395     'DEF:temp_max={file}:value:MAX',
1396     "AREA:temp_max#$HalfBlue",
1397     "AREA:temp_min#$Canvas",
1398     "LINE1:temp_avg#$FullBlue:Exec value",
1399     'GPRINT:temp_min:MIN:%6.2lf Min,',
1400     'GPRINT:temp_avg:AVERAGE:%6.2lf Avg,',
1401     'GPRINT:temp_max:MAX:%6.2lf Max,',
1402     'GPRINT:temp_avg:LAST:%6.2lf Last\l'
1403     ],
1404     hddtemp => [
1405     'DEF:temp_avg={file}:value:AVERAGE',
1406     'DEF:temp_min={file}:value:MIN',
1407     'DEF:temp_max={file}:value:MAX',
1408     "AREA:temp_max#$HalfRed",
1409     "AREA:temp_min#$Canvas",
1410     "LINE1:temp_avg#$FullRed:Temperature",
1411     'GPRINT:temp_min:MIN:%4.1lf Min,',
1412     'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
1413     'GPRINT:temp_max:MAX:%4.1lf Max,',
1414     'GPRINT:temp_avg:LAST:%4.1lf Last\l'
1415     ],
1416     humidity => ['-v', 'Percent',
1417     'DEF:temp_avg={file}:value:AVERAGE',
1418     'DEF:temp_min={file}:value:MIN',
1419     'DEF:temp_max={file}:value:MAX',
1420     "AREA:temp_max#$HalfGreen",
1421     "AREA:temp_min#$Canvas",
1422     "LINE1:temp_avg#$FullGreen:Temperature",
1423     'GPRINT:temp_min:MIN:%4.1lf%% Min,',
1424     'GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,',
1425     'GPRINT:temp_max:MAX:%4.1lf%% Max,',
1426     'GPRINT:temp_avg:LAST:%4.1lf%% Last\l'
1427     ],
1428     if_errors => ['-v', 'Errors/s',
1429     'DEF:tx_min={file}:tx:MIN',
1430     'DEF:tx_avg={file}:tx:AVERAGE',
1431     'DEF:tx_max={file}:tx:MAX',
1432     'DEF:rx_min={file}:rx:MIN',
1433     'DEF:rx_avg={file}:rx:AVERAGE',
1434     'DEF:rx_max={file}:rx:MAX',
1435     'CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF',
1436     'CDEF:mytime=tx_avg,TIME,TIME,IF',
1437     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1438     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1439     'CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*',
1440     'CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+',
1441     'CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*',
1442     'CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+',
1443     "AREA:tx_avg#$HalfGreen",
1444     "AREA:rx_avg#$HalfBlue",
1445     "AREA:overlap#$HalfBlueGreen",
1446     "LINE1:tx_avg#$FullGreen:TX",
1447     'GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,',
1448     'GPRINT:tx_max:MAX:%5.1lf%s Max,',
1449     'GPRINT:tx_avg:LAST:%5.1lf%s Last',
1450     'GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)\l',
1451     "LINE1:rx_avg#$FullBlue:RX",
1452     #'GPRINT:rx_min:MIN:%5.1lf %s Min,',
1453     'GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,',
1454     'GPRINT:rx_max:MAX:%5.1lf%s Max,',
1455     'GPRINT:rx_avg:LAST:%5.1lf%s Last',
1456     'GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)\l'
1457     ],
1458     if_collisions => ['-v', 'Collisions/s',
1459     'DEF:min_raw={file}:value:MIN',
1460     'DEF:avg_raw={file}:value:AVERAGE',
1461     'DEF:max_raw={file}:value:MAX',
1462     'CDEF:min=min_raw,8,*',
1463     'CDEF:avg=avg_raw,8,*',
1464     'CDEF:max=max_raw,8,*',
1465     "AREA:max#$HalfBlue",
1466     "AREA:min#$Canvas",
1467     "LINE1:avg#$FullBlue:Collisions/s",
1468     'GPRINT:min:MIN:%5.1lf %s Min,',
1469     'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
1470     'GPRINT:max:MAX:%5.1lf%s Max,',
1471     'GPRINT:avg:LAST:%5.1lf%s Last\l'
1472     ],
1473     if_dropped => ['-v', 'Packets/s',
1474     'DEF:tx_min={file}:tx:MIN',
1475     'DEF:tx_avg={file}:tx:AVERAGE',
1476     'DEF:tx_max={file}:tx:MAX',
1477     'DEF:rx_min={file}:rx:MIN',
1478     'DEF:rx_avg={file}:rx:AVERAGE',
1479     'DEF:rx_max={file}:rx:MAX',
1480     'CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF',
1481     'CDEF:mytime=tx_avg,TIME,TIME,IF',
1482     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1483     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1484     'CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*',
1485     'CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+',
1486     'CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*',
1487     'CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+',
1488     "AREA:tx_avg#$HalfGreen",
1489     "AREA:rx_avg#$HalfBlue",
1490     "AREA:overlap#$HalfBlueGreen",
1491     "LINE1:tx_avg#$FullGreen:TX",
1492     'GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,',
1493     'GPRINT:tx_max:MAX:%5.1lf%s Max,',
1494     'GPRINT:tx_avg:LAST:%5.1lf%s Last',
1495     'GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)\l',
1496     "LINE1:rx_avg#$FullBlue:RX",
1497     #'GPRINT:rx_min:MIN:%5.1lf %s Min,',
1498     'GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,',
1499     'GPRINT:rx_max:MAX:%5.1lf%s Max,',
1500     'GPRINT:rx_avg:LAST:%5.1lf%s Last',
1501     'GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)\l'
1502     ],
1503     if_packets => ['-v', 'Packets/s',
1504     'DEF:tx_min={file}:tx:MIN',
1505     'DEF:tx_avg={file}:tx:AVERAGE',
1506     'DEF:tx_max={file}:tx:MAX',
1507     'DEF:rx_min={file}:rx:MIN',
1508     'DEF:rx_avg={file}:rx:AVERAGE',
1509     'DEF:rx_max={file}:rx:MAX',
1510     'CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF',
1511     'CDEF:mytime=tx_avg,TIME,TIME,IF',
1512     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1513     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1514     'CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*',
1515     'CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+',
1516     'CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*',
1517     'CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+',
1518     "AREA:tx_avg#$HalfGreen",
1519     "AREA:rx_avg#$HalfBlue",
1520     "AREA:overlap#$HalfBlueGreen",
1521     "LINE1:tx_avg#$FullGreen:TX",
1522     'GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,',
1523     'GPRINT:tx_max:MAX:%5.1lf%s Max,',
1524     'GPRINT:tx_avg:LAST:%5.1lf%s Last',
1525     'GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)\l',
1526     "LINE1:rx_avg#$FullBlue:RX",
1527     #'GPRINT:rx_min:MIN:%5.1lf %s Min,',
1528     'GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,',
1529     'GPRINT:rx_max:MAX:%5.1lf%s Max,',
1530     'GPRINT:rx_avg:LAST:%5.1lf%s Last',
1531     'GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)\l'
1532     ],
1533     if_rx_errors => ['-v', 'Errors/s',
1534     'DEF:min={file}:value:MIN',
1535     'DEF:avg={file}:value:AVERAGE',
1536     'DEF:max={file}:value:MAX',
1537     'CDEF:mytime=avg,TIME,TIME,IF',
1538     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1539     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1540     'CDEF:avg_sample=avg,UN,0,avg,IF,sample_len,*',
1541     'CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+',
1542     "AREA:avg#$HalfBlue",
1543     "LINE1:avg#$FullBlue:Errors/s",
1544     'GPRINT:avg:AVERAGE:%3.1lf%s Avg,',
1545     'GPRINT:max:MAX:%3.1lf%s Max,',
1546     'GPRINT:avg:LAST:%3.1lf%s Last',
1547     'GPRINT:avg_sum:LAST:(ca. %2.0lf%s Total)\l'
1548     ],
1549     ipt_bytes => ['-v', 'Bits/s',
1550     'DEF:min_raw={file}:value:MIN',
1551     'DEF:avg_raw={file}:value:AVERAGE',
1552     'DEF:max_raw={file}:value:MAX',
1553     'CDEF:min=min_raw,8,*',
1554     'CDEF:avg=avg_raw,8,*',
1555     'CDEF:max=max_raw,8,*',
1556     'CDEF:mytime=avg_raw,TIME,TIME,IF',
1557     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1558     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1559     'CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*',
1560     'CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+',
1561     "AREA:max#$HalfBlue",
1562     "AREA:min#$Canvas",
1563     "LINE1:avg#$FullBlue:Bits/s",
1564     #'GPRINT:min:MIN:%5.1lf %s Min,',
1565     'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
1566     'GPRINT:max:MAX:%5.1lf%s Max,',
1567     'GPRINT:avg:LAST:%5.1lf%s Last',
1568     'GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1569     ],
1570     ipt_packets => ['-v', 'Packets/s',
1571     'DEF:min_raw={file}:value:MIN',
1572     'DEF:avg_raw={file}:value:AVERAGE',
1573     'DEF:max_raw={file}:value:MAX',
1574     'CDEF:min=min_raw,8,*',
1575     'CDEF:avg=avg_raw,8,*',
1576     'CDEF:max=max_raw,8,*',
1577     "AREA:max#$HalfBlue",
1578     "AREA:min#$Canvas",
1579     "LINE1:avg#$FullBlue:Packets/s",
1580     'GPRINT:min:MIN:%5.1lf %s Min,',
1581     'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
1582     'GPRINT:max:MAX:%5.1lf%s Max,',
1583     'GPRINT:avg:LAST:%5.1lf%s Last\l'
1584     ],
1585     irq => ['-v', 'Issues/s',
1586     'DEF:avg={file}:value:AVERAGE',
1587     'DEF:min={file}:value:MIN',
1588     'DEF:max={file}:value:MAX',
1589     "AREA:max#$HalfBlue",
1590     "AREA:min#$Canvas",
1591     "LINE1:avg#$FullBlue:Issues/s",
1592     'GPRINT:min:MIN:%6.2lf Min,',
1593     'GPRINT:avg:AVERAGE:%6.2lf Avg,',
1594     'GPRINT:max:MAX:%6.2lf Max,',
1595     'GPRINT:avg:LAST:%6.2lf Last\l'
1596     ],
1597     load => ['-v', 'System load',
1598     'DEF:s_avg={file}:shortterm:AVERAGE',
1599     'DEF:s_min={file}:shortterm:MIN',
1600     'DEF:s_max={file}:shortterm:MAX',
1601     'DEF:m_avg={file}:midterm:AVERAGE',
1602     'DEF:m_min={file}:midterm:MIN',
1603     'DEF:m_max={file}:midterm:MAX',
1604     'DEF:l_avg={file}:longterm:AVERAGE',
1605     'DEF:l_min={file}:longterm:MIN',
1606     'DEF:l_max={file}:longterm:MAX',
1607     "AREA:s_max#$HalfGreen",
1608     "AREA:s_min#$Canvas",
1609     "LINE1:s_avg#$FullGreen: 1m average",
1610     'GPRINT:s_min:MIN:%4.2lf Min,',
1611     'GPRINT:s_avg:AVERAGE:%4.2lf Avg,',
1612     'GPRINT:s_max:MAX:%4.2lf Max,',
1613     'GPRINT:s_avg:LAST:%4.2lf Last\n',
1614     "LINE1:m_avg#$FullBlue: 5m average",
1615     'GPRINT:m_min:MIN:%4.2lf Min,',
1616     'GPRINT:m_avg:AVERAGE:%4.2lf Avg,',
1617     'GPRINT:m_max:MAX:%4.2lf Max,',
1618     'GPRINT:m_avg:LAST:%4.2lf Last\n',
1619     "LINE1:l_avg#$FullRed:15m average",
1620     'GPRINT:l_min:MIN:%4.2lf Min,',
1621     'GPRINT:l_avg:AVERAGE:%4.2lf Avg,',
1622     'GPRINT:l_max:MAX:%4.2lf Max,',
1623     'GPRINT:l_avg:LAST:%4.2lf Last'
1624     ],
1625     load_percent => [
1626     'DEF:avg={file}:percent:AVERAGE',
1627     'DEF:min={file}:percent:MIN',
1628     'DEF:max={file}:percent:MAX',
1629     "AREA:max#$HalfBlue",
1630     "AREA:min#$Canvas",
1631     "LINE1:avg#$FullBlue:Load",
1632     'GPRINT:min:MIN:%5.1lf%s%% Min,',
1633     'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
1634     'GPRINT:max:MAX:%5.1lf%s%% Max,',
1635     'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
1636     ],
1637     mails => ['DEF:rawgood={file}:good:AVERAGE',
1638     'DEF:rawspam={file}:spam:AVERAGE',
1639     'CDEF:good=rawgood,UN,0,rawgood,IF',
1640     'CDEF:spam=rawspam,UN,0,rawspam,IF',
1641     'CDEF:negspam=spam,-1,*',
1642     "AREA:good#$HalfGreen",
1643     "LINE1:good#$FullGreen:Good mails",
1644     'GPRINT:good:AVERAGE:%4.1lf Avg,',
1645     'GPRINT:good:MAX:%4.1lf Max,',
1646     'GPRINT:good:LAST:%4.1lf Last\n',
1647     "AREA:negspam#$HalfRed",
1648     "LINE1:negspam#$FullRed:Spam mails",
1649     'GPRINT:spam:AVERAGE:%4.1lf Avg,',
1650     'GPRINT:spam:MAX:%4.1lf Max,',
1651     'GPRINT:spam:LAST:%4.1lf Last',
1652     'HRULE:0#000000'
1653     ],
1654     memcached_command => ['-v', 'Commands',
1655     'DEF:avg={file}:value:AVERAGE',
1656     'DEF:min={file}:value:MIN',
1657     'DEF:max={file}:value:MAX',
1658     "AREA:max#$HalfBlue",
1659     "AREA:min#$Canvas",
1660     "LINE1:avg#$FullBlue:Commands",
1661     'GPRINT:min:MIN:%5.1lf%s Min,',
1662     'GPRINT:avg:AVERAGE:%5.1lf Avg,',
1663     'GPRINT:max:MAX:%5.1lf Max,',
1664     'GPRINT:avg:LAST:%5.1lf Last\l'
1665     ],
1666     memcached_connections => ['-v', 'Connections',
1667     'DEF:avg={file}:value:AVERAGE',
1668     'DEF:min={file}:value:MIN',
1669     'DEF:max={file}:value:MAX',
1670     "AREA:max#$HalfBlue",
1671     "AREA:min#$Canvas",
1672     "LINE1:avg#$FullBlue:Connections",
1673     'GPRINT:min:MIN:%4.1lf Min,',
1674     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1675     'GPRINT:max:MAX:%4.1lf Max,',
1676     'GPRINT:avg:LAST:%4.1lf Last\l'
1677     ],
1678     memcached_items => ['-v', 'Items',
1679     'DEF:avg={file}:value:AVERAGE',
1680     'DEF:min={file}:value:MIN',
1681     'DEF:max={file}:value:MAX',
1682     "AREA:max#$HalfBlue",
1683     "AREA:min#$Canvas",
1684     "LINE1:avg#$FullBlue:Items",
1685     'GPRINT:min:MIN:%4.1lf Min,',
1686     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1687     'GPRINT:max:MAX:%4.1lf Max,',
1688     'GPRINT:avg:LAST:%4.1lf Last\l'
1689     ],
1690     memcached_octets => ['-v', 'Bits/s',
1691     'DEF:out_min={file}:tx:MIN',
1692     'DEF:out_avg={file}:tx:AVERAGE',
1693     'DEF:out_max={file}:tx:MAX',
1694     'DEF:inc_min={file}:rx:MIN',
1695     'DEF:inc_avg={file}:rx:AVERAGE',
1696     'DEF:inc_max={file}:rx:MAX',
1697     'CDEF:mytime=out_avg,TIME,TIME,IF',
1698     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1699     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1700     'CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*',
1701     'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
1702     'CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*',
1703     'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
1704     'CDEF:out_bit_min=out_min,8,*',
1705     'CDEF:out_bit_avg=out_avg,8,*',
1706     'CDEF:out_bit_max=out_max,8,*',
1707     'CDEF:inc_bit_min=inc_min,8,*',
1708     'CDEF:inc_bit_avg=inc_avg,8,*',
1709     'CDEF:inc_bit_max=inc_max,8,*',
1710     'CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF',
1711     "AREA:out_bit_avg#$HalfGreen",
1712     "AREA:inc_bit_avg#$HalfBlue",
1713     "AREA:overlap#$HalfBlueGreen",
1714     "LINE1:out_bit_avg#$FullGreen:Written",
1715     'GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,',
1716     'GPRINT:out_bit_max:MAX:%5.1lf%s Max,',
1717     'GPRINT:out_bit_avg:LAST:%5.1lf%s Last',
1718     'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
1719     "LINE1:inc_bit_avg#$FullBlue:Read   ",
1720     'GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,',
1721     'GPRINT:inc_bit_max:MAX:%5.1lf%s Max,',
1722     'GPRINT:inc_bit_avg:LAST:%5.1lf%s Last',
1723     'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1724     ],
1725     memcached_ops => ['-v', 'Ops',
1726     'DEF:avg={file}:value:AVERAGE',
1727     'DEF:min={file}:value:MIN',
1728     'DEF:max={file}:value:MAX',
1729     "AREA:max#$HalfBlue",
1730     "AREA:min#$Canvas",
1731     "LINE1:avg#$FullBlue:Ops",
1732     'GPRINT:min:MIN:%4.1lf Min,',
1733     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
1734     'GPRINT:max:MAX:%4.1lf Max,',
1735     'GPRINT:avg:LAST:%4.1lf Last\l'
1736     ],
1737     memory => ['-b', '1024', '-v', 'Bytes',
1738     'DEF:avg={file}:value:AVERAGE',
1739     'DEF:min={file}:value:MIN',
1740     'DEF:max={file}:value:MAX',
1741     "AREA:max#$HalfBlue",
1742     "AREA:min#$Canvas",
1743     "LINE1:avg#$FullBlue:Memory",
1744     'GPRINT:min:MIN:%5.1lf%sbyte Min,',
1745     'GPRINT:avg:AVERAGE:%5.1lf%sbyte Avg,',
1746     'GPRINT:max:MAX:%5.1lf%sbyte Max,',
1747     'GPRINT:avg:LAST:%5.1lf%sbyte Last\l'
1748     ],
1749     old_memory => [
1750     'DEF:used_avg={file}:used:AVERAGE',
1751     'DEF:free_avg={file}:free:AVERAGE',
1752     'DEF:buffers_avg={file}:buffers:AVERAGE',
1753     'DEF:cached_avg={file}:cached:AVERAGE',
1754     'DEF:used_min={file}:used:MIN',
1755     'DEF:free_min={file}:free:MIN',
1756     'DEF:buffers_min={file}:buffers:MIN',
1757     'DEF:cached_min={file}:cached:MIN',
1758     'DEF:used_max={file}:used:MAX',
1759     'DEF:free_max={file}:free:MAX',
1760     'DEF:buffers_max={file}:buffers:MAX',
1761     'DEF:cached_max={file}:cached:MAX',
1762     'CDEF:cached_avg_nn=cached_avg,UN,0,cached_avg,IF',
1763     'CDEF:buffers_avg_nn=buffers_avg,UN,0,buffers_avg,IF',
1764     'CDEF:free_cached_buffers_used=free_avg,cached_avg_nn,+,buffers_avg_nn,+,used_avg,+',
1765     'CDEF:cached_buffers_used=cached_avg,buffers_avg_nn,+,used_avg,+',
1766     'CDEF:buffers_used=buffers_avg,used_avg,+',
1767     "AREA:free_cached_buffers_used#$HalfGreen",
1768     "AREA:cached_buffers_used#$HalfBlue",
1769     "AREA:buffers_used#$HalfYellow",
1770     "AREA:used_avg#$HalfRed",
1771     "LINE1:free_cached_buffers_used#$FullGreen:Free        ",
1772     'GPRINT:free_min:MIN:%5.1lf%s Min,',
1773     'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
1774     'GPRINT:free_max:MAX:%5.1lf%s Max,',
1775     'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
1776     "LINE1:cached_buffers_used#$FullBlue:Page cache  ",
1777     'GPRINT:cached_min:MIN:%5.1lf%s Min,',
1778     'GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,',
1779     'GPRINT:cached_max:MAX:%5.1lf%s Max,',
1780     'GPRINT:cached_avg:LAST:%5.1lf%s Last\n',
1781     "LINE1:buffers_used#$FullYellow:Buffer cache",
1782     'GPRINT:buffers_min:MIN:%5.1lf%s Min,',
1783     'GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,',
1784     'GPRINT:buffers_max:MAX:%5.1lf%s Max,',
1785     'GPRINT:buffers_avg:LAST:%5.1lf%s Last\n',
1786     "LINE1:used_avg#$FullRed:Used        ",
1787     'GPRINT:used_min:MIN:%5.1lf%s Min,',
1788     'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
1789     'GPRINT:used_max:MAX:%5.1lf%s Max,',
1790     'GPRINT:used_avg:LAST:%5.1lf%s Last'
1791     ],
1792     mysql_commands => ['-v', 'Issues/s',
1793     "DEF:val_avg={file}:value:AVERAGE",
1794     "DEF:val_min={file}:value:MIN",
1795     "DEF:val_max={file}:value:MAX",
1796     "AREA:val_max#$HalfBlue",
1797     "AREA:val_min#$Canvas",
1798     "LINE1:val_avg#$FullBlue:Issues/s",
1799     'GPRINT:val_min:MIN:%5.2lf Min,',
1800     'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
1801     'GPRINT:val_max:MAX:%5.2lf Max,',
1802     'GPRINT:val_avg:LAST:%5.2lf Last'
1803     ],
1804     mysql_handler => ['-v', 'Issues/s',
1805     "DEF:val_avg={file}:value:AVERAGE",
1806     "DEF:val_min={file}:value:MIN",
1807     "DEF:val_max={file}:value:MAX",
1808     "AREA:val_max#$HalfBlue",
1809     "AREA:val_min#$Canvas",
1810     "LINE1:val_avg#$FullBlue:Issues/s",
1811     'GPRINT:val_min:MIN:%5.2lf Min,',
1812     'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
1813     'GPRINT:val_max:MAX:%5.2lf Max,',
1814     'GPRINT:val_avg:LAST:%5.2lf Last'
1815     ],
1816     mysql_octets => ['-v', 'Bits/s',
1817     'DEF:out_min={file}:tx:MIN',
1818     'DEF:out_avg={file}:tx:AVERAGE',
1819     'DEF:out_max={file}:tx:MAX',
1820     'DEF:inc_min={file}:rx:MIN',
1821     'DEF:inc_avg={file}:rx:AVERAGE',
1822     'DEF:inc_max={file}:rx:MAX',
1823     'CDEF:mytime=out_avg,TIME,TIME,IF',
1824     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1825     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1826     'CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*',
1827     'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
1828     'CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*',
1829     'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
1830     'CDEF:out_bit_min=out_min,8,*',
1831     'CDEF:out_bit_avg=out_avg,8,*',
1832     'CDEF:out_bit_max=out_max,8,*',
1833     'CDEF:inc_bit_min=inc_min,8,*',
1834     'CDEF:inc_bit_avg=inc_avg,8,*',
1835     'CDEF:inc_bit_max=inc_max,8,*',
1836     'CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF',
1837     "AREA:out_bit_avg#$HalfGreen",
1838     "AREA:inc_bit_avg#$HalfBlue",
1839     "AREA:overlap#$HalfBlueGreen",
1840     "LINE1:out_bit_avg#$FullGreen:Written",
1841     'GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,',
1842     'GPRINT:out_bit_max:MAX:%5.1lf%s Max,',
1843     'GPRINT:out_bit_avg:LAST:%5.1lf%s Last',
1844     'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
1845     "LINE1:inc_bit_avg#$FullBlue:Read   ",
1846     'GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,',
1847     'GPRINT:inc_bit_max:MAX:%5.1lf%s Max,',
1848     'GPRINT:inc_bit_avg:LAST:%5.1lf%s Last',
1849     'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1850     ],
1851     mysql_qcache => ['-v', 'Queries/s',
1852     "DEF:hits_min={file}:hits:MIN",
1853     "DEF:hits_avg={file}:hits:AVERAGE",
1854     "DEF:hits_max={file}:hits:MAX",
1855     "DEF:inserts_min={file}:inserts:MIN",
1856     "DEF:inserts_avg={file}:inserts:AVERAGE",
1857     "DEF:inserts_max={file}:inserts:MAX",
1858     "DEF:not_cached_min={file}:not_cached:MIN",
1859     "DEF:not_cached_avg={file}:not_cached:AVERAGE",
1860     "DEF:not_cached_max={file}:not_cached:MAX",
1861     "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN",
1862     "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE",
1863     "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX",
1864     "DEF:queries_min={file}:queries_in_cache:MIN",
1865     "DEF:queries_avg={file}:queries_in_cache:AVERAGE",
1866     "DEF:queries_max={file}:queries_in_cache:MAX",
1867     "CDEF:unknown=queries_avg,UNKN,+",
1868     "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+",
1869     "CDEF:inserts_agg=hits_avg,inserts_avg,+",
1870     "CDEF:hits_agg=hits_avg",
1871     "AREA:not_cached_agg#$HalfYellow",
1872     "AREA:inserts_agg#$HalfBlue",
1873     "AREA:hits_agg#$HalfGreen",
1874     "LINE1:not_cached_agg#$FullYellow:Not Cached      ",
1875     'GPRINT:not_cached_min:MIN:%5.2lf Min,',
1876     'GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,',
1877     'GPRINT:not_cached_max:MAX:%5.2lf Max,',
1878     'GPRINT:not_cached_avg:LAST:%5.2lf Last\l',
1879     "LINE1:inserts_agg#$FullBlue:Inserts         ",
1880     'GPRINT:inserts_min:MIN:%5.2lf Min,',
1881     'GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,',
1882     'GPRINT:inserts_max:MAX:%5.2lf Max,',
1883     'GPRINT:inserts_avg:LAST:%5.2lf Last\l',
1884     "LINE1:hits_agg#$FullGreen:Hits            ",
1885     'GPRINT:hits_min:MIN:%5.2lf Min,',
1886     'GPRINT:hits_avg:AVERAGE:%5.2lf Avg,',
1887     'GPRINT:hits_max:MAX:%5.2lf Max,',
1888     'GPRINT:hits_avg:LAST:%5.2lf Last\l',
1889     "LINE1:lowmem_prunes_avg#$FullRed:Lowmem Prunes   ",
1890     'GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,',
1891     'GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,',
1892     'GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,',
1893     'GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\l',
1894     "LINE1:unknown#$Canvas:Queries in cache",
1895     'GPRINT:queries_min:MIN:%5.0lf Min,',
1896     'GPRINT:queries_avg:AVERAGE:%5.0lf Avg,',
1897     'GPRINT:queries_max:MAX:%5.0lf Max,',
1898     'GPRINT:queries_avg:LAST:%5.0lf Last\l'
1899     ],
1900     mysql_threads => ['-v', 'Threads',
1901     "DEF:running_min={file}:running:MIN",
1902     "DEF:running_avg={file}:running:AVERAGE",
1903     "DEF:running_max={file}:running:MAX",
1904     "DEF:connected_min={file}:connected:MIN",
1905     "DEF:connected_avg={file}:connected:AVERAGE",
1906     "DEF:connected_max={file}:connected:MAX",
1907     "DEF:cached_min={file}:cached:MIN",
1908     "DEF:cached_avg={file}:cached:AVERAGE",
1909     "DEF:cached_max={file}:cached:MAX",
1910     "DEF:created_min={file}:created:MIN",
1911     "DEF:created_avg={file}:created:AVERAGE",
1912     "DEF:created_max={file}:created:MAX",
1913     "CDEF:unknown=created_avg,UNKN,+",
1914     "CDEF:cached_agg=connected_avg,cached_avg,+",
1915     "AREA:cached_agg#$HalfGreen",
1916     "AREA:connected_avg#$HalfBlue",
1917     "AREA:running_avg#$HalfRed",
1918     "LINE1:cached_agg#$FullGreen:Cached   ",
1919     'GPRINT:cached_min:MIN:%5.1lf Min,',
1920     'GPRINT:cached_avg:AVERAGE:%5.1lf Avg,',
1921     'GPRINT:cached_max:MAX:%5.1lf Max,',
1922     'GPRINT:cached_avg:LAST:%5.1lf Last\l',
1923     "LINE1:connected_avg#$FullBlue:Connected",
1924     'GPRINT:connected_min:MIN:%5.1lf Min,',
1925     'GPRINT:connected_avg:AVERAGE:%5.1lf Avg,',
1926     'GPRINT:connected_max:MAX:%5.1lf Max,',
1927     'GPRINT:connected_avg:LAST:%5.1lf Last\l',
1928     "LINE1:running_avg#$FullRed:Running  ",
1929     'GPRINT:running_min:MIN:%5.1lf Min,',
1930     'GPRINT:running_avg:AVERAGE:%5.1lf Avg,',
1931     'GPRINT:running_max:MAX:%5.1lf Max,',
1932     'GPRINT:running_avg:LAST:%5.1lf Last\l',
1933     "LINE1:unknown#$Canvas:Created  ",
1934     'GPRINT:created_min:MIN:%5.0lf Min,',
1935     'GPRINT:created_avg:AVERAGE:%5.0lf Avg,',
1936     'GPRINT:created_max:MAX:%5.0lf Max,',
1937     'GPRINT:created_avg:LAST:%5.0lf Last\l'
1938     ],
1939     nfs_procedure => ['-v', 'Issues/s',
1940     'DEF:avg={file}:value:AVERAGE',
1941     'DEF:min={file}:value:MIN',
1942     'DEF:max={file}:value:MAX',
1943     "AREA:max#$HalfBlue",
1944     "AREA:min#$Canvas",
1945     "LINE1:avg#$FullBlue:Issues/s",
1946     'GPRINT:min:MIN:%6.2lf Min,',
1947     'GPRINT:avg:AVERAGE:%6.2lf Avg,',
1948     'GPRINT:max:MAX:%6.2lf Max,',
1949     'GPRINT:avg:LAST:%6.2lf Last\l'
1950     ],
1951     nfs3_procedures => [
1952     "DEF:null_avg={file}:null:AVERAGE",
1953     "DEF:getattr_avg={file}:getattr:AVERAGE",
1954     "DEF:setattr_avg={file}:setattr:AVERAGE",
1955     "DEF:lookup_avg={file}:lookup:AVERAGE",
1956     "DEF:access_avg={file}:access:AVERAGE",
1957     "DEF:readlink_avg={file}:readlink:AVERAGE",
1958     "DEF:read_avg={file}:read:AVERAGE",
1959     "DEF:write_avg={file}:write:AVERAGE",
1960     "DEF:create_avg={file}:create:AVERAGE",
1961     "DEF:mkdir_avg={file}:mkdir:AVERAGE",
1962     "DEF:symlink_avg={file}:symlink:AVERAGE",
1963     "DEF:mknod_avg={file}:mknod:AVERAGE",
1964     "DEF:remove_avg={file}:remove:AVERAGE",
1965     "DEF:rmdir_avg={file}:rmdir:AVERAGE",
1966     "DEF:rename_avg={file}:rename:AVERAGE",
1967     "DEF:link_avg={file}:link:AVERAGE",
1968     "DEF:readdir_avg={file}:readdir:AVERAGE",
1969     "DEF:readdirplus_avg={file}:readdirplus:AVERAGE",
1970     "DEF:fsstat_avg={file}:fsstat:AVERAGE",
1971     "DEF:fsinfo_avg={file}:fsinfo:AVERAGE",
1972     "DEF:pathconf_avg={file}:pathconf:AVERAGE",
1973     "DEF:commit_avg={file}:commit:AVERAGE",
1974     "DEF:null_max={file}:null:MAX",
1975     "DEF:getattr_max={file}:getattr:MAX",
1976     "DEF:setattr_max={file}:setattr:MAX",
1977     "DEF:lookup_max={file}:lookup:MAX",
1978     "DEF:access_max={file}:access:MAX",
1979     "DEF:readlink_max={file}:readlink:MAX",
1980     "DEF:read_max={file}:read:MAX",
1981     "DEF:write_max={file}:write:MAX",
1982     "DEF:create_max={file}:create:MAX",
1983     "DEF:mkdir_max={file}:mkdir:MAX",
1984     "DEF:symlink_max={file}:symlink:MAX",
1985     "DEF:mknod_max={file}:mknod:MAX",
1986     "DEF:remove_max={file}:remove:MAX",
1987     "DEF:rmdir_max={file}:rmdir:MAX",
1988     "DEF:rename_max={file}:rename:MAX",
1989     "DEF:link_max={file}:link:MAX",
1990     "DEF:readdir_max={file}:readdir:MAX",
1991     "DEF:readdirplus_max={file}:readdirplus:MAX",
1992     "DEF:fsstat_max={file}:fsstat:MAX",
1993     "DEF:fsinfo_max={file}:fsinfo:MAX",
1994     "DEF:pathconf_max={file}:pathconf:MAX",
1995     "DEF:commit_max={file}:commit:MAX",
1996     "CDEF:other_avg=null_avg,readlink_avg,create_avg,mkdir_avg,symlink_avg,mknod_avg,remove_avg,rmdir_avg,rename_avg,link_avg,readdir_avg,readdirplus_avg,fsstat_avg,fsinfo_avg,pathconf_avg,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
1997     "CDEF:other_max=null_max,readlink_max,create_max,mkdir_max,symlink_max,mknod_max,remove_max,rmdir_max,rename_max,link_max,readdir_max,readdirplus_max,fsstat_max,fsinfo_max,pathconf_max,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
1998     "CDEF:stack_read=read_avg",
1999     "CDEF:stack_getattr=stack_read,getattr_avg,+",
2000     "CDEF:stack_access=stack_getattr,access_avg,+",
2001     "CDEF:stack_lookup=stack_access,lookup_avg,+",
2002     "CDEF:stack_write=stack_lookup,write_avg,+",
2003     "CDEF:stack_commit=stack_write,commit_avg,+",
2004     "CDEF:stack_setattr=stack_commit,setattr_avg,+",
2005     "CDEF:stack_other=stack_setattr,other_avg,+",
2006     "AREA:stack_other#$HalfRed",
2007     "AREA:stack_setattr#$HalfGreen",
2008     "AREA:stack_commit#$HalfYellow",
2009     "AREA:stack_write#$HalfGreen",
2010     "AREA:stack_lookup#$HalfBlue",
2011     "AREA:stack_access#$HalfMagenta",
2012     "AREA:stack_getattr#$HalfCyan",
2013     "AREA:stack_read#$HalfBlue",
2014     "LINE1:stack_other#$FullRed:Other  ",
2015     'GPRINT:other_max:MAX:%5.1lf Max,',
2016     'GPRINT:other_avg:AVERAGE:%5.1lf Avg,',
2017     'GPRINT:other_avg:LAST:%5.1lf Last\l',
2018     "LINE1:stack_setattr#$FullGreen:setattr",
2019     'GPRINT:setattr_max:MAX:%5.1lf Max,',
2020     'GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,',
2021     'GPRINT:setattr_avg:LAST:%5.1lf Last\l',
2022     "LINE1:stack_commit#$FullYellow:commit ",
2023     'GPRINT:commit_max:MAX:%5.1lf Max,',
2024     'GPRINT:commit_avg:AVERAGE:%5.1lf Avg,',
2025     'GPRINT:commit_avg:LAST:%5.1lf Last\l',
2026     "LINE1:stack_write#$FullGreen:write  ",
2027     'GPRINT:write_max:MAX:%5.1lf Max,',
2028     'GPRINT:write_avg:AVERAGE:%5.1lf Avg,',
2029     'GPRINT:write_avg:LAST:%5.1lf Last\l',
2030     "LINE1:stack_lookup#$FullBlue:lookup ",
2031     'GPRINT:lookup_max:MAX:%5.1lf Max,',
2032     'GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,',
2033     'GPRINT:lookup_avg:LAST:%5.1lf Last\l',
2034     "LINE1:stack_access#$FullMagenta:access ",
2035     'GPRINT:access_max:MAX:%5.1lf Max,',
2036     'GPRINT:access_avg:AVERAGE:%5.1lf Avg,',
2037     'GPRINT:access_avg:LAST:%5.1lf Last\l',
2038     "LINE1:stack_getattr#$FullCyan:getattr",
2039     'GPRINT:getattr_max:MAX:%5.1lf Max,',
2040     'GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,',
2041     'GPRINT:getattr_avg:LAST:%5.1lf Last\l',
2042     "LINE1:stack_read#$FullBlue:read   ",
2043     'GPRINT:read_max:MAX:%5.1lf Max,',
2044     'GPRINT:read_avg:AVERAGE:%5.1lf Avg,',
2045     'GPRINT:read_avg:LAST:%5.1lf Last\l'
2046     ],
2047     partition => [
2048     "DEF:rbyte_avg={file}:rbytes:AVERAGE",
2049     "DEF:rbyte_min={file}:rbytes:MIN",
2050     "DEF:rbyte_max={file}:rbytes:MAX",
2051     "DEF:wbyte_avg={file}:wbytes:AVERAGE",
2052     "DEF:wbyte_min={file}:wbytes:MIN",
2053     "DEF:wbyte_max={file}:wbytes:MAX",
2054     'CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF',
2055     "AREA:wbyte_avg#$HalfGreen",
2056     "AREA:rbyte_avg#$HalfBlue",
2057     "AREA:overlap#$HalfBlueGreen",
2058     "LINE1:wbyte_avg#$FullGreen:Write",
2059     'GPRINT:wbyte_min:MIN:%5.1lf%s Min,',
2060     'GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,',
2061     'GPRINT:wbyte_max:MAX:%5.1lf%s Max,',
2062     'GPRINT:wbyte_avg:LAST:%5.1lf%s Last\l',
2063     "LINE1:rbyte_avg#$FullBlue:Read ",
2064     'GPRINT:rbyte_min:MIN:%5.1lf%s Min,',
2065     'GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,',
2066     'GPRINT:rbyte_max:MAX:%5.1lf%s Max,',
2067     'GPRINT:rbyte_avg:LAST:%5.1lf%s Last\l'
2068     ],
2069     percent => ['-v', 'Percent',
2070     'DEF:avg={file}:percent:AVERAGE',
2071     'DEF:min={file}:percent:MIN',
2072     'DEF:max={file}:percent:MAX',
2073     "AREA:max#$HalfBlue",
2074     "AREA:min#$Canvas",
2075     "LINE1:avg#$FullBlue:Percent",
2076     'GPRINT:min:MIN:%5.1lf%% Min,',
2077     'GPRINT:avg:AVERAGE:%5.1lf%% Avg,',
2078     'GPRINT:max:MAX:%5.1lf%% Max,',
2079     'GPRINT:avg:LAST:%5.1lf%% Last\l'
2080     ],
2081     ping => ['DEF:ping_avg={file}:ping:AVERAGE',
2082     'DEF:ping_min={file}:ping:MIN',
2083     'DEF:ping_max={file}:ping:MAX',
2084     "AREA:ping_max#$HalfBlue",
2085     "AREA:ping_min#$Canvas",
2086     "LINE1:ping_avg#$FullBlue:Ping",
2087     'GPRINT:ping_min:MIN:%4.1lf ms Min,',
2088     'GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,',
2089     'GPRINT:ping_max:MAX:%4.1lf ms Max,',
2090     'GPRINT:ping_avg:LAST:%4.1lf ms Last'],
2091     pg_blks => ['DEF:pg_blks_avg={file}:value:AVERAGE',
2092     'DEF:pg_blks_min={file}:value:MIN',
2093     'DEF:pg_blks_max={file}:value:MAX',
2094     "AREA:pg_blks_max#$HalfBlue",
2095     "AREA:pg_blks_min#$Canvas",
2096     "LINE1:pg_blks_avg#$FullBlue:Blocks",
2097     'GPRINT:pg_blks_min:MIN:%4.1lf%s Min,',
2098     'GPRINT:pg_blks_avg:AVERAGE:%4.1lf%s Avg,',
2099     'GPRINT:pg_blks_max:MAX:%4.1lf%s Max,',
2100     'GPRINT:pg_blks_avg:LAST:%4.1lf%s Last'],
2101     pg_db_size => ['DEF:pg_db_size_avg={file}:value:AVERAGE',
2102     'DEF:pg_db_size_min={file}:value:MIN',
2103     'DEF:pg_db_size_max={file}:value:MAX',
2104     "AREA:pg_db_size_max#$HalfBlue",
2105     "AREA:pg_db_size_min#$Canvas",
2106     "LINE1:pg_db_size_avg#$FullBlue:Bytes",
2107     'GPRINT:pg_db_size_min:MIN:%4.1lf%s Min,',
2108     'GPRINT:pg_db_size_avg:AVERAGE:%4.1lf%s Avg,',
2109     'GPRINT:pg_db_size_max:MAX:%4.1lf%s Max,',
2110     'GPRINT:pg_db_size_avg:LAST:%4.1lf%s Last'],
2111     pg_n_tup_c => ['DEF:pg_n_tup_avg={file}:value:AVERAGE',
2112     'DEF:pg_n_tup_min={file}:value:MIN',
2113     'DEF:pg_n_tup_max={file}:value:MAX',
2114     "AREA:pg_n_tup_max#$HalfBlue",
2115     "AREA:pg_n_tup_min#$Canvas",
2116     "LINE1:pg_n_tup_avg#$FullBlue:Tuples",
2117     'GPRINT:pg_n_tup_min:MIN:%4.1lf%s Min,',
2118     'GPRINT:pg_n_tup_avg:AVERAGE:%4.1lf%s Avg,',
2119     'GPRINT:pg_n_tup_max:MAX:%4.1lf%s Max,',
2120     'GPRINT:pg_n_tup_avg:LAST:%4.1lf%s Last'],
2121     pg_n_tup_g => ['DEF:pg_n_tup_avg={file}:value:AVERAGE',
2122     'DEF:pg_n_tup_min={file}:value:MIN',
2123     'DEF:pg_n_tup_max={file}:value:MAX',
2124     "AREA:pg_n_tup_max#$HalfBlue",
2125     "AREA:pg_n_tup_min#$Canvas",
2126     "LINE1:pg_n_tup_avg#$FullBlue:Tuples",
2127     'GPRINT:pg_n_tup_min:MIN:%4.1lf%s Min,',
2128     'GPRINT:pg_n_tup_avg:AVERAGE:%4.1lf%s Avg,',
2129     'GPRINT:pg_n_tup_max:MAX:%4.1lf%s Max,',
2130     'GPRINT:pg_n_tup_avg:LAST:%4.1lf%s Last'],
2131     pg_numbackends => ['DEF:pg_numbackends_avg={file}:value:AVERAGE',
2132     'DEF:pg_numbackends_min={file}:value:MIN',
2133     'DEF:pg_numbackends_max={file}:value:MAX',
2134     "AREA:pg_numbackends_max#$HalfBlue",
2135     "AREA:pg_numbackends_min#$Canvas",
2136     "LINE1:pg_numbackends_avg#$FullBlue:Backends",
2137     'GPRINT:pg_numbackends_min:MIN:%4.1lf%s Min,',
2138     'GPRINT:pg_numbackends_avg:AVERAGE:%4.1lf%s Avg,',
2139     'GPRINT:pg_numbackends_max:MAX:%4.1lf%s Max,',
2140     'GPRINT:pg_numbackends_avg:LAST:%4.1lf%s Last'],
2141     pg_scan => ['DEF:pg_scan_avg={file}:value:AVERAGE',
2142     'DEF:pg_scan_min={file}:value:MIN',
2143     'DEF:pg_scan_max={file}:value:MAX',
2144     "AREA:pg_scan_max#$HalfBlue",
2145     "AREA:pg_scan_min#$Canvas",
2146     "LINE1:pg_scan_avg#$FullBlue:Scans",
2147     'GPRINT:pg_scan_min:MIN:%4.1lf%s Min,',
2148     'GPRINT:pg_scan_avg:AVERAGE:%4.1lf%s Avg,',
2149     'GPRINT:pg_scan_max:MAX:%4.1lf%s Max,',
2150     'GPRINT:pg_scan_avg:LAST:%4.1lf%s Last'],
2151     pg_xact => ['DEF:pg_xact_avg={file}:value:AVERAGE',
2152     'DEF:pg_xact_min={file}:value:MIN',
2153     'DEF:pg_xact_max={file}:value:MAX',
2154     "AREA:pg_xact_max#$HalfBlue",
2155     "AREA:pg_xact_min#$Canvas",
2156     "LINE1:pg_xact_avg#$FullBlue:Transactions",
2157     'GPRINT:pg_xact_min:MIN:%4.1lf%s Min,',
2158     'GPRINT:pg_xact_avg:AVERAGE:%4.1lf%s Avg,',
2159     'GPRINT:pg_xact_max:MAX:%4.1lf%s Max,',
2160     'GPRINT:pg_xact_avg:LAST:%4.1lf%s Last'],
2161     power => ['-v', 'Watt',
2162     'DEF:avg={file}:value:AVERAGE',
2163     'DEF:min={file}:value:MIN',
2164     'DEF:max={file}:value:MAX',
2165     "AREA:max#$HalfBlue",
2166     "AREA:min#$Canvas",
2167     "LINE1:avg#$FullBlue:Watt",
2168     'GPRINT:min:MIN:%5.1lf%sW Min,',
2169     'GPRINT:avg:AVERAGE:%5.1lf%sW Avg,',
2170     'GPRINT:max:MAX:%5.1lf%sW Max,',
2171     'GPRINT:avg:LAST:%5.1lf%sW Last\l'
2172     ],
2173     processes => [
2174     "DEF:running_avg={file}:running:AVERAGE",
2175     "DEF:running_min={file}:running:MIN",
2176     "DEF:running_max={file}:running:MAX",
2177     "DEF:sleeping_avg={file}:sleeping:AVERAGE",
2178     "DEF:sleeping_min={file}:sleeping:MIN",
2179     "DEF:sleeping_max={file}:sleeping:MAX",
2180     "DEF:zombies_avg={file}:zombies:AVERAGE",
2181     "DEF:zombies_min={file}:zombies:MIN",
2182     "DEF:zombies_max={file}:zombies:MAX",
2183     "DEF:stopped_avg={file}:stopped:AVERAGE",
2184     "DEF:stopped_min={file}:stopped:MIN",
2185     "DEF:stopped_max={file}:stopped:MAX",
2186     "DEF:paging_avg={file}:paging:AVERAGE",
2187     "DEF:paging_min={file}:paging:MIN",
2188     "DEF:paging_max={file}:paging:MAX",
2189     "DEF:blocked_avg={file}:blocked:AVERAGE",
2190     "DEF:blocked_min={file}:blocked:MIN",
2191     "DEF:blocked_max={file}:blocked:MAX",
2192     'CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+',
2193     'CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+',
2194     'CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+',
2195     'CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+',
2196     'CDEF:running_acc=sleeping_avg,running_avg,+',
2197     'CDEF:sleeping_acc=sleeping_avg',
2198     "AREA:paging_acc#$HalfYellow",
2199     "AREA:blocked_acc#$HalfCyan",
2200     "AREA:zombies_acc#$HalfRed",
2201     "AREA:stopped_acc#$HalfMagenta",
2202     "AREA:running_acc#$HalfGreen",
2203     "AREA:sleeping_acc#$HalfBlue",
2204     "LINE1:paging_acc#$FullYellow:Paging  ",
2205     'GPRINT:paging_min:MIN:%5.1lf Min,',
2206     'GPRINT:paging_avg:AVERAGE:%5.1lf Average,',
2207     'GPRINT:paging_max:MAX:%5.1lf Max,',
2208     'GPRINT:paging_avg:LAST:%5.1lf Last\l',
2209     "LINE1:blocked_acc#$FullCyan:Blocked ",
2210     'GPRINT:blocked_min:MIN:%5.1lf Min,',
2211     'GPRINT:blocked_avg:AVERAGE:%5.1lf Average,',
2212     'GPRINT:blocked_max:MAX:%5.1lf Max,',
2213     'GPRINT:blocked_avg:LAST:%5.1lf Last\l',
2214     "LINE1:zombies_acc#$FullRed:Zombies ",
2215     'GPRINT:zombies_min:MIN:%5.1lf Min,',
2216     'GPRINT:zombies_avg:AVERAGE:%5.1lf Average,',
2217     'GPRINT:zombies_max:MAX:%5.1lf Max,',
2218     'GPRINT:zombies_avg:LAST:%5.1lf Last\l',
2219     "LINE1:stopped_acc#$FullMagenta:Stopped ",
2220     'GPRINT:stopped_min:MIN:%5.1lf Min,',
2221     'GPRINT:stopped_avg:AVERAGE:%5.1lf Average,',
2222     'GPRINT:stopped_max:MAX:%5.1lf Max,',
2223     'GPRINT:stopped_avg:LAST:%5.1lf Last\l',
2224     "LINE1:running_acc#$FullGreen:Running ",
2225     'GPRINT:running_min:MIN:%5.1lf Min,',
2226     'GPRINT:running_avg:AVERAGE:%5.1lf Average,',
2227     'GPRINT:running_max:MAX:%5.1lf Max,',
2228     'GPRINT:running_avg:LAST:%5.1lf Last\l',
2229     "LINE1:sleeping_acc#$FullBlue:Sleeping",
2230     'GPRINT:sleeping_min:MIN:%5.1lf Min,',
2231     'GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,',
2232     'GPRINT:sleeping_max:MAX:%5.1lf Max,',
2233     'GPRINT:sleeping_avg:LAST:%5.1lf Last\l'
2234     ],
2235     ps_count => ['-v', 'Processes',
2236     'DEF:procs_avg={file}:processes:AVERAGE',
2237     'DEF:procs_min={file}:processes:MIN',
2238     'DEF:procs_max={file}:processes:MAX',
2239     'DEF:thrds_avg={file}:threads:AVERAGE',
2240     'DEF:thrds_min={file}:threads:MIN',
2241     'DEF:thrds_max={file}:threads:MAX',
2242     "AREA:thrds_avg#$HalfBlue",
2243     "AREA:procs_avg#$HalfRed",
2244     "LINE1:thrds_avg#$FullBlue:Threads  ",
2245     'GPRINT:thrds_min:MIN:%5.1lf Min,',
2246     'GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,',
2247     'GPRINT:thrds_max:MAX:%5.1lf Max,',
2248     'GPRINT:thrds_avg:LAST:%5.1lf Last\l',
2249     "LINE1:procs_avg#$FullRed:Processes",
2250     'GPRINT:procs_min:MIN:%5.1lf Min,',
2251     'GPRINT:procs_avg:AVERAGE:%5.1lf Avg,',
2252     'GPRINT:procs_max:MAX:%5.1lf Max,',
2253     'GPRINT:procs_avg:LAST:%5.1lf Last\l'
2254     ],
2255     ps_cputime => ['-v', 'Jiffies',
2256     'DEF:user_avg_raw={file}:user:AVERAGE',
2257     'DEF:user_min_raw={file}:user:MIN',
2258     'DEF:user_max_raw={file}:user:MAX',
2259     'DEF:syst_avg_raw={file}:syst:AVERAGE',
2260     'DEF:syst_min_raw={file}:syst:MIN',
2261     'DEF:syst_max_raw={file}:syst:MAX',
2262     'CDEF:user_avg=user_avg_raw,1000000,/',
2263     'CDEF:user_min=user_min_raw,1000000,/',
2264     'CDEF:user_max=user_max_raw,1000000,/',
2265     'CDEF:syst_avg=syst_avg_raw,1000000,/',
2266     'CDEF:syst_min=syst_min_raw,1000000,/',
2267     'CDEF:syst_max=syst_max_raw,1000000,/',
2268     'CDEF:user_syst=syst_avg,UN,0,syst_avg,IF,user_avg,+',
2269     "AREA:user_syst#$HalfBlue",
2270     "AREA:syst_avg#$HalfRed",
2271     "LINE1:user_syst#$FullBlue:User  ",
2272     'GPRINT:user_min:MIN:%5.1lf%s Min,',
2273     'GPRINT:user_avg:AVERAGE:%5.1lf%s Avg,',
2274     'GPRINT:user_max:MAX:%5.1lf%s Max,',
2275     'GPRINT:user_avg:LAST:%5.1lf%s Last\l',
2276     "LINE1:syst_avg#$FullRed:System",
2277     'GPRINT:syst_min:MIN:%5.1lf%s Min,',
2278     'GPRINT:syst_avg:AVERAGE:%5.1lf%s Avg,',
2279     'GPRINT:syst_max:MAX:%5.1lf%s Max,',
2280     'GPRINT:syst_avg:LAST:%5.1lf%s Last\l'
2281     ],
2282     ps_pagefaults => ['-v', 'Pagefaults/s',
2283     'DEF:minor_avg={file}:minflt:AVERAGE',
2284     'DEF:minor_min={file}:minflt:MIN',
2285     'DEF:minor_max={file}:minflt:MAX',
2286     'DEF:major_avg={file}:majflt:AVERAGE',
2287     'DEF:major_min={file}:majflt:MIN',
2288     'DEF:major_max={file}:majflt:MAX',
2289     'CDEF:minor_major=major_avg,UN,0,major_avg,IF,minor_avg,+',
2290     "AREA:minor_major#$HalfBlue",
2291     "AREA:major_avg#$HalfRed",
2292     "LINE1:minor_major#$FullBlue:Minor",
2293     'GPRINT:minor_min:MIN:%5.1lf%s Min,',
2294     'GPRINT:minor_avg:AVERAGE:%5.1lf%s Avg,',
2295     'GPRINT:minor_max:MAX:%5.1lf%s Max,',
2296     'GPRINT:minor_avg:LAST:%5.1lf%s Last\l',
2297     "LINE1:major_avg#$FullRed:Major",
2298     'GPRINT:major_min:MIN:%5.1lf%s Min,',
2299     'GPRINT:major_avg:AVERAGE:%5.1lf%s Avg,',
2300     'GPRINT:major_max:MAX:%5.1lf%s Max,',
2301     'GPRINT:major_avg:LAST:%5.1lf%s Last\l'
2302     ],
2303     ps_rss => ['-v', 'Bytes',
2304     'DEF:avg={file}:value:AVERAGE',
2305     'DEF:min={file}:value:MIN',
2306     'DEF:max={file}:value:MAX',
2307     "AREA:avg#$HalfBlue",
2308     "LINE1:avg#$FullBlue:RSS",
2309     'GPRINT:min:MIN:%5.1lf%s Min,',
2310     'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
2311     'GPRINT:max:MAX:%5.1lf%s Max,',
2312     'GPRINT:avg:LAST:%5.1lf%s Last\l'
2313     ],
2314     ps_state => ['-v', 'Processes',
2315     'DEF:avg={file}:value:AVERAGE',
2316     'DEF:min={file}:value:MIN',
2317     'DEF:max={file}:value:MAX',
2318     "AREA:max#$HalfBlue",
2319     "AREA:min#$Canvas",
2320     "LINE1:avg#$FullBlue:Processes",
2321     'GPRINT:min:MIN:%6.2lf Min,',
2322     'GPRINT:avg:AVERAGE:%6.2lf Avg,',
2323     'GPRINT:max:MAX:%6.2lf Max,',
2324     'GPRINT:avg:LAST:%6.2lf Last\l'
2325     ],
2326     signal_noise => ['-v', 'dBm',
2327     'DEF:avg={file}:value:AVERAGE',
2328     'DEF:min={file}:value:MIN',
2329     'DEF:max={file}:value:MAX',
2330     "AREA:max#$HalfBlue",
2331     "AREA:min#$Canvas",
2332     "LINE1:avg#$FullBlue:Noise",
2333     'GPRINT:min:MIN:%5.1lf%sdBm Min,',
2334     'GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,',
2335     'GPRINT:max:MAX:%5.1lf%sdBm Max,',
2336     'GPRINT:avg:LAST:%5.1lf%sdBm Last\l'
2337     ],
2338     signal_power => ['-v', 'dBm',
2339     'DEF:avg={file}:value:AVERAGE',
2340     'DEF:min={file}:value:MIN',
2341     'DEF:max={file}:value:MAX',
2342     "AREA:max#$HalfBlue",
2343     "AREA:min#$Canvas",
2344     "LINE1:avg#$FullBlue:Power",
2345     'GPRINT:min:MIN:%5.1lf%sdBm Min,',
2346     'GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,',
2347     'GPRINT:max:MAX:%5.1lf%sdBm Max,',
2348     'GPRINT:avg:LAST:%5.1lf%sdBm Last\l'
2349     ],
2350     signal_quality => ['-v', '%',
2351     'DEF:avg={file}:value:AVERAGE',
2352     'DEF:min={file}:value:MIN',
2353     'DEF:max={file}:value:MAX',
2354     "AREA:max#$HalfBlue",
2355     "AREA:min#$Canvas",
2356     "LINE1:avg#$FullBlue:Quality",
2357     'GPRINT:min:MIN:%5.1lf%s%% Min,',
2358     'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
2359     'GPRINT:max:MAX:%5.1lf%s%% Max,',
2360     'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
2361     ],
2362     swap => ['-v', 'Bytes', '-b', '1024',
2363     'DEF:avg={file}:value:AVERAGE',
2364     'DEF:min={file}:value:MIN',
2365     'DEF:max={file}:value:MAX',
2366     "AREA:max#$HalfBlue",
2367     "AREA:min#$Canvas",
2368     "LINE1:avg#$FullBlue:Bytes",
2369     'GPRINT:min:MIN:%6.2lf%sByte Min,',
2370     'GPRINT:avg:AVERAGE:%6.2lf%sByte Avg,',
2371     'GPRINT:max:MAX:%6.2lf%sByte Max,',
2372     'GPRINT:avg:LAST:%6.2lf%sByte Last\l'
2373     ],
2374     old_swap => [
2375     'DEF:used_avg={file}:used:AVERAGE',
2376     'DEF:used_min={file}:used:MIN',
2377     'DEF:used_max={file}:used:MAX',
2378     'DEF:free_avg={file}:free:AVERAGE',
2379     'DEF:free_min={file}:free:MIN',
2380     'DEF:free_max={file}:free:MAX',
2381     'DEF:cach_avg={file}:cached:AVERAGE',
2382     'DEF:cach_min={file}:cached:MIN',
2383     'DEF:cach_max={file}:cached:MAX',
2384     'DEF:resv_avg={file}:resv:AVERAGE',
2385     'DEF:resv_min={file}:resv:MIN',
2386     'DEF:resv_max={file}:resv:MAX',
2387     'CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF',
2388     'CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF',
2389     'CDEF:used_acc=used_avg',
2390     'CDEF:resv_acc=used_acc,resv_avg_notnull,+',
2391     'CDEF:cach_acc=resv_acc,cach_avg_notnull,+',
2392     'CDEF:free_acc=cach_acc,free_avg,+',
2393     "AREA:free_acc#$HalfGreen",
2394     "AREA:cach_acc#$HalfBlue",
2395     "AREA:resv_acc#$HalfYellow",
2396     "AREA:used_acc#$HalfRed",
2397     "LINE1:free_acc#$FullGreen:Free    ",
2398     'GPRINT:free_min:MIN:%5.1lf%s Min,',
2399     'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
2400     'GPRINT:free_max:MAX:%5.1lf%s Max,',
2401     'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
2402     "LINE1:cach_acc#$FullBlue:Cached  ",
2403     'GPRINT:cach_min:MIN:%5.1lf%s Min,',
2404     'GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,',
2405     'GPRINT:cach_max:MAX:%5.1lf%s Max,',
2406     'GPRINT:cach_avg:LAST:%5.1lf%s Last\l',
2407     "LINE1:resv_acc#$FullYellow:Reserved",
2408     'GPRINT:resv_min:MIN:%5.1lf%s Min,',
2409     'GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,',
2410     'GPRINT:resv_max:MAX:%5.1lf%s Max,',
2411     'GPRINT:resv_avg:LAST:%5.1lf%s Last\n',
2412     "LINE1:used_acc#$FullRed:Used    ",
2413     'GPRINT:used_min:MIN:%5.1lf%s Min,',
2414     'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
2415     'GPRINT:used_max:MAX:%5.1lf%s Max,',
2416     'GPRINT:used_avg:LAST:%5.1lf%s Last\l'
2417     ],
2418     tcp_connections => ['-v', 'Connections',
2419     'DEF:avg={file}:value:AVERAGE',
2420     'DEF:min={file}:value:MIN',
2421     'DEF:max={file}:value:MAX',
2422     "AREA:max#$HalfBlue",
2423     "AREA:min#$Canvas",
2424     "LINE1:avg#$FullBlue:Connections",
2425     'GPRINT:min:MIN:%4.1lf Min,',
2426     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
2427     'GPRINT:max:MAX:%4.1lf Max,',
2428     'GPRINT:avg:LAST:%4.1lf Last\l'
2429     ],
2430     temperature => ['-v', 'Celsius',
2431     'DEF:temp_avg={file}:value:AVERAGE',
2432     'DEF:temp_min={file}:value:MIN',
2433     'DEF:temp_max={file}:value:MAX',
2434     'CDEF:average=temp_avg,0.2,*,PREV,UN,temp_avg,PREV,IF,0.8,*,+',
2435     "AREA:temp_max#$HalfRed",
2436     "AREA:temp_min#$Canvas",
2437     "LINE1:temp_avg#$FullRed:Temperature",
2438     'GPRINT:temp_min:MIN:%4.1lf Min,',
2439     'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
2440     'GPRINT:temp_max:MAX:%4.1lf Max,',
2441     'GPRINT:temp_avg:LAST:%4.1lf Last\l'
2442     ],
2443     timeleft => ['-v', 'Minutes',
2444     'DEF:avg={file}:timeleft:AVERAGE',
2445     'DEF:min={file}:timeleft:MIN',
2446     'DEF:max={file}:timeleft:MAX',
2447     "AREA:max#$HalfBlue",
2448     "AREA:min#$Canvas",
2449     "LINE1:avg#$FullBlue:Time left [min]",
2450     'GPRINT:min:MIN:%5.1lf%s Min,',
2451     'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
2452     'GPRINT:max:MAX:%5.1lf%s Max,',
2453     'GPRINT:avg:LAST:%5.1lf%s Last\l'
2454     ],
2455     time_offset => [ # NTPd
2456     'DEF:s_avg={file}:seconds:AVERAGE',
2457     'DEF:s_min={file}:seconds:MIN',
2458     'DEF:s_max={file}:seconds:MAX',
2459     "AREA:s_max#$HalfBlue",
2460     "AREA:s_min#$Canvas",
2461     "LINE1:s_avg#$FullBlue:{inst}",
2462     'GPRINT:s_min:MIN:%7.3lf%s Min,',
2463     'GPRINT:s_avg:AVERAGE:%7.3lf%s Avg,',
2464     'GPRINT:s_max:MAX:%7.3lf%s Max,',
2465     'GPRINT:s_avg:LAST:%7.3lf%s Last'
2466     ],
2467     if_octets => ['-v', 'Bits/s', '-l', '0',
2468     'DEF:out_min_raw={file}:tx:MIN',
2469     'DEF:out_avg_raw={file}:tx:AVERAGE',
2470     'DEF:out_max_raw={file}:tx:MAX',
2471     'DEF:inc_min_raw={file}:rx:MIN',
2472     'DEF:inc_avg_raw={file}:rx:AVERAGE',
2473     'DEF:inc_max_raw={file}:rx:MAX',
2474     'CDEF:out_min=out_min_raw,8,*',
2475     'CDEF:out_avg=out_avg_raw,8,*',
2476     'CDEF:out_max=out_max_raw,8,*',
2477     'CDEF:inc_min=inc_min_raw,8,*',
2478     'CDEF:inc_avg=inc_avg_raw,8,*',
2479     'CDEF:inc_max=inc_max_raw,8,*',
2480     'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
2481     'CDEF:mytime=out_avg_raw,TIME,TIME,IF',
2482     'CDEF:sample_len_raw=mytime,PREV(mytime),-',
2483     'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
2484     'CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*',
2485     'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
2486     'CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*',
2487     'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
2488     "AREA:out_avg#$HalfGreen",
2489     "AREA:inc_avg#$HalfBlue",
2490     "AREA:overlap#$HalfBlueGreen",
2491     "LINE1:out_avg#$FullGreen:Outgoing",
2492     'GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,',
2493     'GPRINT:out_max:MAX:%5.1lf%s Max,',
2494     'GPRINT:out_avg:LAST:%5.1lf%s Last',
2495     'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
2496     "LINE1:inc_avg#$FullBlue:Incoming",
2497     #'GPRINT:inc_min:MIN:%5.1lf %s Min,',
2498     'GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,',
2499     'GPRINT:inc_max:MAX:%5.1lf%s Max,',
2500     'GPRINT:inc_avg:LAST:%5.1lf%s Last',
2501     'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
2502     ],
2503     cpufreq => [
2504     'DEF:cpufreq_avg={file}:value:AVERAGE',
2505     'DEF:cpufreq_min={file}:value:MIN',
2506     'DEF:cpufreq_max={file}:value:MAX',
2507     "AREA:cpufreq_max#$HalfBlue",
2508     "AREA:cpufreq_min#$Canvas",
2509     "LINE1:cpufreq_avg#$FullBlue:Frequency",
2510     'GPRINT:cpufreq_min:MIN:%5.1lf%s Min,',
2511     'GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,',
2512     'GPRINT:cpufreq_max:MAX:%5.1lf%s Max,',
2513     'GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\l'
2514     ],
2515     multimeter => [
2516     'DEF:multimeter_avg={file}:value:AVERAGE',
2517     'DEF:multimeter_min={file}:value:MIN',
2518     'DEF:multimeter_max={file}:value:MAX',
2519     "AREA:multimeter_max#$HalfBlue",
2520     "AREA:multimeter_min#$Canvas",
2521     "LINE1:multimeter_avg#$FullBlue:Multimeter",
2522     'GPRINT:multimeter_min:MIN:%4.1lf Min,',
2523     'GPRINT:multimeter_avg:AVERAGE:%4.1lf Average,',
2524     'GPRINT:multimeter_max:MAX:%4.1lf Max,',
2525     'GPRINT:multimeter_avg:LAST:%4.1lf Last\l'
2526     ],
2527     users => ['-v', 'Users',
2528     'DEF:users_avg={file}:users:AVERAGE',
2529     'DEF:users_min={file}:users:MIN',
2530     'DEF:users_max={file}:users:MAX',
2531     "AREA:users_max#$HalfBlue",
2532     "AREA:users_min#$Canvas",
2533     "LINE1:users_avg#$FullBlue:Users",
2534     'GPRINT:users_min:MIN:%4.1lf Min,',
2535     'GPRINT:users_avg:AVERAGE:%4.1lf Average,',
2536     'GPRINT:users_max:MAX:%4.1lf Max,',
2537     'GPRINT:users_avg:LAST:%4.1lf Last\l'
2538     ],
2539     voltage => ['-v', 'Voltage',
2540     'DEF:avg={file}:value:AVERAGE',
2541     'DEF:min={file}:value:MIN',
2542     'DEF:max={file}:value:MAX',
2543     "AREA:max#$HalfBlue",
2544     "AREA:min#$Canvas",
2545     "LINE1:avg#$FullBlue:Voltage",
2546     'GPRINT:min:MIN:%5.1lf%sV Min,',
2547     'GPRINT:avg:AVERAGE:%5.1lf%sV Avg,',
2548     'GPRINT:max:MAX:%5.1lf%sV Max,',
2549     'GPRINT:avg:LAST:%5.1lf%sV Last\l'
2550     ],
2551     vs_threads => [
2552     "DEF:avg={file}:value:AVERAGE",
2553     "DEF:min={file}:value:MIN",
2554     "DEF:max={file}:value:MAX",
2555     "AREA:max#$HalfBlue",
2556     "AREA:min#$Canvas",
2557     "LINE1:avg#$FullBlue:Threads",
2558     'GPRINT:min:MIN:%5.1lf Min,',
2559     'GPRINT:avg:AVERAGE:%5.1lf Avg.,',
2560     'GPRINT:max:MAX:%5.1lf Max,',
2561     'GPRINT:avg:LAST:%5.1lf Last\l',
2562     ],
2563     vs_memory => ['-b', '1024', '-v', 'Bytes',
2564     "DEF:avg={file}:value:AVERAGE",
2565     "DEF:min={file}:value:MIN",
2566     "DEF:max={file}:value:MAX",
2567     "AREA:max#$HalfBlue",
2568     "AREA:min#$Canvas",
2569     "LINE1:avg#$FullBlue:",
2570     'GPRINT:min:MIN:%5.1lf%sbytes Min,',
2571     'GPRINT:avg:AVERAGE:%5.1lf%sbytes Avg.,',
2572     'GPRINT:max:MAX:%5.1lf%sbytes Max,',
2573     'GPRINT:avg:LAST:%5.1lf%sbytes Last\l',
2574     ],
2575     vs_processes => [
2576     "DEF:avg={file}:value:AVERAGE",
2577     "DEF:min={file}:value:MIN",
2578     "DEF:max={file}:value:MAX",
2579     "AREA:max#$HalfBlue",
2580     "AREA:min#$Canvas",
2581     "LINE1:avg#$FullBlue:Processes",
2582     'GPRINT:min:MIN:%5.1lf Min,',
2583     'GPRINT:avg:AVERAGE:%5.1lf Avg.,',
2584     'GPRINT:max:MAX:%5.1lf Max,',
2585     'GPRINT:avg:LAST:%5.1lf Last\l',
2586     ],
2587     vmpage_number => ['-v', 'Pages',
2588     'DEF:avg={file}:value:AVERAGE',
2589     'DEF:min={file}:value:MIN',
2590     'DEF:max={file}:value:MAX',
2591     "AREA:max#$HalfBlue",
2592     "AREA:min#$Canvas",
2593     "LINE1:avg#$FullBlue:Number",
2594     'GPRINT:min:MIN:%4.1lf Min,',
2595     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
2596     'GPRINT:max:MAX:%4.1lf Max,',
2597     'GPRINT:avg:LAST:%4.1lf Last\l'
2598     ],
2599     vmpage_faults => [
2600     "DEF:minf_avg={file}:minflt:AVERAGE",
2601     "DEF:minf_min={file}:minflt:MIN",
2602     "DEF:minf_max={file}:minflt:MAX",
2603     "DEF:majf_avg={file}:majflt:AVERAGE",
2604     "DEF:majf_min={file}:majflt:MIN",
2605     "DEF:majf_max={file}:majflt:MAX",
2606     'CDEF:overlap=majf_avg,minf_avg,GT,minf_avg,majf_avg,IF',
2607     "AREA:majf_avg#$HalfGreen",
2608     "AREA:minf_avg#$HalfBlue",
2609     "AREA:overlap#$HalfBlueGreen",
2610     "LINE1:majf_avg#$FullGreen:Major",
2611     'GPRINT:majf_min:MIN:%5.1lf%s Min,',
2612     'GPRINT:majf_avg:AVERAGE:%5.1lf%s Avg,',
2613     'GPRINT:majf_max:MAX:%5.1lf%s Max,',
2614     'GPRINT:majf_avg:LAST:%5.1lf%s Last\l',
2615     "LINE1:minf_avg#$FullBlue:Minor",
2616     'GPRINT:minf_min:MIN:%5.1lf%s Min,',
2617     'GPRINT:minf_avg:AVERAGE:%5.1lf%s Avg,',
2618     'GPRINT:minf_max:MAX:%5.1lf%s Max,',
2619     'GPRINT:minf_avg:LAST:%5.1lf%s Last\l'
2620     ],
2621     vmpage_io => [
2622     "DEF:rpag_avg={file}:in:AVERAGE",
2623     "DEF:rpag_min={file}:in:MIN",
2624     "DEF:rpag_max={file}:in:MAX",
2625     "DEF:wpag_avg={file}:out:AVERAGE",
2626     "DEF:wpag_min={file}:out:MIN",
2627     "DEF:wpag_max={file}:out:MAX",
2628     'CDEF:overlap=wpag_avg,rpag_avg,GT,rpag_avg,wpag_avg,IF',
2629     "AREA:wpag_avg#$HalfGreen",
2630     "AREA:rpag_avg#$HalfBlue",
2631     "AREA:overlap#$HalfBlueGreen",
2632     "LINE1:wpag_avg#$FullGreen:OUT",
2633     'GPRINT:wpag_min:MIN:%5.1lf%s Min,',
2634     'GPRINT:wpag_avg:AVERAGE:%5.1lf%s Avg,',
2635     'GPRINT:wpag_max:MAX:%5.1lf%s Max,',
2636     'GPRINT:wpag_avg:LAST:%5.1lf%s Last\l',
2637     "LINE1:rpag_avg#$FullBlue:IN ",
2638     'GPRINT:rpag_min:MIN:%5.1lf%s Min,',
2639     'GPRINT:rpag_avg:AVERAGE:%5.1lf%s Avg,',
2640     'GPRINT:rpag_max:MAX:%5.1lf%s Max,',
2641     'GPRINT:rpag_avg:LAST:%5.1lf%s Last\l'
2642     ],
2643     vmpage_action => ['-v', 'Pages',
2644     'DEF:avg={file}:value:AVERAGE',
2645     'DEF:min={file}:value:MIN',
2646     'DEF:max={file}:value:MAX',
2647     "AREA:max#$HalfBlue",
2648     "AREA:min#$Canvas",
2649     "LINE1:avg#$FullBlue:Number",
2650     'GPRINT:min:MIN:%4.1lf Min,',
2651     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
2652     'GPRINT:max:MAX:%4.1lf Max,',
2653     'GPRINT:avg:LAST:%4.1lf Last\l'
2654     ],
2655     virt_cpu_total => ['-v', 'Milliseconds',
2656     'DEF:avg_raw={file}:ns:AVERAGE',
2657     'DEF:min_raw={file}:ns:MIN',
2658     'DEF:max_raw={file}:ns:MAX',
2659     'CDEF:avg=avg_raw,1000000,/',
2660     'CDEF:min=min_raw,1000000,/',
2661     'CDEF:max=max_raw,1000000,/',
2662     "AREA:avg#$HalfBlue",
2663     "LINE1:avg#$FullBlue:CPU time",
2664     'GPRINT:min:MIN:%4.1lf Min,',
2665     'GPRINT:avg:AVERAGE:%4.1lf Avg,',
2666     'GPRINT:max:MAX:%4.1lf Max,',
2667     'GPRINT:avg:LAST:%4.1lf Last\l'
2668     ],
2669   };
2670   $GraphDefs->{'if_multicast'} = $GraphDefs->{'ipt_packets'};
2671   $GraphDefs->{'if_tx_errors'} = $GraphDefs->{'if_rx_errors'};
2672   $GraphDefs->{'dns_qtype'} = $GraphDefs->{'dns_opcode'};
2673   $GraphDefs->{'dns_rcode'} = $GraphDefs->{'dns_opcode'};
2674   $GraphDefs->{'vmpage_io-memory'} = $GraphDefs->{'vmpage_io'};
2675   $GraphDefs->{'vmpage_io-swap'} = $GraphDefs->{'vmpage_io'};
2676   $GraphDefs->{'virt_cpu_total'} = $GraphDefs->{'virt_cpu_total'};
2678   $MetaGraphDefs->{'cpu'} = \&meta_graph_cpu;
2679   $MetaGraphDefs->{'dns_qtype'} = \&meta_graph_dns;
2680   $MetaGraphDefs->{'dns_rcode'} = \&meta_graph_dns;
2681   $MetaGraphDefs->{'if_rx_errors'} = \&meta_graph_if_rx_errors;
2682   $MetaGraphDefs->{'if_tx_errors'} = \&meta_graph_if_rx_errors;
2683   $MetaGraphDefs->{'memory'} = \&meta_graph_memory;
2684   $MetaGraphDefs->{'nfs_procedure'} = \&meta_graph_nfs_procedure;
2685   $MetaGraphDefs->{'ps_state'} = \&meta_graph_ps_state;
2686   $MetaGraphDefs->{'swap'} = \&meta_graph_swap;
2687   $MetaGraphDefs->{'mysql_commands'} = \&meta_graph_mysql_commands;
2688   $MetaGraphDefs->{'mysql_handler'} = \&meta_graph_mysql_commands;
2689   $MetaGraphDefs->{'tcp_connections'} = \&meta_graph_tcp_connections;
2690   $MetaGraphDefs->{'vmpage_number'} = \&meta_graph_vmpage_number;
2691   $MetaGraphDefs->{'vmpage_action'} = \&meta_graph_vmpage_action;
2692 } # load_graph_definitions
2694 sub meta_graph_generic_stack
2696   confess ("Wrong number of arguments") if (@_ != 2);
2698   my $opts = shift;
2699   my $sources = shift;
2700   my $i;
2702   my $timespan_str = _get_param_timespan ();
2703   my $timespan_int = (-1) * $ValidTimespan->{$timespan_str};
2705   $opts->{'title'} ||= 'Unknown title';
2706   $opts->{'rrd_opts'} ||= [];
2707   $opts->{'colors'} ||= {};
2709   my @cmd = ('-', '-a', 'PNG', '-s', $timespan_int,
2710     '-t', $opts->{'title'} || 'Unknown title',
2711     @RRDDefaultArgs, @{$opts->{'rrd_opts'}});
2713   my $max_inst_name = 0;
2714   my @vnames = ();
2716   for ($i = 0; $i < @$sources; $i++)
2717   {
2718     my $tmp = $sources->[$i]->{'name'};
2719     $tmp =~ tr/A-Za-z0-9\-_/_/c;
2720     $vnames[$i] = $i . $tmp;
2721   }
2723   for ($i = 0; $i < @$sources; $i++)
2724   {
2725     my $inst_data = $sources->[$i];
2726     my $inst_name = $inst_data->{'name'} || confess;
2727     my $file = $inst_data->{'file'} || confess;
2728     my $vname = $vnames[$i];
2730     if (length ($inst_name) > $max_inst_name)
2731     {
2732       $max_inst_name = length ($inst_name);
2733     }
2735     confess ("No such file: $file") if (!-e $file);
2737     push (@cmd,
2738       qq#DEF:${vname}_min=$file:value:MIN#,
2739       qq#DEF:${vname}_avg=$file:value:AVERAGE#,
2740       qq#DEF:${vname}_max=$file:value:MAX#,
2741       qq#CDEF:${vname}_nnl=${vname}_avg,UN,0,${vname}_avg,IF#);
2742   }
2744   {
2745     my $vname = $vnames[@vnames - 1];
2747     push (@cmd, qq#CDEF:${vname}_stk=${vname}_nnl#);
2748   }
2749   for (my $i = 1; $i < @$sources; $i++)
2750   {
2751     my $vname0 = $vnames[@vnames - ($i + 1)];
2752     my $vname1 = $vnames[@vnames - $i];
2754     push (@cmd, qq#CDEF:${vname0}_stk=${vname0}_nnl,${vname1}_stk,+#);
2755   }
2757   for (my $i = 0; $i < @$sources; $i++)
2758   {
2759     my $inst_data = $sources->[$i];
2760     my $inst_name = $inst_data->{'name'};
2762     my $vname = $vnames[$i];
2764     my $legend = sprintf ('%-*s', $max_inst_name, $inst_name);
2766     my $line_color;
2767     my $area_color;
2769     my $number_format = $opts->{'number_format'} || '%6.1lf';
2771     if (exists ($opts->{'colors'}{$inst_name}))
2772     {
2773       $line_color = $opts->{'colors'}{$inst_name};
2774       $area_color = _string_to_color ($line_color);
2775     }
2776     else
2777     {
2778       $area_color = _get_random_color ();
2779       $line_color = _color_to_string ($area_color);
2780     }
2781     $area_color = _color_to_string (_get_faded_color ($area_color));
2783     push (@cmd, qq(AREA:${vname}_stk#$area_color),
2784       qq(LINE1:${vname}_stk#$line_color:$legend),
2785       qq(GPRINT:${vname}_min:MIN:$number_format Min,),
2786       qq(GPRINT:${vname}_avg:AVERAGE:$number_format Avg,),
2787       qq(GPRINT:${vname}_max:MAX:$number_format Max,),
2788       qq(GPRINT:${vname}_avg:LAST:$number_format Last\\l),
2789     );
2790   }
2792   RRDs::graph (@cmd);
2793   if (my $errmsg = RRDs::error ())
2794   {
2795     confess ("RRDs::graph: $errmsg");
2796   }
2797 } # meta_graph_generic_stack
2799 sub meta_graph_cpu
2801   confess ("Wrong number of arguments") if (@_ != 5);
2803   my $host = shift;
2804   my $plugin = shift;
2805   my $plugin_instance = shift;
2806   my $type = shift;
2807   my $type_instances = shift;
2809   my $opts = {};
2810   my $sources = [];
2812   $opts->{'title'} = "$host/$plugin"
2813   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2815   $opts->{'rrd_opts'} = ['-v', 'Percent'];
2817   my @files = ();
2819   $opts->{'colors'} =
2820   {
2821     'idle'      => 'ffffff',
2822     'nice'      => '00e000',
2823     'user'      => '0000ff',
2824     'wait'      => 'ffb000',
2825     'system'    => 'ff0000',
2826     'softirq'   => 'ff00ff',
2827     'interrupt' => 'a000a0',
2828     'steal'     => '000000'
2829   };
2831   _custom_sort_arrayref ($type_instances,
2832     [qw(idle nice user wait system softirq interrupt steal)]);
2834   for (@$type_instances)
2835   {
2836     my $inst = $_;
2837     my $file = '';
2838     my $title = $opts->{'title'};
2840     for (@DataDirs)
2841     {
2842       if (-e "$_/$title-$inst.rrd")
2843       {
2844         $file = "$_/$title-$inst.rrd";
2845         last;
2846       }
2847     }
2848     confess ("No file found for $title") if ($file eq '');
2850     push (@$sources,
2851       {
2852         name => $inst,
2853         file => $file
2854       }
2855     );
2856   } # for (@$type_instances)
2858   return (meta_graph_generic_stack ($opts, $sources));
2859 } # meta_graph_cpu
2861 sub meta_graph_dns
2863   confess ("Wrong number of arguments") if (@_ != 5);
2865   my $host = shift;
2866   my $plugin = shift;
2867   my $plugin_instance = shift;
2868   my $type = shift;
2869   my $type_instances = shift;
2871   my $opts = {};
2872   my $sources = [];
2874   $opts->{'title'} = "$host/$plugin"
2875   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2877   $opts->{'rrd_opts'} = ['-v', 'Queries/s'];
2879   my @files = ();
2881   @$type_instances = sort @$type_instances;
2883   $opts->{'colors'} = _get_n_colors ($type_instances);
2885   for (@$type_instances)
2886   {
2887     my $inst = $_;
2888     my $file = '';
2889     my $title = $opts->{'title'};
2891     for (@DataDirs)
2892     {
2893       if (-e "$_/$title-$inst.rrd")
2894       {
2895         $file = "$_/$title-$inst.rrd";
2896         last;
2897       }
2898     }
2899     confess ("No file found for $title") if ($file eq '');
2901     push (@$sources,
2902       {
2903         name => $inst,
2904         file => $file
2905       }
2906     );
2907   } # for (@$type_instances)
2909   return (meta_graph_generic_stack ($opts, $sources));
2910 } # meta_graph_dns
2912 sub meta_graph_memory
2914   confess ("Wrong number of arguments") if (@_ != 5);
2916   my $host = shift;
2917   my $plugin = shift;
2918   my $plugin_instance = shift;
2919   my $type = shift;
2920   my $type_instances = shift;
2922   my $opts = {};
2923   my $sources = [];
2925   $opts->{'title'} = "$host/$plugin"
2926   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2927   $opts->{'number_format'} = '%5.1lf%s';
2929   $opts->{'rrd_opts'} = ['-b', '1024', '-v', 'Bytes'];
2931   my @files = ();
2933   $opts->{'colors'} =
2934   {
2935     'free'     => '00e000',
2936     'cached'   => '0000ff',
2937     'buffered' => 'ffb000',
2938     'used'     => 'ff0000'
2939   };
2941   _custom_sort_arrayref ($type_instances,
2942     [qw(free cached buffered used)]);
2944   for (@$type_instances)
2945   {
2946     my $inst = $_;
2947     my $file = '';
2948     my $title = $opts->{'title'};
2950     for (@DataDirs)
2951     {
2952       if (-e "$_/$title-$inst.rrd")
2953       {
2954         $file = "$_/$title-$inst.rrd";
2955         last;
2956       }
2957     }
2958     confess ("No file found for $title") if ($file eq '');
2960     push (@$sources,
2961       {
2962         name => $inst,
2963         file => $file
2964       }
2965     );
2966   } # for (@$type_instances)
2968   return (meta_graph_generic_stack ($opts, $sources));
2969 } # meta_graph_memory
2971 sub meta_graph_if_rx_errors
2973   confess ("Wrong number of arguments") if (@_ != 5);
2975   my $host = shift;
2976   my $plugin = shift;
2977   my $plugin_instance = shift;
2978   my $type = shift;
2979   my $type_instances = shift;
2981   my $opts = {};
2982   my $sources = [];
2984   $opts->{'title'} = "$host/$plugin"
2985   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2986   $opts->{'number_format'} = '%5.2lf';
2987   $opts->{'rrd_opts'} = ['-v', 'Errors/s'];
2989   my @files = ();
2991   for (sort @$type_instances)
2992   {
2993     my $inst = $_;
2994     my $file = '';
2995     my $title = $opts->{'title'};
2997     for (@DataDirs)
2998     {
2999       if (-e "$_/$title-$inst.rrd")
3000       {
3001         $file = "$_/$title-$inst.rrd";
3002         last;
3003       }
3004     }
3005     confess ("No file found for $title") if ($file eq '');
3007     push (@$sources,
3008       {
3009         name => $inst,
3010         file => $file
3011       }
3012     );
3013   } # for (@$type_instances)
3015   return (meta_graph_generic_stack ($opts, $sources));
3016 } # meta_graph_if_rx_errors
3018 sub meta_graph_mysql_commands
3020   confess ("Wrong number of arguments") if (@_ != 5);
3022   my $host = shift;
3023   my $plugin = shift;
3024   my $plugin_instance = shift;
3025   my $type = shift;
3026   my $type_instances = shift;
3028   my $opts = {};
3029   my $sources = [];
3031   $opts->{'title'} = "$host/$plugin"
3032   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
3033   $opts->{'number_format'} = '%5.2lf';
3035   my @files = ();
3037   for (sort @$type_instances)
3038   {
3039     my $inst = $_;
3040     my $file = '';
3041     my $title = $opts->{'title'};
3043     for (@DataDirs)
3044     {
3045       if (-e "$_/$title-$inst.rrd")
3046       {
3047         $file = "$_/$title-$inst.rrd";
3048         last;
3049       }
3050     }
3051     confess ("No file found for $title") if ($file eq '');
3053     push (@$sources,
3054       {
3055         name => $inst,
3056         file => $file
3057       }
3058     );
3059   } # for (@$type_instances)
3061   return (meta_graph_generic_stack ($opts, $sources));
3062 } # meta_graph_mysql_commands
3064 sub meta_graph_nfs_procedure
3066   confess ("Wrong number of arguments") if (@_ != 5);
3068   my $host = shift;
3069   my $plugin = shift;
3070   my $plugin_instance = shift;
3071   my $type = shift;
3072   my $type_instances = shift;
3074   my $opts = {};
3075   my $sources = [];
3077   $opts->{'title'} = "$host/$plugin"
3078   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
3079   $opts->{'number_format'} = '%5.1lf%s';
3081   my @files = ();
3083   for (sort @$type_instances)
3084   {
3085     my $inst = $_;
3086     my $file = '';
3087     my $title = $opts->{'title'};
3089     for (@DataDirs)
3090     {
3091       if (-e "$_/$title-$inst.rrd")
3092       {
3093         $file = "$_/$title-$inst.rrd";
3094         last;
3095       }
3096     }
3097     confess ("No file found for $title") if ($file eq '');
3099     push (@$sources,
3100       {
3101         name => $inst,
3102         file => $file
3103       }
3104     );
3105   } # for (@$type_instances)
3107   return (meta_graph_generic_stack ($opts, $sources));
3108 } # meta_graph_nfs_procedure
3110 sub meta_graph_ps_state
3112   confess ("Wrong number of arguments") if (@_ != 5);
3114   my $host = shift;
3115   my $plugin = shift;
3116   my $plugin_instance = shift;
3117   my $type = shift;
3118   my $type_instances = shift;
3120   my $opts = {};
3121   my $sources = [];
3123   $opts->{'title'} = "$host/$plugin"
3124   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
3125   $opts->{'rrd_opts'} = ['-v', 'Processes'];
3127   my @files = ();
3129   $opts->{'colors'} =
3130   {
3131     'Running'      => '00e000',
3132     'Sleeping'  => '0000ff',
3133     'Paging'      => 'ffb000',
3134     'Zombies'   => 'ff0000',
3135     'Blocked'   => 'ff00ff',
3136     'Stopped' => 'a000a0'
3137   };
3139   _custom_sort_arrayref ($type_instances,
3140     [qw(paging blocked zombies stopped running sleeping)]);
3142   for (@$type_instances)
3143   {
3144     my $inst = $_;
3145     my $file = '';
3146     my $title = $opts->{'title'};
3148     for (@DataDirs)
3149     {
3150       if (-e "$_/$title-$inst.rrd")
3151       {
3152         $file = "$_/$title-$inst.rrd";
3153         last;
3154       }
3155     }
3156     confess ("No file found for $title") if ($file eq '');
3158     push (@$sources,
3159       {
3160         name => ucfirst ($inst),
3161         file => $file
3162       }
3163     );
3164   } # for (@$type_instances)
3166   return (meta_graph_generic_stack ($opts, $sources));
3167 } # meta_graph_ps_state
3169 sub meta_graph_swap
3171   confess ("Wrong number of arguments") if (@_ != 5);
3173   my $host = shift;
3174   my $plugin = shift;
3175   my $plugin_instance = shift;
3176   my $type = shift;
3177   my $type_instances = shift;
3179   my $opts = {};
3180   my $sources = [];
3182   $opts->{'title'} = "$host/$plugin"
3183   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
3184   $opts->{'number_format'} = '%5.1lf%s';
3185   $opts->{'rrd_opts'} = ['-v', 'Bytes'];
3187   my @files = ();
3189   $opts->{'colors'} =
3190   {
3191     'Free'     => '00e000',
3192     'Cached'   => '0000ff',
3193     'Reserved' => 'ffb000',
3194     'Used'     => 'ff0000'
3195   };
3197   _custom_sort_arrayref ($type_instances,
3198     [qw(free cached reserved used)]);
3200   for (@$type_instances)
3201   {
3202     my $inst = $_;
3203     my $file = '';
3204     my $title = $opts->{'title'};
3206     for (@DataDirs)
3207     {
3208       if (-e "$_/$title-$inst.rrd")
3209       {
3210         $file = "$_/$title-$inst.rrd";
3211         last;
3212       }
3213     }
3214     confess ("No file found for $title") if ($file eq '');
3216     push (@$sources,
3217       {
3218         name => ucfirst ($inst),
3219         file => $file
3220       }
3221     );
3222   } # for (@$type_instances)
3224   return (meta_graph_generic_stack ($opts, $sources));
3225 } # meta_graph_swap
3227 sub meta_graph_tcp_connections
3229   confess ("Wrong number of arguments") if (@_ != 5);
3231   my $host = shift;
3232   my $plugin = shift;
3233   my $plugin_instance = shift;
3234   my $type = shift;
3235   my $type_instances = shift;
3237   my $opts = {};
3238   my $sources = [];
3240   $opts->{'title'} = "$host/$plugin"
3241   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
3242   $opts->{'number_format'} = '%6.2lf';
3244   $opts->{'rrd_opts'} = ['-v', 'Connections'];
3246   my @files = ();
3248   $opts->{'colors'} =
3249   {
3250     ESTABLISHED   => '00e000',
3251     SYN_SENT      => '00e0ff',
3252     SYN_RECV      => '00e0a0',
3253     FIN_WAIT1     => 'f000f0',
3254     FIN_WAIT2     => 'f000a0',
3255     TIME_WAIT     => 'ffb000',
3256     CLOSE         => '0000f0',
3257     CLOSE_WAIT    => '0000a0',
3258     LAST_ACK      => '000080',
3259     LISTEN        => 'ff0000',
3260     CLOSING       => '000000'
3261   };
3263   _custom_sort_arrayref ($type_instances,
3264     [reverse qw(ESTABLISHED SYN_SENT SYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSE
3265     CLOSE_WAIT LAST_ACK CLOSING LISTEN)]);
3267   for (@$type_instances)
3268   {
3269     my $inst = $_;
3270     my $file = '';
3271     my $title = $opts->{'title'};
3273     for (@DataDirs)
3274     {
3275       if (-e "$_/$title-$inst.rrd")
3276       {
3277         $file = "$_/$title-$inst.rrd";
3278         last;
3279       }
3280     }
3281     confess ("No file found for $title") if ($file eq '');
3283     push (@$sources,
3284       {
3285         name => $inst,
3286         file => $file
3287       }
3288     );
3289   } # for (@$type_instances)
3291   return (meta_graph_generic_stack ($opts, $sources));
3292 } # meta_graph_tcp_connections
3294 sub meta_graph_vmpage_number
3296   confess ("Wrong number of arguments") if (@_ != 5);
3298   my $host = shift;
3299   my $plugin = shift;
3300   my $plugin_instance = shift;
3301   my $type = shift;
3302   my $type_instances = shift;
3304   my $opts = {};
3305   my $sources = [];
3307   $opts->{'title'} = "$host/$plugin"
3308   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
3309   $opts->{'number_format'} = '%6.2lf';
3311   $opts->{'rrd_opts'} = ['-v', 'Pages'];
3313   my @files = ();
3315   $opts->{'colors'} =
3316   {
3317     anon_pages    => '00e000',
3318     bounce        => '00e0ff',
3319     dirty         => '00e0a0',
3320     file_pages    => 'f000f0',
3321     mapped        => 'f000a0',
3322     page_table_pages      => 'ffb000',
3323     slab          => '0000f0',
3324     unstable      => '0000a0',
3325     writeback     => 'ff0000',
3326   };
3328   _custom_sort_arrayref ($type_instances,
3329     [reverse qw(anon_pages bounce dirty file_pages mapped page_table_pages slab unstable writeback)]);
3331   for (@$type_instances)
3332   {
3333     my $inst = $_;
3334     my $file = '';
3335     my $title = $opts->{'title'};
3337     for (@DataDirs)
3338     {
3339       if (-e "$_/$title-$inst.rrd")
3340       {
3341         $file = "$_/$title-$inst.rrd";
3342         last;
3343       }
3344     }
3345     confess ("No file found for $title") if ($file eq '');
3347     push (@$sources,
3348       {
3349         name => $inst,
3350         file => $file
3351       }
3352     );
3353   } # for (@$type_instances)
3355   return (meta_graph_generic_stack ($opts, $sources));
3356 } # meta_graph_vmpage_number
3358 sub meta_graph_vmpage_action
3360   confess ("Wrong number of arguments") if (@_ != 5);
3362   my $host = shift;
3363   my $plugin = shift;
3364   my $plugin_instance = shift;
3365   my $type = shift;
3366   my $type_instances = shift;
3368   my $opts = {};
3369   my $sources = [];
3371   $opts->{'title'} = "$host/$plugin"
3372   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
3373   $opts->{'number_format'} = '%6.2lf';
3375   $opts->{'rrd_opts'} = ['-v', 'Pages'];
3377   my @files = ();
3379   $opts->{'colors'} =
3380   {
3381     activate      => '00e000',
3382     deactivate    => '00e0ff',
3383     free          => '00e0a0',
3384     alloc         => 'f000f0',
3385     refill        => 'f000a0',
3386     scan_direct   => 'ffb000',
3387     scan_kswapd   => '0000f0',
3388     steal         => '0000a0',
3389   };
3391   _custom_sort_arrayref ($type_instances,
3392     [reverse qw(activate deactivate alloc free refill scan_direct scan_kswapd steal)]);
3394   for (@$type_instances)
3395   {
3396     my $inst = $_;
3397     my $file = '';
3398     my $title = $opts->{'title'};
3400     for (@DataDirs)
3401     {
3402       if (-e "$_/$title-$inst.rrd")
3403       {
3404         $file = "$_/$title-$inst.rrd";
3405         last;
3406       }
3407     }
3408     confess ("No file found for $title") if ($file eq '');
3410     push (@$sources,
3411       {
3412         name => $inst,
3413         file => $file
3414       }
3415     );
3416   } # for (@$type_instances)
3418   return (meta_graph_generic_stack ($opts, $sources));
3419 } # meta_graph_vmpage_action
3420 # vim: shiftwidth=2:softtabstop=2:tabstop=8