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