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