33f13510f88e06d2c158f81ebdf93beb850ad331
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 humidity => ['-v', 'Percent',
1293 'DEF:temp_avg={file}:value:AVERAGE',
1294 'DEF:temp_min={file}:value:MIN',
1295 'DEF:temp_max={file}:value:MAX',
1296 "AREA:temp_max#$HalfGreen",
1297 "AREA:temp_min#$Canvas",
1298 "LINE1:temp_avg#$FullGreen:Temperature",
1299 'GPRINT:temp_min:MIN:%4.1lf%% Min,',
1300 'GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,',
1301 'GPRINT:temp_max:MAX:%4.1lf%% Max,',
1302 'GPRINT:temp_avg:LAST:%4.1lf%% Last\l'
1303 ],
1304 if_errors => ['-v', 'Errors/s',
1305 'DEF:tx_min={file}:tx:MIN',
1306 'DEF:tx_avg={file}:tx:AVERAGE',
1307 'DEF:tx_max={file}:tx:MAX',
1308 'DEF:rx_min={file}:rx:MIN',
1309 'DEF:rx_avg={file}:rx:AVERAGE',
1310 'DEF:rx_max={file}:rx:MAX',
1311 'CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF',
1312 'CDEF:mytime=tx_avg,TIME,TIME,IF',
1313 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1314 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1315 'CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*',
1316 'CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+',
1317 'CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*',
1318 'CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+',
1319 "AREA:tx_avg#$HalfGreen",
1320 "AREA:rx_avg#$HalfBlue",
1321 "AREA:overlap#$HalfBlueGreen",
1322 "LINE1:tx_avg#$FullGreen:TX",
1323 'GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,',
1324 'GPRINT:tx_max:MAX:%5.1lf%s Max,',
1325 'GPRINT:tx_avg:LAST:%5.1lf%s Last',
1326 'GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)\l',
1327 "LINE1:rx_avg#$FullBlue:RX",
1328 #'GPRINT:rx_min:MIN:%5.1lf %s Min,',
1329 'GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,',
1330 'GPRINT:rx_max:MAX:%5.1lf%s Max,',
1331 'GPRINT:rx_avg:LAST:%5.1lf%s Last',
1332 'GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)\l'
1333 ],
1334 if_collisions => ['-v', 'Collisions/s',
1335 'DEF:min_raw={file}:value:MIN',
1336 'DEF:avg_raw={file}:value:AVERAGE',
1337 'DEF:max_raw={file}:value:MAX',
1338 'CDEF:min=min_raw,8,*',
1339 'CDEF:avg=avg_raw,8,*',
1340 'CDEF:max=max_raw,8,*',
1341 "AREA:max#$HalfBlue",
1342 "AREA:min#$Canvas",
1343 "LINE1:avg#$FullBlue:Collisions/s",
1344 'GPRINT:min:MIN:%5.1lf %s Min,',
1345 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
1346 'GPRINT:max:MAX:%5.1lf%s Max,',
1347 'GPRINT:avg:LAST:%5.1lf%s Last\l'
1348 ],
1349 if_dropped => ['-v', 'Packets/s',
1350 'DEF:tx_min={file}:tx:MIN',
1351 'DEF:tx_avg={file}:tx:AVERAGE',
1352 'DEF:tx_max={file}:tx:MAX',
1353 'DEF:rx_min={file}:rx:MIN',
1354 'DEF:rx_avg={file}:rx:AVERAGE',
1355 'DEF:rx_max={file}:rx:MAX',
1356 'CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF',
1357 'CDEF:mytime=tx_avg,TIME,TIME,IF',
1358 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1359 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1360 'CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*',
1361 'CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+',
1362 'CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*',
1363 'CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+',
1364 "AREA:tx_avg#$HalfGreen",
1365 "AREA:rx_avg#$HalfBlue",
1366 "AREA:overlap#$HalfBlueGreen",
1367 "LINE1:tx_avg#$FullGreen:TX",
1368 'GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,',
1369 'GPRINT:tx_max:MAX:%5.1lf%s Max,',
1370 'GPRINT:tx_avg:LAST:%5.1lf%s Last',
1371 'GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)\l',
1372 "LINE1:rx_avg#$FullBlue:RX",
1373 #'GPRINT:rx_min:MIN:%5.1lf %s Min,',
1374 'GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,',
1375 'GPRINT:rx_max:MAX:%5.1lf%s Max,',
1376 'GPRINT:rx_avg:LAST:%5.1lf%s Last',
1377 'GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)\l'
1378 ],
1379 if_packets => ['-v', 'Packets/s',
1380 'DEF:tx_min={file}:tx:MIN',
1381 'DEF:tx_avg={file}:tx:AVERAGE',
1382 'DEF:tx_max={file}:tx:MAX',
1383 'DEF:rx_min={file}:rx:MIN',
1384 'DEF:rx_avg={file}:rx:AVERAGE',
1385 'DEF:rx_max={file}:rx:MAX',
1386 'CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF',
1387 'CDEF:mytime=tx_avg,TIME,TIME,IF',
1388 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1389 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1390 'CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*',
1391 'CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+',
1392 'CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*',
1393 'CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+',
1394 "AREA:tx_avg#$HalfGreen",
1395 "AREA:rx_avg#$HalfBlue",
1396 "AREA:overlap#$HalfBlueGreen",
1397 "LINE1:tx_avg#$FullGreen:TX",
1398 'GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,',
1399 'GPRINT:tx_max:MAX:%5.1lf%s Max,',
1400 'GPRINT:tx_avg:LAST:%5.1lf%s Last',
1401 'GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)\l',
1402 "LINE1:rx_avg#$FullBlue:RX",
1403 #'GPRINT:rx_min:MIN:%5.1lf %s Min,',
1404 'GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,',
1405 'GPRINT:rx_max:MAX:%5.1lf%s Max,',
1406 'GPRINT:rx_avg:LAST:%5.1lf%s Last',
1407 'GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)\l'
1408 ],
1409 if_rx_errors => ['-v', 'Errors/s',
1410 'DEF:min={file}:value:MIN',
1411 'DEF:avg={file}:value:AVERAGE',
1412 'DEF:max={file}:value:MAX',
1413 'CDEF:mytime=avg,TIME,TIME,IF',
1414 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1415 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1416 'CDEF:avg_sample=avg,UN,0,avg,IF,sample_len,*',
1417 'CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+',
1418 "AREA:avg#$HalfBlue",
1419 "LINE1:avg#$FullBlue:Errors/s",
1420 'GPRINT:avg:AVERAGE:%3.1lf%s Avg,',
1421 'GPRINT:max:MAX:%3.1lf%s Max,',
1422 'GPRINT:avg:LAST:%3.1lf%s Last',
1423 'GPRINT:avg_sum:LAST:(ca. %2.0lf%s Total)\l'
1424 ],
1425 ipt_bytes => ['-v', 'Bits/s',
1426 'DEF:min_raw={file}:value:MIN',
1427 'DEF:avg_raw={file}:value:AVERAGE',
1428 'DEF:max_raw={file}:value:MAX',
1429 'CDEF:min=min_raw,8,*',
1430 'CDEF:avg=avg_raw,8,*',
1431 'CDEF:max=max_raw,8,*',
1432 'CDEF:mytime=avg_raw,TIME,TIME,IF',
1433 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1434 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1435 'CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*',
1436 'CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+',
1437 "AREA:max#$HalfBlue",
1438 "AREA:min#$Canvas",
1439 "LINE1:avg#$FullBlue:Bits/s",
1440 #'GPRINT:min:MIN:%5.1lf %s Min,',
1441 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
1442 'GPRINT:max:MAX:%5.1lf%s Max,',
1443 'GPRINT:avg:LAST:%5.1lf%s Last',
1444 'GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1445 ],
1446 ipt_packets => ['-v', 'Packets/s',
1447 'DEF:min_raw={file}:value:MIN',
1448 'DEF:avg_raw={file}:value:AVERAGE',
1449 'DEF:max_raw={file}:value:MAX',
1450 'CDEF:min=min_raw,8,*',
1451 'CDEF:avg=avg_raw,8,*',
1452 'CDEF:max=max_raw,8,*',
1453 "AREA:max#$HalfBlue",
1454 "AREA:min#$Canvas",
1455 "LINE1:avg#$FullBlue:Packets/s",
1456 'GPRINT:min:MIN:%5.1lf %s Min,',
1457 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
1458 'GPRINT:max:MAX:%5.1lf%s Max,',
1459 'GPRINT:avg:LAST:%5.1lf%s Last\l'
1460 ],
1461 irq => ['-v', 'Issues/s',
1462 'DEF:avg={file}:value:AVERAGE',
1463 'DEF:min={file}:value:MIN',
1464 'DEF:max={file}:value:MAX',
1465 "AREA:max#$HalfBlue",
1466 "AREA:min#$Canvas",
1467 "LINE1:avg#$FullBlue:Issues/s",
1468 'GPRINT:min:MIN:%6.2lf Min,',
1469 'GPRINT:avg:AVERAGE:%6.2lf Avg,',
1470 'GPRINT:max:MAX:%6.2lf Max,',
1471 'GPRINT:avg:LAST:%6.2lf Last\l'
1472 ],
1473 load => ['-v', 'System load',
1474 'DEF:s_avg={file}:shortterm:AVERAGE',
1475 'DEF:s_min={file}:shortterm:MIN',
1476 'DEF:s_max={file}:shortterm:MAX',
1477 'DEF:m_avg={file}:midterm:AVERAGE',
1478 'DEF:m_min={file}:midterm:MIN',
1479 'DEF:m_max={file}:midterm:MAX',
1480 'DEF:l_avg={file}:longterm:AVERAGE',
1481 'DEF:l_min={file}:longterm:MIN',
1482 'DEF:l_max={file}:longterm:MAX',
1483 "AREA:s_max#$HalfGreen",
1484 "AREA:s_min#$Canvas",
1485 "LINE1:s_avg#$FullGreen: 1m average",
1486 'GPRINT:s_min:MIN:%4.2lf Min,',
1487 'GPRINT:s_avg:AVERAGE:%4.2lf Avg,',
1488 'GPRINT:s_max:MAX:%4.2lf Max,',
1489 'GPRINT:s_avg:LAST:%4.2lf Last\n',
1490 "LINE1:m_avg#$FullBlue: 5m average",
1491 'GPRINT:m_min:MIN:%4.2lf Min,',
1492 'GPRINT:m_avg:AVERAGE:%4.2lf Avg,',
1493 'GPRINT:m_max:MAX:%4.2lf Max,',
1494 'GPRINT:m_avg:LAST:%4.2lf Last\n',
1495 "LINE1:l_avg#$FullRed:15m average",
1496 'GPRINT:l_min:MIN:%4.2lf Min,',
1497 'GPRINT:l_avg:AVERAGE:%4.2lf Avg,',
1498 'GPRINT:l_max:MAX:%4.2lf Max,',
1499 'GPRINT:l_avg:LAST:%4.2lf Last'
1500 ],
1501 load_percent => [
1502 'DEF:avg={file}:percent:AVERAGE',
1503 'DEF:min={file}:percent:MIN',
1504 'DEF:max={file}:percent:MAX',
1505 "AREA:max#$HalfBlue",
1506 "AREA:min#$Canvas",
1507 "LINE1:avg#$FullBlue:Load",
1508 'GPRINT:min:MIN:%5.1lf%s%% Min,',
1509 'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
1510 'GPRINT:max:MAX:%5.1lf%s%% Max,',
1511 'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
1512 ],
1513 mails => ['DEF:rawgood={file}:good:AVERAGE',
1514 'DEF:rawspam={file}:spam:AVERAGE',
1515 'CDEF:good=rawgood,UN,0,rawgood,IF',
1516 'CDEF:spam=rawspam,UN,0,rawspam,IF',
1517 'CDEF:negspam=spam,-1,*',
1518 "AREA:good#$HalfGreen",
1519 "LINE1:good#$FullGreen:Good mails",
1520 'GPRINT:good:AVERAGE:%4.1lf Avg,',
1521 'GPRINT:good:MAX:%4.1lf Max,',
1522 'GPRINT:good:LAST:%4.1lf Last\n',
1523 "AREA:negspam#$HalfRed",
1524 "LINE1:negspam#$FullRed:Spam mails",
1525 'GPRINT:spam:AVERAGE:%4.1lf Avg,',
1526 'GPRINT:spam:MAX:%4.1lf Max,',
1527 'GPRINT:spam:LAST:%4.1lf Last',
1528 'HRULE:0#000000'
1529 ],
1530 memory => ['-b', '1024', '-v', 'Bytes',
1531 'DEF:avg={file}:value:AVERAGE',
1532 'DEF:min={file}:value:MIN',
1533 'DEF:max={file}:value:MAX',
1534 "AREA:max#$HalfBlue",
1535 "AREA:min#$Canvas",
1536 "LINE1:avg#$FullBlue:Memory",
1537 'GPRINT:min:MIN:%5.1lf%sbyte Min,',
1538 'GPRINT:avg:AVERAGE:%5.1lf%sbyte Avg,',
1539 'GPRINT:max:MAX:%5.1lf%sbyte Max,',
1540 'GPRINT:avg:LAST:%5.1lf%sbyte Last\l'
1541 ],
1542 old_memory => [
1543 'DEF:used_avg={file}:used:AVERAGE',
1544 'DEF:free_avg={file}:free:AVERAGE',
1545 'DEF:buffers_avg={file}:buffers:AVERAGE',
1546 'DEF:cached_avg={file}:cached:AVERAGE',
1547 'DEF:used_min={file}:used:MIN',
1548 'DEF:free_min={file}:free:MIN',
1549 'DEF:buffers_min={file}:buffers:MIN',
1550 'DEF:cached_min={file}:cached:MIN',
1551 'DEF:used_max={file}:used:MAX',
1552 'DEF:free_max={file}:free:MAX',
1553 'DEF:buffers_max={file}:buffers:MAX',
1554 'DEF:cached_max={file}:cached:MAX',
1555 'CDEF:cached_avg_nn=cached_avg,UN,0,cached_avg,IF',
1556 'CDEF:buffers_avg_nn=buffers_avg,UN,0,buffers_avg,IF',
1557 'CDEF:free_cached_buffers_used=free_avg,cached_avg_nn,+,buffers_avg_nn,+,used_avg,+',
1558 'CDEF:cached_buffers_used=cached_avg,buffers_avg_nn,+,used_avg,+',
1559 'CDEF:buffers_used=buffers_avg,used_avg,+',
1560 "AREA:free_cached_buffers_used#$HalfGreen",
1561 "AREA:cached_buffers_used#$HalfBlue",
1562 "AREA:buffers_used#$HalfYellow",
1563 "AREA:used_avg#$HalfRed",
1564 "LINE1:free_cached_buffers_used#$FullGreen:Free ",
1565 'GPRINT:free_min:MIN:%5.1lf%s Min,',
1566 'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
1567 'GPRINT:free_max:MAX:%5.1lf%s Max,',
1568 'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
1569 "LINE1:cached_buffers_used#$FullBlue:Page cache ",
1570 'GPRINT:cached_min:MIN:%5.1lf%s Min,',
1571 'GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,',
1572 'GPRINT:cached_max:MAX:%5.1lf%s Max,',
1573 'GPRINT:cached_avg:LAST:%5.1lf%s Last\n',
1574 "LINE1:buffers_used#$FullYellow:Buffer cache",
1575 'GPRINT:buffers_min:MIN:%5.1lf%s Min,',
1576 'GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,',
1577 'GPRINT:buffers_max:MAX:%5.1lf%s Max,',
1578 'GPRINT:buffers_avg:LAST:%5.1lf%s Last\n',
1579 "LINE1:used_avg#$FullRed:Used ",
1580 'GPRINT:used_min:MIN:%5.1lf%s Min,',
1581 'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
1582 'GPRINT:used_max:MAX:%5.1lf%s Max,',
1583 'GPRINT:used_avg:LAST:%5.1lf%s Last'
1584 ],
1585 mysql_commands => ['-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_handler => ['-v', 'Issues/s',
1598 "DEF:val_avg={file}:value:AVERAGE",
1599 "DEF:val_min={file}:value:MIN",
1600 "DEF:val_max={file}:value:MAX",
1601 "AREA:val_max#$HalfBlue",
1602 "AREA:val_min#$Canvas",
1603 "LINE1:val_avg#$FullBlue:Issues/s",
1604 'GPRINT:val_min:MIN:%5.2lf Min,',
1605 'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
1606 'GPRINT:val_max:MAX:%5.2lf Max,',
1607 'GPRINT:val_avg:LAST:%5.2lf Last'
1608 ],
1609 mysql_octets => ['-v', 'Bits/s',
1610 'DEF:out_min={file}:tx:MIN',
1611 'DEF:out_avg={file}:tx:AVERAGE',
1612 'DEF:out_max={file}:tx:MAX',
1613 'DEF:inc_min={file}:rx:MIN',
1614 'DEF:inc_avg={file}:rx:AVERAGE',
1615 'DEF:inc_max={file}:rx:MAX',
1616 'CDEF:mytime=out_avg,TIME,TIME,IF',
1617 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1618 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1619 'CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*',
1620 'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
1621 'CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*',
1622 'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
1623 'CDEF:out_bit_min=out_min,8,*',
1624 'CDEF:out_bit_avg=out_avg,8,*',
1625 'CDEF:out_bit_max=out_max,8,*',
1626 'CDEF:inc_bit_min=inc_min,8,*',
1627 'CDEF:inc_bit_avg=inc_avg,8,*',
1628 'CDEF:inc_bit_max=inc_max,8,*',
1629 'CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF',
1630 "AREA:out_bit_avg#$HalfGreen",
1631 "AREA:inc_bit_avg#$HalfBlue",
1632 "AREA:overlap#$HalfBlueGreen",
1633 "LINE1:out_bit_avg#$FullGreen:Written",
1634 'GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,',
1635 'GPRINT:out_bit_max:MAX:%5.1lf%s Max,',
1636 'GPRINT:out_bit_avg:LAST:%5.1lf%s Last',
1637 'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
1638 "LINE1:inc_bit_avg#$FullBlue:Read ",
1639 'GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,',
1640 'GPRINT:inc_bit_max:MAX:%5.1lf%s Max,',
1641 'GPRINT:inc_bit_avg:LAST:%5.1lf%s Last',
1642 'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1643 ],
1644 mysql_qcache => ['-v', 'Queries/s',
1645 "DEF:hits_min={file}:hits:MIN",
1646 "DEF:hits_avg={file}:hits:AVERAGE",
1647 "DEF:hits_max={file}:hits:MAX",
1648 "DEF:inserts_min={file}:inserts:MIN",
1649 "DEF:inserts_avg={file}:inserts:AVERAGE",
1650 "DEF:inserts_max={file}:inserts:MAX",
1651 "DEF:not_cached_min={file}:not_cached:MIN",
1652 "DEF:not_cached_avg={file}:not_cached:AVERAGE",
1653 "DEF:not_cached_max={file}:not_cached:MAX",
1654 "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN",
1655 "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE",
1656 "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX",
1657 "DEF:queries_min={file}:queries_in_cache:MIN",
1658 "DEF:queries_avg={file}:queries_in_cache:AVERAGE",
1659 "DEF:queries_max={file}:queries_in_cache:MAX",
1660 "CDEF:unknown=queries_avg,UNKN,+",
1661 "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+",
1662 "CDEF:inserts_agg=hits_avg,inserts_avg,+",
1663 "CDEF:hits_agg=hits_avg",
1664 "AREA:not_cached_agg#$HalfYellow",
1665 "AREA:inserts_agg#$HalfBlue",
1666 "AREA:hits_agg#$HalfGreen",
1667 "LINE1:not_cached_agg#$FullYellow:Not Cached ",
1668 'GPRINT:not_cached_min:MIN:%5.2lf Min,',
1669 'GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,',
1670 'GPRINT:not_cached_max:MAX:%5.2lf Max,',
1671 'GPRINT:not_cached_avg:LAST:%5.2lf Last\l',
1672 "LINE1:inserts_agg#$FullBlue:Inserts ",
1673 'GPRINT:inserts_min:MIN:%5.2lf Min,',
1674 'GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,',
1675 'GPRINT:inserts_max:MAX:%5.2lf Max,',
1676 'GPRINT:inserts_avg:LAST:%5.2lf Last\l',
1677 "LINE1:hits_agg#$FullGreen:Hits ",
1678 'GPRINT:hits_min:MIN:%5.2lf Min,',
1679 'GPRINT:hits_avg:AVERAGE:%5.2lf Avg,',
1680 'GPRINT:hits_max:MAX:%5.2lf Max,',
1681 'GPRINT:hits_avg:LAST:%5.2lf Last\l',
1682 "LINE1:lowmem_prunes_avg#$FullRed:Lowmem Prunes ",
1683 'GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,',
1684 'GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,',
1685 'GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,',
1686 'GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\l',
1687 "LINE1:unknown#$Canvas:Queries in cache",
1688 'GPRINT:queries_min:MIN:%5.0lf Min,',
1689 'GPRINT:queries_avg:AVERAGE:%5.0lf Avg,',
1690 'GPRINT:queries_max:MAX:%5.0lf Max,',
1691 'GPRINT:queries_avg:LAST:%5.0lf Last\l'
1692 ],
1693 mysql_threads => ['-v', 'Threads',
1694 "DEF:running_min={file}:running:MIN",
1695 "DEF:running_avg={file}:running:AVERAGE",
1696 "DEF:running_max={file}:running:MAX",
1697 "DEF:connected_min={file}:connected:MIN",
1698 "DEF:connected_avg={file}:connected:AVERAGE",
1699 "DEF:connected_max={file}:connected:MAX",
1700 "DEF:cached_min={file}:cached:MIN",
1701 "DEF:cached_avg={file}:cached:AVERAGE",
1702 "DEF:cached_max={file}:cached:MAX",
1703 "DEF:created_min={file}:created:MIN",
1704 "DEF:created_avg={file}:created:AVERAGE",
1705 "DEF:created_max={file}:created:MAX",
1706 "CDEF:unknown=created_avg,UNKN,+",
1707 "CDEF:cached_agg=connected_avg,cached_avg,+",
1708 "AREA:cached_agg#$HalfGreen",
1709 "AREA:connected_avg#$HalfBlue",
1710 "AREA:running_avg#$HalfRed",
1711 "LINE1:cached_agg#$FullGreen:Cached ",
1712 'GPRINT:cached_min:MIN:%5.1lf Min,',
1713 'GPRINT:cached_avg:AVERAGE:%5.1lf Avg,',
1714 'GPRINT:cached_max:MAX:%5.1lf Max,',
1715 'GPRINT:cached_avg:LAST:%5.1lf Last\l',
1716 "LINE1:connected_avg#$FullBlue:Connected",
1717 'GPRINT:connected_min:MIN:%5.1lf Min,',
1718 'GPRINT:connected_avg:AVERAGE:%5.1lf Avg,',
1719 'GPRINT:connected_max:MAX:%5.1lf Max,',
1720 'GPRINT:connected_avg:LAST:%5.1lf Last\l',
1721 "LINE1:running_avg#$FullRed:Running ",
1722 'GPRINT:running_min:MIN:%5.1lf Min,',
1723 'GPRINT:running_avg:AVERAGE:%5.1lf Avg,',
1724 'GPRINT:running_max:MAX:%5.1lf Max,',
1725 'GPRINT:running_avg:LAST:%5.1lf Last\l',
1726 "LINE1:unknown#$Canvas:Created ",
1727 'GPRINT:created_min:MIN:%5.0lf Min,',
1728 'GPRINT:created_avg:AVERAGE:%5.0lf Avg,',
1729 'GPRINT:created_max:MAX:%5.0lf Max,',
1730 'GPRINT:created_avg:LAST:%5.0lf Last\l'
1731 ],
1732 nfs_procedure => ['-v', 'Issues/s',
1733 'DEF:avg={file}:value:AVERAGE',
1734 'DEF:min={file}:value:MIN',
1735 'DEF:max={file}:value:MAX',
1736 "AREA:max#$HalfBlue",
1737 "AREA:min#$Canvas",
1738 "LINE1:avg#$FullBlue:Issues/s",
1739 'GPRINT:min:MIN:%6.2lf Min,',
1740 'GPRINT:avg:AVERAGE:%6.2lf Avg,',
1741 'GPRINT:max:MAX:%6.2lf Max,',
1742 'GPRINT:avg:LAST:%6.2lf Last\l'
1743 ],
1744 nfs3_procedures => [
1745 "DEF:null_avg={file}:null:AVERAGE",
1746 "DEF:getattr_avg={file}:getattr:AVERAGE",
1747 "DEF:setattr_avg={file}:setattr:AVERAGE",
1748 "DEF:lookup_avg={file}:lookup:AVERAGE",
1749 "DEF:access_avg={file}:access:AVERAGE",
1750 "DEF:readlink_avg={file}:readlink:AVERAGE",
1751 "DEF:read_avg={file}:read:AVERAGE",
1752 "DEF:write_avg={file}:write:AVERAGE",
1753 "DEF:create_avg={file}:create:AVERAGE",
1754 "DEF:mkdir_avg={file}:mkdir:AVERAGE",
1755 "DEF:symlink_avg={file}:symlink:AVERAGE",
1756 "DEF:mknod_avg={file}:mknod:AVERAGE",
1757 "DEF:remove_avg={file}:remove:AVERAGE",
1758 "DEF:rmdir_avg={file}:rmdir:AVERAGE",
1759 "DEF:rename_avg={file}:rename:AVERAGE",
1760 "DEF:link_avg={file}:link:AVERAGE",
1761 "DEF:readdir_avg={file}:readdir:AVERAGE",
1762 "DEF:readdirplus_avg={file}:readdirplus:AVERAGE",
1763 "DEF:fsstat_avg={file}:fsstat:AVERAGE",
1764 "DEF:fsinfo_avg={file}:fsinfo:AVERAGE",
1765 "DEF:pathconf_avg={file}:pathconf:AVERAGE",
1766 "DEF:commit_avg={file}:commit:AVERAGE",
1767 "DEF:null_max={file}:null:MAX",
1768 "DEF:getattr_max={file}:getattr:MAX",
1769 "DEF:setattr_max={file}:setattr:MAX",
1770 "DEF:lookup_max={file}:lookup:MAX",
1771 "DEF:access_max={file}:access:MAX",
1772 "DEF:readlink_max={file}:readlink:MAX",
1773 "DEF:read_max={file}:read:MAX",
1774 "DEF:write_max={file}:write:MAX",
1775 "DEF:create_max={file}:create:MAX",
1776 "DEF:mkdir_max={file}:mkdir:MAX",
1777 "DEF:symlink_max={file}:symlink:MAX",
1778 "DEF:mknod_max={file}:mknod:MAX",
1779 "DEF:remove_max={file}:remove:MAX",
1780 "DEF:rmdir_max={file}:rmdir:MAX",
1781 "DEF:rename_max={file}:rename:MAX",
1782 "DEF:link_max={file}:link:MAX",
1783 "DEF:readdir_max={file}:readdir:MAX",
1784 "DEF:readdirplus_max={file}:readdirplus:MAX",
1785 "DEF:fsstat_max={file}:fsstat:MAX",
1786 "DEF:fsinfo_max={file}:fsinfo:MAX",
1787 "DEF:pathconf_max={file}:pathconf:MAX",
1788 "DEF:commit_max={file}:commit:MAX",
1789 "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,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
1790 "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,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
1791 "CDEF:stack_read=read_avg",
1792 "CDEF:stack_getattr=stack_read,getattr_avg,+",
1793 "CDEF:stack_access=stack_getattr,access_avg,+",
1794 "CDEF:stack_lookup=stack_access,lookup_avg,+",
1795 "CDEF:stack_write=stack_lookup,write_avg,+",
1796 "CDEF:stack_commit=stack_write,commit_avg,+",
1797 "CDEF:stack_setattr=stack_commit,setattr_avg,+",
1798 "CDEF:stack_other=stack_setattr,other_avg,+",
1799 "AREA:stack_other#$HalfRed",
1800 "AREA:stack_setattr#$HalfGreen",
1801 "AREA:stack_commit#$HalfYellow",
1802 "AREA:stack_write#$HalfGreen",
1803 "AREA:stack_lookup#$HalfBlue",
1804 "AREA:stack_access#$HalfMagenta",
1805 "AREA:stack_getattr#$HalfCyan",
1806 "AREA:stack_read#$HalfBlue",
1807 "LINE1:stack_other#$FullRed:Other ",
1808 'GPRINT:other_max:MAX:%5.1lf Max,',
1809 'GPRINT:other_avg:AVERAGE:%5.1lf Avg,',
1810 'GPRINT:other_avg:LAST:%5.1lf Last\l',
1811 "LINE1:stack_setattr#$FullGreen:setattr",
1812 'GPRINT:setattr_max:MAX:%5.1lf Max,',
1813 'GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,',
1814 'GPRINT:setattr_avg:LAST:%5.1lf Last\l',
1815 "LINE1:stack_commit#$FullYellow:commit ",
1816 'GPRINT:commit_max:MAX:%5.1lf Max,',
1817 'GPRINT:commit_avg:AVERAGE:%5.1lf Avg,',
1818 'GPRINT:commit_avg:LAST:%5.1lf Last\l',
1819 "LINE1:stack_write#$FullGreen:write ",
1820 'GPRINT:write_max:MAX:%5.1lf Max,',
1821 'GPRINT:write_avg:AVERAGE:%5.1lf Avg,',
1822 'GPRINT:write_avg:LAST:%5.1lf Last\l',
1823 "LINE1:stack_lookup#$FullBlue:lookup ",
1824 'GPRINT:lookup_max:MAX:%5.1lf Max,',
1825 'GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,',
1826 'GPRINT:lookup_avg:LAST:%5.1lf Last\l',
1827 "LINE1:stack_access#$FullMagenta:access ",
1828 'GPRINT:access_max:MAX:%5.1lf Max,',
1829 'GPRINT:access_avg:AVERAGE:%5.1lf Avg,',
1830 'GPRINT:access_avg:LAST:%5.1lf Last\l',
1831 "LINE1:stack_getattr#$FullCyan:getattr",
1832 'GPRINT:getattr_max:MAX:%5.1lf Max,',
1833 'GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,',
1834 'GPRINT:getattr_avg:LAST:%5.1lf Last\l',
1835 "LINE1:stack_read#$FullBlue:read ",
1836 'GPRINT:read_max:MAX:%5.1lf Max,',
1837 'GPRINT:read_avg:AVERAGE:%5.1lf Avg,',
1838 'GPRINT:read_avg:LAST:%5.1lf Last\l'
1839 ],
1840 opcode => [
1841 'DEF:avg={file}:value:AVERAGE',
1842 'DEF:min={file}:value:MIN',
1843 'DEF:max={file}:value:MAX',
1844 "AREA:max#$HalfBlue",
1845 "AREA:min#$Canvas",
1846 "LINE1:avg#$FullBlue:Queries/s",
1847 'GPRINT:min:MIN:%9.3lf Min,',
1848 'GPRINT:avg:AVERAGE:%9.3lf Average,',
1849 'GPRINT:max:MAX:%9.3lf Max,',
1850 'GPRINT:avg:LAST:%9.3lf Last\l'
1851 ],
1852 partition => [
1853 "DEF:rbyte_avg={file}:rbytes:AVERAGE",
1854 "DEF:rbyte_min={file}:rbytes:MIN",
1855 "DEF:rbyte_max={file}:rbytes:MAX",
1856 "DEF:wbyte_avg={file}:wbytes:AVERAGE",
1857 "DEF:wbyte_min={file}:wbytes:MIN",
1858 "DEF:wbyte_max={file}:wbytes:MAX",
1859 'CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF',
1860 "AREA:wbyte_avg#$HalfGreen",
1861 "AREA:rbyte_avg#$HalfBlue",
1862 "AREA:overlap#$HalfBlueGreen",
1863 "LINE1:wbyte_avg#$FullGreen:Write",
1864 'GPRINT:wbyte_min:MIN:%5.1lf%s Min,',
1865 'GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,',
1866 'GPRINT:wbyte_max:MAX:%5.1lf%s Max,',
1867 'GPRINT:wbyte_avg:LAST:%5.1lf%s Last\l',
1868 "LINE1:rbyte_avg#$FullBlue:Read ",
1869 'GPRINT:rbyte_min:MIN:%5.1lf%s Min,',
1870 'GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,',
1871 'GPRINT:rbyte_max:MAX:%5.1lf%s Max,',
1872 'GPRINT:rbyte_avg:LAST:%5.1lf%s Last\l'
1873 ],
1874 percent => ['-v', 'Percent',
1875 'DEF:avg={file}:percent:AVERAGE',
1876 'DEF:min={file}:percent:MIN',
1877 'DEF:max={file}:percent:MAX',
1878 "AREA:max#$HalfBlue",
1879 "AREA:min#$Canvas",
1880 "LINE1:avg#$FullBlue:Percent",
1881 'GPRINT:min:MIN:%5.1lf%% Min,',
1882 'GPRINT:avg:AVERAGE:%5.1lf%% Avg,',
1883 'GPRINT:max:MAX:%5.1lf%% Max,',
1884 'GPRINT:avg:LAST:%5.1lf%% Last\l'
1885 ],
1886 ping => ['DEF:ping_avg={file}:ping:AVERAGE',
1887 'DEF:ping_min={file}:ping:MIN',
1888 'DEF:ping_max={file}:ping:MAX',
1889 "AREA:ping_max#$HalfBlue",
1890 "AREA:ping_min#$Canvas",
1891 "LINE1:ping_avg#$FullBlue:Ping",
1892 'GPRINT:ping_min:MIN:%4.1lf ms Min,',
1893 'GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,',
1894 'GPRINT:ping_max:MAX:%4.1lf ms Max,',
1895 'GPRINT:ping_avg:LAST:%4.1lf ms Last'],
1896 power => ['-v', 'Watt',
1897 'DEF:avg={file}:value:AVERAGE',
1898 'DEF:min={file}:value:MIN',
1899 'DEF:max={file}:value:MAX',
1900 "AREA:max#$HalfBlue",
1901 "AREA:min#$Canvas",
1902 "LINE1:avg#$FullBlue:Watt",
1903 'GPRINT:min:MIN:%5.1lf%sW Min,',
1904 'GPRINT:avg:AVERAGE:%5.1lf%sW Avg,',
1905 'GPRINT:max:MAX:%5.1lf%sW Max,',
1906 'GPRINT:avg:LAST:%5.1lf%sW Last\l'
1907 ],
1908 processes => [
1909 "DEF:running_avg={file}:running:AVERAGE",
1910 "DEF:running_min={file}:running:MIN",
1911 "DEF:running_max={file}:running:MAX",
1912 "DEF:sleeping_avg={file}:sleeping:AVERAGE",
1913 "DEF:sleeping_min={file}:sleeping:MIN",
1914 "DEF:sleeping_max={file}:sleeping:MAX",
1915 "DEF:zombies_avg={file}:zombies:AVERAGE",
1916 "DEF:zombies_min={file}:zombies:MIN",
1917 "DEF:zombies_max={file}:zombies:MAX",
1918 "DEF:stopped_avg={file}:stopped:AVERAGE",
1919 "DEF:stopped_min={file}:stopped:MIN",
1920 "DEF:stopped_max={file}:stopped:MAX",
1921 "DEF:paging_avg={file}:paging:AVERAGE",
1922 "DEF:paging_min={file}:paging:MIN",
1923 "DEF:paging_max={file}:paging:MAX",
1924 "DEF:blocked_avg={file}:blocked:AVERAGE",
1925 "DEF:blocked_min={file}:blocked:MIN",
1926 "DEF:blocked_max={file}:blocked:MAX",
1927 'CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+',
1928 'CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+',
1929 'CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+',
1930 'CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+',
1931 'CDEF:running_acc=sleeping_avg,running_avg,+',
1932 'CDEF:sleeping_acc=sleeping_avg',
1933 "AREA:paging_acc#$HalfYellow",
1934 "AREA:blocked_acc#$HalfCyan",
1935 "AREA:zombies_acc#$HalfRed",
1936 "AREA:stopped_acc#$HalfMagenta",
1937 "AREA:running_acc#$HalfGreen",
1938 "AREA:sleeping_acc#$HalfBlue",
1939 "LINE1:paging_acc#$FullYellow:Paging ",
1940 'GPRINT:paging_min:MIN:%5.1lf Min,',
1941 'GPRINT:paging_avg:AVERAGE:%5.1lf Average,',
1942 'GPRINT:paging_max:MAX:%5.1lf Max,',
1943 'GPRINT:paging_avg:LAST:%5.1lf Last\l',
1944 "LINE1:blocked_acc#$FullCyan:Blocked ",
1945 'GPRINT:blocked_min:MIN:%5.1lf Min,',
1946 'GPRINT:blocked_avg:AVERAGE:%5.1lf Average,',
1947 'GPRINT:blocked_max:MAX:%5.1lf Max,',
1948 'GPRINT:blocked_avg:LAST:%5.1lf Last\l',
1949 "LINE1:zombies_acc#$FullRed:Zombies ",
1950 'GPRINT:zombies_min:MIN:%5.1lf Min,',
1951 'GPRINT:zombies_avg:AVERAGE:%5.1lf Average,',
1952 'GPRINT:zombies_max:MAX:%5.1lf Max,',
1953 'GPRINT:zombies_avg:LAST:%5.1lf Last\l',
1954 "LINE1:stopped_acc#$FullMagenta:Stopped ",
1955 'GPRINT:stopped_min:MIN:%5.1lf Min,',
1956 'GPRINT:stopped_avg:AVERAGE:%5.1lf Average,',
1957 'GPRINT:stopped_max:MAX:%5.1lf Max,',
1958 'GPRINT:stopped_avg:LAST:%5.1lf Last\l',
1959 "LINE1:running_acc#$FullGreen:Running ",
1960 'GPRINT:running_min:MIN:%5.1lf Min,',
1961 'GPRINT:running_avg:AVERAGE:%5.1lf Average,',
1962 'GPRINT:running_max:MAX:%5.1lf Max,',
1963 'GPRINT:running_avg:LAST:%5.1lf Last\l',
1964 "LINE1:sleeping_acc#$FullBlue:Sleeping",
1965 'GPRINT:sleeping_min:MIN:%5.1lf Min,',
1966 'GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,',
1967 'GPRINT:sleeping_max:MAX:%5.1lf Max,',
1968 'GPRINT:sleeping_avg:LAST:%5.1lf Last\l'
1969 ],
1970 ps_rss => [
1971 'DEF:avg={file}:byte:AVERAGE',
1972 'DEF:min={file}:byte:MIN',
1973 'DEF:max={file}:byte:MAX',
1974 "AREA:avg#$HalfBlue",
1975 "LINE1:avg#$FullBlue:RSS",
1976 'GPRINT:min:MIN:%5.1lf%s Min,',
1977 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
1978 'GPRINT:max:MAX:%5.1lf%s Max,',
1979 'GPRINT:avg:LAST:%5.1lf%s Last\l'
1980 ],
1981 ps_cputime => [
1982 'DEF:user_avg_raw={file}:user:AVERAGE',
1983 'DEF:user_min_raw={file}:user:MIN',
1984 'DEF:user_max_raw={file}:user:MAX',
1985 'DEF:syst_avg_raw={file}:syst:AVERAGE',
1986 'DEF:syst_min_raw={file}:syst:MIN',
1987 'DEF:syst_max_raw={file}:syst:MAX',
1988 'CDEF:user_avg=user_avg_raw,1000000,/',
1989 'CDEF:user_min=user_min_raw,1000000,/',
1990 'CDEF:user_max=user_max_raw,1000000,/',
1991 'CDEF:syst_avg=syst_avg_raw,1000000,/',
1992 'CDEF:syst_min=syst_min_raw,1000000,/',
1993 'CDEF:syst_max=syst_max_raw,1000000,/',
1994 'CDEF:user_syst=syst_avg,UN,0,syst_avg,IF,user_avg,+',
1995 "AREA:user_syst#$HalfBlue",
1996 "AREA:syst_avg#$HalfRed",
1997 "LINE1:user_syst#$FullBlue:User ",
1998 'GPRINT:user_min:MIN:%5.1lf%s Min,',
1999 'GPRINT:user_avg:AVERAGE:%5.1lf%s Avg,',
2000 'GPRINT:user_max:MAX:%5.1lf%s Max,',
2001 'GPRINT:user_avg:LAST:%5.1lf%s Last\l',
2002 "LINE1:syst_avg#$FullRed:System",
2003 'GPRINT:syst_min:MIN:%5.1lf%s Min,',
2004 'GPRINT:syst_avg:AVERAGE:%5.1lf%s Avg,',
2005 'GPRINT:syst_max:MAX:%5.1lf%s Max,',
2006 'GPRINT:syst_avg:LAST:%5.1lf%s Last\l'
2007 ],
2008 ps_count => [
2009 'DEF:procs_avg={file}:processes:AVERAGE',
2010 'DEF:procs_min={file}:processes:MIN',
2011 'DEF:procs_max={file}:processes:MAX',
2012 'DEF:thrds_avg={file}:threads:AVERAGE',
2013 'DEF:thrds_min={file}:threads:MIN',
2014 'DEF:thrds_max={file}:threads:MAX',
2015 "AREA:thrds_avg#$HalfBlue",
2016 "AREA:procs_avg#$HalfRed",
2017 "LINE1:thrds_avg#$FullBlue:Threads ",
2018 'GPRINT:thrds_min:MIN:%5.1lf Min,',
2019 'GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,',
2020 'GPRINT:thrds_max:MAX:%5.1lf Max,',
2021 'GPRINT:thrds_avg:LAST:%5.1lf Last\l',
2022 "LINE1:procs_avg#$FullRed:Processes",
2023 'GPRINT:procs_min:MIN:%5.1lf Min,',
2024 'GPRINT:procs_avg:AVERAGE:%5.1lf Avg,',
2025 'GPRINT:procs_max:MAX:%5.1lf Max,',
2026 'GPRINT:procs_avg:LAST:%5.1lf Last\l'
2027 ],
2028 ps_pagefaults => [
2029 'DEF:minor_avg={file}:minflt:AVERAGE',
2030 'DEF:minor_min={file}:minflt:MIN',
2031 'DEF:minor_max={file}:minflt:MAX',
2032 'DEF:major_avg={file}:majflt:AVERAGE',
2033 'DEF:major_min={file}:majflt:MIN',
2034 'DEF:major_max={file}:majflt:MAX',
2035 'CDEF:minor_major=major_avg,UN,0,major_avg,IF,minor_avg,+',
2036 "AREA:minor_major#$HalfBlue",
2037 "AREA:major_avg#$HalfRed",
2038 "LINE1:minor_major#$FullBlue:Minor",
2039 'GPRINT:minor_min:MIN:%5.1lf%s Min,',
2040 'GPRINT:minor_avg:AVERAGE:%5.1lf%s Avg,',
2041 'GPRINT:minor_max:MAX:%5.1lf%s Max,',
2042 'GPRINT:minor_avg:LAST:%5.1lf%s Last\l',
2043 "LINE1:major_avg#$FullRed:Major",
2044 'GPRINT:major_min:MIN:%5.1lf%s Min,',
2045 'GPRINT:major_avg:AVERAGE:%5.1lf%s Avg,',
2046 'GPRINT:major_max:MAX:%5.1lf%s Max,',
2047 'GPRINT:major_avg:LAST:%5.1lf%s Last\l'
2048 ],
2049 ps_state => ['-v', 'Processes',
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:Processes",
2056 'GPRINT:min:MIN:%6.2lf Min,',
2057 'GPRINT:avg:AVERAGE:%6.2lf Avg,',
2058 'GPRINT:max:MAX:%6.2lf Max,',
2059 'GPRINT:avg:LAST:%6.2lf Last\l'
2060 ],
2061 qtype => [
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:Queries/s",
2068 'GPRINT:min:MIN:%9.3lf Min,',
2069 'GPRINT:avg:AVERAGE:%9.3lf Average,',
2070 'GPRINT:max:MAX:%9.3lf Max,',
2071 'GPRINT:avg:LAST:%9.3lf Last\l'
2072 ],
2073 rcode => [
2074 'DEF:avg={file}:value:AVERAGE',
2075 'DEF:min={file}:value:MIN',
2076 'DEF:max={file}:value:MAX',
2077 "AREA:max#$HalfBlue",
2078 "AREA:min#$Canvas",
2079 "LINE1:avg#$FullBlue:Queries/s",
2080 'GPRINT:min:MIN:%9.3lf Min,',
2081 'GPRINT:avg:AVERAGE:%9.3lf Average,',
2082 'GPRINT:max:MAX:%9.3lf Max,',
2083 'GPRINT:avg:LAST:%9.3lf Last\l'
2084 ],
2085 swap => ['-v', 'Bytes', '-b', '1024',
2086 'DEF:avg={file}:value:AVERAGE',
2087 'DEF:min={file}:value:MIN',
2088 'DEF:max={file}:value:MAX',
2089 "AREA:max#$HalfBlue",
2090 "AREA:min#$Canvas",
2091 "LINE1:avg#$FullBlue:Bytes",
2092 'GPRINT:min:MIN:%6.2lf%sByte Min,',
2093 'GPRINT:avg:AVERAGE:%6.2lf%sByte Avg,',
2094 'GPRINT:max:MAX:%6.2lf%sByte Max,',
2095 'GPRINT:avg:LAST:%6.2lf%sByte Last\l'
2096 ],
2097 old_swap => [
2098 'DEF:used_avg={file}:used:AVERAGE',
2099 'DEF:used_min={file}:used:MIN',
2100 'DEF:used_max={file}:used:MAX',
2101 'DEF:free_avg={file}:free:AVERAGE',
2102 'DEF:free_min={file}:free:MIN',
2103 'DEF:free_max={file}:free:MAX',
2104 'DEF:cach_avg={file}:cached:AVERAGE',
2105 'DEF:cach_min={file}:cached:MIN',
2106 'DEF:cach_max={file}:cached:MAX',
2107 'DEF:resv_avg={file}:resv:AVERAGE',
2108 'DEF:resv_min={file}:resv:MIN',
2109 'DEF:resv_max={file}:resv:MAX',
2110 'CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF',
2111 'CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF',
2112 'CDEF:used_acc=used_avg',
2113 'CDEF:resv_acc=used_acc,resv_avg_notnull,+',
2114 'CDEF:cach_acc=resv_acc,cach_avg_notnull,+',
2115 'CDEF:free_acc=cach_acc,free_avg,+',
2116 "AREA:free_acc#$HalfGreen",
2117 "AREA:cach_acc#$HalfBlue",
2118 "AREA:resv_acc#$HalfYellow",
2119 "AREA:used_acc#$HalfRed",
2120 "LINE1:free_acc#$FullGreen:Free ",
2121 'GPRINT:free_min:MIN:%5.1lf%s Min,',
2122 'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
2123 'GPRINT:free_max:MAX:%5.1lf%s Max,',
2124 'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
2125 "LINE1:cach_acc#$FullBlue:Cached ",
2126 'GPRINT:cach_min:MIN:%5.1lf%s Min,',
2127 'GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,',
2128 'GPRINT:cach_max:MAX:%5.1lf%s Max,',
2129 'GPRINT:cach_avg:LAST:%5.1lf%s Last\l',
2130 "LINE1:resv_acc#$FullYellow:Reserved",
2131 'GPRINT:resv_min:MIN:%5.1lf%s Min,',
2132 'GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,',
2133 'GPRINT:resv_max:MAX:%5.1lf%s Max,',
2134 'GPRINT:resv_avg:LAST:%5.1lf%s Last\n',
2135 "LINE1:used_acc#$FullRed:Used ",
2136 'GPRINT:used_min:MIN:%5.1lf%s Min,',
2137 'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
2138 'GPRINT:used_max:MAX:%5.1lf%s Max,',
2139 'GPRINT:used_avg:LAST:%5.1lf%s Last\l'
2140 ],
2141 tcp_connections => ['-v', 'Connections',
2142 'DEF:avg={file}:value:AVERAGE',
2143 'DEF:min={file}:value:MIN',
2144 'DEF:max={file}:value:MAX',
2145 "AREA:max#$HalfBlue",
2146 "AREA:min#$Canvas",
2147 "LINE1:avg#$FullBlue:Connections",
2148 'GPRINT:min:MIN:%4.1lf Min,',
2149 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
2150 'GPRINT:max:MAX:%4.1lf Max,',
2151 'GPRINT:avg:LAST:%4.1lf Last\l'
2152 ],
2153 temperature => ['-v', 'Celsius',
2154 'DEF:temp_avg={file}:value:AVERAGE',
2155 'DEF:temp_min={file}:value:MIN',
2156 'DEF:temp_max={file}:value:MAX',
2157 'CDEF:average=temp_avg,0.2,*,PREV,UN,temp_avg,PREV,IF,0.8,*,+',
2158 "AREA:temp_max#$HalfRed",
2159 "AREA:temp_min#$Canvas",
2160 "LINE1:temp_avg#$FullRed:Temperature",
2161 'GPRINT:temp_min:MIN:%4.1lf Min,',
2162 'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
2163 'GPRINT:temp_max:MAX:%4.1lf Max,',
2164 'GPRINT:temp_avg:LAST:%4.1lf Last\l'
2165 ],
2166 timeleft => ['-v', 'Minutes',
2167 'DEF:avg={file}:timeleft:AVERAGE',
2168 'DEF:min={file}:timeleft:MIN',
2169 'DEF:max={file}:timeleft:MAX',
2170 "AREA:max#$HalfBlue",
2171 "AREA:min#$Canvas",
2172 "LINE1:avg#$FullBlue:Time left [min]",
2173 'GPRINT:min:MIN:%5.1lf%s Min,',
2174 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
2175 'GPRINT:max:MAX:%5.1lf%s Max,',
2176 'GPRINT:avg:LAST:%5.1lf%s Last\l'
2177 ],
2178 time_offset => [ # NTPd
2179 'DEF:s_avg={file}:seconds:AVERAGE',
2180 'DEF:s_min={file}:seconds:MIN',
2181 'DEF:s_max={file}:seconds:MAX',
2182 "AREA:s_max#$HalfBlue",
2183 "AREA:s_min#$Canvas",
2184 "LINE1:s_avg#$FullBlue:{inst}",
2185 'GPRINT:s_min:MIN:%7.3lf%s Min,',
2186 'GPRINT:s_avg:AVERAGE:%7.3lf%s Avg,',
2187 'GPRINT:s_max:MAX:%7.3lf%s Max,',
2188 'GPRINT:s_avg:LAST:%7.3lf%s Last'
2189 ],
2190 if_octets => ['-v', 'Bits/s', '-l', '0',
2191 'DEF:out_min_raw={file}:tx:MIN',
2192 'DEF:out_avg_raw={file}:tx:AVERAGE',
2193 'DEF:out_max_raw={file}:tx:MAX',
2194 'DEF:inc_min_raw={file}:rx:MIN',
2195 'DEF:inc_avg_raw={file}:rx:AVERAGE',
2196 'DEF:inc_max_raw={file}:rx:MAX',
2197 'CDEF:out_min=out_min_raw,8,*',
2198 'CDEF:out_avg=out_avg_raw,8,*',
2199 'CDEF:out_max=out_max_raw,8,*',
2200 'CDEF:inc_min=inc_min_raw,8,*',
2201 'CDEF:inc_avg=inc_avg_raw,8,*',
2202 'CDEF:inc_max=inc_max_raw,8,*',
2203 'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
2204 'CDEF:mytime=out_avg_raw,TIME,TIME,IF',
2205 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
2206 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
2207 'CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*',
2208 'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
2209 'CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*',
2210 'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
2211 "AREA:out_avg#$HalfGreen",
2212 "AREA:inc_avg#$HalfBlue",
2213 "AREA:overlap#$HalfBlueGreen",
2214 "LINE1:out_avg#$FullGreen:Outgoing",
2215 'GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,',
2216 'GPRINT:out_max:MAX:%5.1lf%s Max,',
2217 'GPRINT:out_avg:LAST:%5.1lf%s Last',
2218 'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
2219 "LINE1:inc_avg#$FullBlue:Incoming",
2220 #'GPRINT:inc_min:MIN:%5.1lf %s Min,',
2221 'GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,',
2222 'GPRINT:inc_max:MAX:%5.1lf%s Max,',
2223 'GPRINT:inc_avg:LAST:%5.1lf%s Last',
2224 'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
2225 ],
2226 cpufreq => [
2227 'DEF:cpufreq_avg={file}:value:AVERAGE',
2228 'DEF:cpufreq_min={file}:value:MIN',
2229 'DEF:cpufreq_max={file}:value:MAX',
2230 "AREA:cpufreq_max#$HalfBlue",
2231 "AREA:cpufreq_min#$Canvas",
2232 "LINE1:cpufreq_avg#$FullBlue:Frequency",
2233 'GPRINT:cpufreq_min:MIN:%5.1lf%s Min,',
2234 'GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,',
2235 'GPRINT:cpufreq_max:MAX:%5.1lf%s Max,',
2236 'GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\l'
2237 ],
2238 multimeter => [
2239 'DEF:multimeter_avg={file}:value:AVERAGE',
2240 'DEF:multimeter_min={file}:value:MIN',
2241 'DEF:multimeter_max={file}:value:MAX',
2242 "AREA:multimeter_max#$HalfBlue",
2243 "AREA:multimeter_min#$Canvas",
2244 "LINE1:multimeter_avg#$FullBlue:Multimeter",
2245 'GPRINT:multimeter_min:MIN:%4.1lf Min,',
2246 'GPRINT:multimeter_avg:AVERAGE:%4.1lf Average,',
2247 'GPRINT:multimeter_max:MAX:%4.1lf Max,',
2248 'GPRINT:multimeter_avg:LAST:%4.1lf Last\l'
2249 ],
2250 users => ['-v', 'Users',
2251 'DEF:users_avg={file}:users:AVERAGE',
2252 'DEF:users_min={file}:users:MIN',
2253 'DEF:users_max={file}:users:MAX',
2254 "AREA:users_max#$HalfBlue",
2255 "AREA:users_min#$Canvas",
2256 "LINE1:users_avg#$FullBlue:Users",
2257 'GPRINT:users_min:MIN:%4.1lf Min,',
2258 'GPRINT:users_avg:AVERAGE:%4.1lf Average,',
2259 'GPRINT:users_max:MAX:%4.1lf Max,',
2260 'GPRINT:users_avg:LAST:%4.1lf Last\l'
2261 ],
2262 voltage => ['-v', 'Voltage',
2263 'DEF:avg={file}:value:AVERAGE',
2264 'DEF:min={file}:value:MIN',
2265 'DEF:max={file}:value:MAX',
2266 "AREA:max#$HalfBlue",
2267 "AREA:min#$Canvas",
2268 "LINE1:avg#$FullBlue:Voltage",
2269 'GPRINT:min:MIN:%5.1lf%sV Min,',
2270 'GPRINT:avg:AVERAGE:%5.1lf%sV Avg,',
2271 'GPRINT:max:MAX:%5.1lf%sV Max,',
2272 'GPRINT:avg:LAST:%5.1lf%sV Last\l'
2273 ],
2274 vs_threads => [
2275 "DEF:total_avg={file}:total:AVERAGE",
2276 "DEF:total_min={file}:total:MIN",
2277 "DEF:total_max={file}:total:MAX",
2278 "DEF:running_avg={file}:running:AVERAGE",
2279 "DEF:running_min={file}:running:MIN",
2280 "DEF:running_max={file}:running:MAX",
2281 "DEF:uninterruptible_avg={file}:uninterruptible:AVERAGE",
2282 "DEF:uninterruptible_min={file}:uninterruptible:MIN",
2283 "DEF:uninterruptible_max={file}:uninterruptible:MAX",
2284 "DEF:onhold_avg={file}:onhold:AVERAGE",
2285 "DEF:onhold_min={file}:onhold:MIN",
2286 "DEF:onhold_max={file}:onhold:MAX",
2287 "LINE1:total_avg#$FullYellow:Total ",
2288 'GPRINT:total_min:MIN:%5.1lf Min,',
2289 'GPRINT:total_avg:AVERAGE:%5.1lf Avg.,',
2290 'GPRINT:total_max:MAX:%5.1lf Max,',
2291 'GPRINT:total_avg:LAST:%5.1lf Last\l',
2292 "LINE1:running_avg#$FullRed:Running ",
2293 'GPRINT:running_min:MIN:%5.1lf Min,',
2294 'GPRINT:running_avg:AVERAGE:%5.1lf Avg.,',
2295 'GPRINT:running_max:MAX:%5.1lf Max,',
2296 'GPRINT:running_avg:LAST:%5.1lf Last\l',
2297 "LINE1:uninterruptible_avg#$FullGreen:Unintr ",
2298 'GPRINT:uninterruptible_min:MIN:%5.1lf Min,',
2299 'GPRINT:uninterruptible_avg:AVERAGE:%5.1lf Avg.,',
2300 'GPRINT:uninterruptible_max:MAX:%5.1lf Max,',
2301 'GPRINT:uninterruptible_avg:LAST:%5.1lf Last\l',
2302 "LINE1:onhold_avg#$FullBlue:Onhold ",
2303 'GPRINT:onhold_min:MIN:%5.1lf Min,',
2304 'GPRINT:onhold_avg:AVERAGE:%5.1lf Avg.,',
2305 'GPRINT:onhold_max:MAX:%5.1lf Max,',
2306 'GPRINT:onhold_avg:LAST:%5.1lf Last\l'
2307 ],
2308 vs_memory => [
2309 'DEF:vm_avg={file}:vm:AVERAGE',
2310 'DEF:vm_min={file}:vm:MIN',
2311 'DEF:vm_max={file}:vm:MAX',
2312 'DEF:vml_avg={file}:vml:AVERAGE',
2313 'DEF:vml_min={file}:vml:MIN',
2314 'DEF:vml_max={file}:vml:MAX',
2315 'DEF:rss_avg={file}:rss:AVERAGE',
2316 'DEF:rss_min={file}:rss:MIN',
2317 'DEF:rss_max={file}:rss:MAX',
2318 'DEF:anon_avg={file}:anon:AVERAGE',
2319 'DEF:anon_min={file}:anon:MIN',
2320 'DEF:anon_max={file}:anon:MAX',
2321 "LINE1:vm_avg#$FullYellow:VM ",
2322 'GPRINT:vm_min:MIN:%5.1lf%s Min,',
2323 'GPRINT:vm_avg:AVERAGE:%5.1lf%s Avg.,',
2324 'GPRINT:vm_max:MAX:%5.1lf%s Avg.,',
2325 'GPRINT:vm_avg:LAST:%5.1lf%s Last\l',
2326 "LINE1:vml_avg#$FullRed:Locked ",
2327 'GPRINT:vml_min:MIN:%5.1lf%s Min,',
2328 'GPRINT:vml_avg:AVERAGE:%5.1lf%s Avg.,',
2329 'GPRINT:vml_max:MAX:%5.1lf%s Avg.,',
2330 'GPRINT:vml_avg:LAST:%5.1lf%s Last\l',
2331 "LINE1:rss_avg#$FullGreen:RSS ",
2332 'GPRINT:rss_min:MIN:%5.1lf%s Min,',
2333 'GPRINT:rss_avg:AVERAGE:%5.1lf%s Avg.,',
2334 'GPRINT:rss_max:MAX:%5.1lf%s Avg.,',
2335 'GPRINT:rss_avg:LAST:%5.1lf%s Last\l',
2336 "LINE1:anon_avg#$FullBlue:Anon. ",
2337 'GPRINT:anon_min:MIN:%5.1lf%s Min,',
2338 'GPRINT:anon_avg:AVERAGE:%5.1lf%s Avg.,',
2339 'GPRINT:anon_max:MAX:%5.1lf%s Avg.,',
2340 'GPRINT:anon_avg:LAST:%5.1lf%s Last\l',
2341 ],
2342 vs_processes => [
2343 'DEF:proc_avg={file}:total:AVERAGE',
2344 'DEF:proc_min={file}:total:MIN',
2345 'DEF:proc_max={file}:total:MAX',
2346 "AREA:proc_max#$HalfBlue",
2347 "AREA:proc_min#$Canvas",
2348 "LINE1:proc_avg#$FullBlue:Processes",
2349 'GPRINT:proc_min:MIN:%4.1lf Min,',
2350 'GPRINT:proc_avg:AVERAGE:%4.1lf Avg.,',
2351 'GPRINT:proc_max:MAX:%4.1lf Max,',
2352 'GPRINT:proc_avg:LAST:%4.1lf Last\l'
2353 ],
2354 };
2355 $GraphDefs->{'if_multicast'} = $GraphDefs->{'ipt_packets'};
2356 $GraphDefs->{'if_tx_errors'} = $GraphDefs->{'if_rx_errors'};
2358 $MetaGraphDefs->{'cpu'} = \&meta_graph_cpu;
2359 $MetaGraphDefs->{'if_rx_errors'} = \&meta_graph_if_rx_errors;
2360 $MetaGraphDefs->{'if_tx_errors'} = \&meta_graph_if_rx_errors;
2361 $MetaGraphDefs->{'memory'} = \&meta_graph_memory;
2362 $MetaGraphDefs->{'nfs_procedure'} = \&meta_graph_nfs_procedure;
2363 $MetaGraphDefs->{'ps_state'} = \&meta_graph_ps_state;
2364 $MetaGraphDefs->{'swap'} = \&meta_graph_swap;
2365 $MetaGraphDefs->{'mysql_commands'} = \&meta_graph_mysql_commands;
2366 $MetaGraphDefs->{'mysql_handler'} = \&meta_graph_mysql_commands;
2367 $MetaGraphDefs->{'tcp_connections'} = \&meta_graph_tcp_connections;
2368 } # load_graph_definitions
2370 sub meta_graph_generic_stack
2371 {
2372 confess ("Wrong number of arguments") if (@_ != 2);
2374 my $opts = shift;
2375 my $sources = shift;
2376 my $i;
2378 my $timespan_str = _get_param_timespan ();
2379 my $timespan_int = (-1) * $ValidTimespan->{$timespan_str};
2381 $opts->{'title'} ||= 'Unknown title';
2382 $opts->{'rrd_opts'} ||= [];
2383 $opts->{'colors'} ||= {};
2385 my @cmd = ('-', '-a', 'PNG', '-s', $timespan_int,
2386 '-t', $opts->{'title'} || 'Unknown title',
2387 @RRDDefaultArgs, @{$opts->{'rrd_opts'}});
2389 my $max_inst_name = 0;
2391 for ($i = 0; $i < @$sources; $i++)
2392 {
2393 my $inst_data = $sources->[$i];
2394 my $inst_name = $inst_data->{'name'} || confess;
2395 my $file = $inst_data->{'file'} || confess;
2397 if (length ($inst_name) > $max_inst_name)
2398 {
2399 $max_inst_name = length ($inst_name);
2400 }
2402 confess ("No such file: $file") if (!-e $file);
2404 push (@cmd,
2405 qq#DEF:${inst_name}_min=$file:value:MIN#,
2406 qq#DEF:${inst_name}_avg=$file:value:AVERAGE#,
2407 qq#DEF:${inst_name}_max=$file:value:MAX#,
2408 qq#CDEF:${inst_name}_nnl=${inst_name}_avg,UN,0,${inst_name}_avg,IF#);
2409 }
2411 {
2412 my $inst_data = $sources->[@$sources - 1];
2413 my $inst_name = $inst_data->{'name'};
2415 push (@cmd, qq#CDEF:${inst_name}_stk=${inst_name}_nnl#);
2416 }
2417 for (my $i = 1; $i < @$sources; $i++)
2418 {
2419 my $inst_data0 = $sources->[@$sources - ($i + 1)];
2420 my $inst_data1 = $sources->[@$sources - $i];
2422 my $inst_name0 = $inst_data0->{'name'};
2423 my $inst_name1 = $inst_data1->{'name'};
2425 push (@cmd, qq#CDEF:${inst_name0}_stk=${inst_name0}_nnl,${inst_name1}_stk,+#);
2426 }
2428 for (my $i = 0; $i < @$sources; $i++)
2429 {
2430 my $inst_data = $sources->[$i];
2431 my $inst_name = $inst_data->{'name'};
2433 my $legend = sprintf ('%-*s', $max_inst_name, $inst_name);
2435 my $line_color;
2436 my $area_color;
2438 my $number_format = $opts->{'number_format'} || '%6.1lf';
2440 if (exists ($opts->{'colors'}{$inst_name}))
2441 {
2442 $line_color = $opts->{'colors'}{$inst_name};
2443 $area_color = _string_to_color ($line_color);
2444 }
2445 else
2446 {
2447 $area_color = _get_random_color ();
2448 $line_color = _color_to_string ($area_color);
2449 }
2450 $area_color = _color_to_string (_get_faded_color ($area_color));
2452 push (@cmd, qq(AREA:${inst_name}_stk#$area_color),
2453 qq(LINE1:${inst_name}_stk#$line_color:$legend),
2454 qq(GPRINT:${inst_name}_min:MIN:$number_format Min,),
2455 qq(GPRINT:${inst_name}_avg:AVERAGE:$number_format Avg,),
2456 qq(GPRINT:${inst_name}_max:MAX:$number_format Max,),
2457 qq(GPRINT:${inst_name}_avg:LAST:$number_format Last\\l),
2458 );
2459 }
2461 RRDs::graph (@cmd);
2462 if (my $errmsg = RRDs::error ())
2463 {
2464 confess ("RRDs::graph: $errmsg");
2465 }
2466 } # meta_graph_generic_stack
2468 sub meta_graph_cpu
2469 {
2470 confess ("Wrong number of arguments") if (@_ != 5);
2472 my $host = shift;
2473 my $plugin = shift;
2474 my $plugin_instance = shift;
2475 my $type = shift;
2476 my $type_instances = shift;
2478 my $opts = {};
2479 my $sources = [];
2481 $opts->{'title'} = "$host/$plugin"
2482 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2484 $opts->{'rrd_opts'} = ['-v', 'Percent'];
2486 my @files = ();
2488 $opts->{'colors'} =
2489 {
2490 'idle' => 'ffffff',
2491 'nice' => '00e000',
2492 'user' => '0000ff',
2493 'wait' => 'ffb000',
2494 'system' => 'ff0000',
2495 'softirq' => 'ff00ff',
2496 'interrupt' => 'a000a0',
2497 'steal' => '000000'
2498 };
2500 _custom_sort_arrayref ($type_instances,
2501 [qw(idle nice user wait system softirq interrupt steal)]);
2503 for (@$type_instances)
2504 {
2505 my $inst = $_;
2506 my $file = '';
2507 my $title = $opts->{'title'};
2509 for (@DataDirs)
2510 {
2511 if (-e "$_/$title-$inst.rrd")
2512 {
2513 $file = "$_/$title-$inst.rrd";
2514 last;
2515 }
2516 }
2517 confess ("No file found for $title") if ($file eq '');
2519 push (@$sources,
2520 {
2521 name => $inst,
2522 file => $file
2523 }
2524 );
2525 } # for (@$type_instances)
2527 return (meta_graph_generic_stack ($opts, $sources));
2528 } # meta_graph_cpu
2530 sub meta_graph_memory
2531 {
2532 confess ("Wrong number of arguments") if (@_ != 5);
2534 my $host = shift;
2535 my $plugin = shift;
2536 my $plugin_instance = shift;
2537 my $type = shift;
2538 my $type_instances = shift;
2540 my $opts = {};
2541 my $sources = [];
2543 $opts->{'title'} = "$host/$plugin"
2544 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2545 $opts->{'number_format'} = '%5.1lf%s';
2547 $opts->{'rrd_opts'} = ['-b', '1024', '-v', 'Bytes'];
2549 my @files = ();
2551 $opts->{'colors'} =
2552 {
2553 'free' => '00e000',
2554 'cached' => '0000ff',
2555 'buffered' => 'ffb000',
2556 'used' => 'ff0000'
2557 };
2559 _custom_sort_arrayref ($type_instances,
2560 [qw(free cached buffered used)]);
2562 for (@$type_instances)
2563 {
2564 my $inst = $_;
2565 my $file = '';
2566 my $title = $opts->{'title'};
2568 for (@DataDirs)
2569 {
2570 if (-e "$_/$title-$inst.rrd")
2571 {
2572 $file = "$_/$title-$inst.rrd";
2573 last;
2574 }
2575 }
2576 confess ("No file found for $title") if ($file eq '');
2578 push (@$sources,
2579 {
2580 name => $inst,
2581 file => $file
2582 }
2583 );
2584 } # for (@$type_instances)
2586 return (meta_graph_generic_stack ($opts, $sources));
2587 } # meta_graph_cpu
2589 sub meta_graph_if_rx_errors
2590 {
2591 confess ("Wrong number of arguments") if (@_ != 5);
2593 my $host = shift;
2594 my $plugin = shift;
2595 my $plugin_instance = shift;
2596 my $type = shift;
2597 my $type_instances = shift;
2599 my $opts = {};
2600 my $sources = [];
2602 $opts->{'title'} = "$host/$plugin"
2603 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2604 $opts->{'number_format'} = '%5.2lf';
2605 $opts->{'rrd_opts'} = ['-v', 'Errors/s'];
2607 my @files = ();
2609 for (sort @$type_instances)
2610 {
2611 my $inst = $_;
2612 my $file = '';
2613 my $title = $opts->{'title'};
2615 for (@DataDirs)
2616 {
2617 if (-e "$_/$title-$inst.rrd")
2618 {
2619 $file = "$_/$title-$inst.rrd";
2620 last;
2621 }
2622 }
2623 confess ("No file found for $title") if ($file eq '');
2625 push (@$sources,
2626 {
2627 name => $inst,
2628 file => $file
2629 }
2630 );
2631 } # for (@$type_instances)
2633 return (meta_graph_generic_stack ($opts, $sources));
2634 } # meta_graph_if_rx_errors
2636 sub meta_graph_mysql_commands
2637 {
2638 confess ("Wrong number of arguments") if (@_ != 5);
2640 my $host = shift;
2641 my $plugin = shift;
2642 my $plugin_instance = shift;
2643 my $type = shift;
2644 my $type_instances = shift;
2646 my $opts = {};
2647 my $sources = [];
2649 $opts->{'title'} = "$host/$plugin"
2650 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2651 $opts->{'number_format'} = '%5.2lf';
2653 my @files = ();
2655 for (sort @$type_instances)
2656 {
2657 my $inst = $_;
2658 my $file = '';
2659 my $title = $opts->{'title'};
2661 for (@DataDirs)
2662 {
2663 if (-e "$_/$title-$inst.rrd")
2664 {
2665 $file = "$_/$title-$inst.rrd";
2666 last;
2667 }
2668 }
2669 confess ("No file found for $title") if ($file eq '');
2671 push (@$sources,
2672 {
2673 name => $inst,
2674 file => $file
2675 }
2676 );
2677 } # for (@$type_instances)
2679 return (meta_graph_generic_stack ($opts, $sources));
2680 } # meta_graph_mysql_commands
2682 sub meta_graph_nfs_procedure
2683 {
2684 confess ("Wrong number of arguments") if (@_ != 5);
2686 my $host = shift;
2687 my $plugin = shift;
2688 my $plugin_instance = shift;
2689 my $type = shift;
2690 my $type_instances = shift;
2692 my $opts = {};
2693 my $sources = [];
2695 $opts->{'title'} = "$host/$plugin"
2696 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2697 $opts->{'number_format'} = '%5.1lf%s';
2699 my @files = ();
2701 for (sort @$type_instances)
2702 {
2703 my $inst = $_;
2704 my $file = '';
2705 my $title = $opts->{'title'};
2707 for (@DataDirs)
2708 {
2709 if (-e "$_/$title-$inst.rrd")
2710 {
2711 $file = "$_/$title-$inst.rrd";
2712 last;
2713 }
2714 }
2715 confess ("No file found for $title") if ($file eq '');
2717 push (@$sources,
2718 {
2719 name => $inst,
2720 file => $file
2721 }
2722 );
2723 } # for (@$type_instances)
2725 return (meta_graph_generic_stack ($opts, $sources));
2726 } # meta_graph_nfs_procedure
2728 sub meta_graph_ps_state
2729 {
2730 confess ("Wrong number of arguments") if (@_ != 5);
2732 my $host = shift;
2733 my $plugin = shift;
2734 my $plugin_instance = shift;
2735 my $type = shift;
2736 my $type_instances = shift;
2738 my $opts = {};
2739 my $sources = [];
2741 $opts->{'title'} = "$host/$plugin"
2742 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2743 $opts->{'rrd_opts'} = ['-v', 'Processes'];
2745 my @files = ();
2747 $opts->{'colors'} =
2748 {
2749 'Running' => '00e000',
2750 'Sleeping' => '0000ff',
2751 'Paging' => 'ffb000',
2752 'Zombies' => 'ff0000',
2753 'Blocked' => 'ff00ff',
2754 'Stopped' => 'a000a0'
2755 };
2757 _custom_sort_arrayref ($type_instances,
2758 [qw(paging blocked zombies stopped running sleeping)]);
2760 for (@$type_instances)
2761 {
2762 my $inst = $_;
2763 my $file = '';
2764 my $title = $opts->{'title'};
2766 for (@DataDirs)
2767 {
2768 if (-e "$_/$title-$inst.rrd")
2769 {
2770 $file = "$_/$title-$inst.rrd";
2771 last;
2772 }
2773 }
2774 confess ("No file found for $title") if ($file eq '');
2776 push (@$sources,
2777 {
2778 name => ucfirst ($inst),
2779 file => $file
2780 }
2781 );
2782 } # for (@$type_instances)
2784 return (meta_graph_generic_stack ($opts, $sources));
2785 } # meta_graph_ps_state
2787 sub meta_graph_swap
2788 {
2789 confess ("Wrong number of arguments") if (@_ != 5);
2791 my $host = shift;
2792 my $plugin = shift;
2793 my $plugin_instance = shift;
2794 my $type = shift;
2795 my $type_instances = shift;
2797 my $opts = {};
2798 my $sources = [];
2800 $opts->{'title'} = "$host/$plugin"
2801 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2802 $opts->{'number_format'} = '%5.1lf%s';
2803 $opts->{'rrd_opts'} = ['-v', 'Bytes'];
2805 my @files = ();
2807 $opts->{'colors'} =
2808 {
2809 'Free' => '00e000',
2810 'Cached' => '0000ff',
2811 'Reserved' => 'ffb000',
2812 'Used' => 'ff0000'
2813 };
2815 _custom_sort_arrayref ($type_instances,
2816 [qw(free cached reserved used)]);
2818 for (@$type_instances)
2819 {
2820 my $inst = $_;
2821 my $file = '';
2822 my $title = $opts->{'title'};
2824 for (@DataDirs)
2825 {
2826 if (-e "$_/$title-$inst.rrd")
2827 {
2828 $file = "$_/$title-$inst.rrd";
2829 last;
2830 }
2831 }
2832 confess ("No file found for $title") if ($file eq '');
2834 push (@$sources,
2835 {
2836 name => ucfirst ($inst),
2837 file => $file
2838 }
2839 );
2840 } # for (@$type_instances)
2842 return (meta_graph_generic_stack ($opts, $sources));
2843 } # meta_graph_swap
2845 sub meta_graph_tcp_connections
2846 {
2847 confess ("Wrong number of arguments") if (@_ != 5);
2849 my $host = shift;
2850 my $plugin = shift;
2851 my $plugin_instance = shift;
2852 my $type = shift;
2853 my $type_instances = shift;
2855 my $opts = {};
2856 my $sources = [];
2858 $opts->{'title'} = "$host/$plugin"
2859 . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
2860 $opts->{'number_format'} = '%6.2lf';
2862 $opts->{'rrd_opts'} = ['-v', 'Connections'];
2864 my @files = ();
2866 $opts->{'colors'} =
2867 {
2868 ESTABLISHED => '00e000',
2869 SYN_SENT => '00e0ff',
2870 SYN_RECV => '00e0a0',
2871 FIN_WAIT1 => 'f000f0',
2872 FIN_WAIT2 => 'f000a0',
2873 TIME_WAIT => 'ffb000',
2874 CLOSE => '0000f0',
2875 CLOSE_WAIT => '0000a0',
2876 LAST_ACK => '000080',
2877 LISTEN => 'ff0000',
2878 CLOSING => '000000'
2879 };
2881 _custom_sort_arrayref ($type_instances,
2882 [reverse qw(ESTABLISHED SYN_SENT SYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSE
2883 CLOSE_WAIT LAST_ACK CLOSING LISTEN)]);
2885 for (@$type_instances)
2886 {
2887 my $inst = $_;
2888 my $file = '';
2889 my $title = $opts->{'title'};
2891 for (@DataDirs)
2892 {
2893 if (-e "$_/$title-$inst.rrd")
2894 {
2895 $file = "$_/$title-$inst.rrd";
2896 last;
2897 }
2898 }
2899 confess ("No file found for $title") if ($file eq '');
2901 push (@$sources,
2902 {
2903 name => $inst,
2904 file => $file
2905 }
2906 );
2907 } # for (@$type_instances)
2909 return (meta_graph_generic_stack ($opts, $sources));
2910 } # meta_graph_tcp_connections
2911 # vim: shiftwidth=2:softtabstop=2:tabstop=8