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