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