X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fcollection.cgi;h=7da7e1c62f857a8bd9d1be956e51ff102d6da64e;hb=1a8ae6734a9351097943dd1ce019a8d95b72c3d1;hp=791976027827adba69de670ca6c93b97d67b6a9b;hpb=ebf2e171eb457394e498cada2be85bcef24d6221;p=collectd.git diff --git a/contrib/collection.cgi b/contrib/collection.cgi index 79197602..7da7e1c6 100755 --- a/contrib/collection.cgi +++ b/contrib/collection.cgi @@ -209,8 +209,8 @@ sub _find_plugins for (@tmp) { my ($plugin, $instance) = split (m/-/, $_, 2); - $plugins{$plugin} = [] if (!$plugins{$plugin}); - push (@{$plugins{$plugin}}, $instance) if (defined ($instance)); + $plugins{$plugin} = [] if (!exists $plugins{$plugin}); + push (@{$plugins{$plugin}}, $instance); } } # for (@DataDirs) @@ -267,9 +267,11 @@ sub _find_files_for_host for (@$plugin_instances) { - my $plugin_instance = $_; + my $plugin_instance = defined ($_) ? $_ : '-'; my %types = _find_types ($host, $plugin, - ($plugin_instance ne '-') ? $plugin_instance : undef); + ($plugin_instance ne '-') + ? $plugin_instance + : undef); $ret->{$plugin}{$plugin_instance} = {}; @@ -1289,6 +1291,18 @@ sub load_graph_definitions 'GPRINT:temp_max:MAX:%4.1lf Max,', 'GPRINT:temp_avg:LAST:%4.1lf Last\l' ], + humidity => ['-v', 'Percent', + 'DEF:temp_avg={file}:value:AVERAGE', + 'DEF:temp_min={file}:value:MIN', + 'DEF:temp_max={file}:value:MAX', + "AREA:temp_max#$HalfGreen", + "AREA:temp_min#$Canvas", + "LINE1:temp_avg#$FullGreen:Temperature", + 'GPRINT:temp_min:MIN:%4.1lf%% Min,', + 'GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,', + 'GPRINT:temp_max:MAX:%4.1lf%% Max,', + 'GPRINT:temp_avg:LAST:%4.1lf%% Last\l' + ], if_errors => ['-v', 'Errors/s', 'DEF:tx_min={file}:tx:MIN', 'DEF:tx_avg={file}:tx:AVERAGE', @@ -1881,6 +1895,18 @@ sub load_graph_definitions 'GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,', 'GPRINT:ping_max:MAX:%4.1lf ms Max,', 'GPRINT:ping_avg:LAST:%4.1lf ms Last'], + power => ['-v', 'Watt', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Watt", + 'GPRINT:min:MIN:%5.1lf%sW Min,', + 'GPRINT:avg:AVERAGE:%5.1lf%sW Avg,', + 'GPRINT:max:MAX:%5.1lf%sW Max,', + 'GPRINT:avg:LAST:%5.1lf%sW Last\l' + ], processes => [ "DEF:running_avg={file}:running:AVERAGE", "DEF:running_min={file}:running:MIN", @@ -1943,18 +1969,27 @@ sub load_graph_definitions 'GPRINT:sleeping_max:MAX:%5.1lf Max,', 'GPRINT:sleeping_avg:LAST:%5.1lf Last\l' ], - ps_rss => [ - 'DEF:avg={file}:byte:AVERAGE', - 'DEF:min={file}:byte:MIN', - 'DEF:max={file}:byte:MAX', - "AREA:avg#$HalfBlue", - "LINE1:avg#$FullBlue:RSS", - 'GPRINT:min:MIN:%5.1lf%s Min,', - 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,', - 'GPRINT:max:MAX:%5.1lf%s Max,', - 'GPRINT:avg:LAST:%5.1lf%s Last\l' + ps_count => ['-v', 'Processes', + 'DEF:procs_avg={file}:processes:AVERAGE', + 'DEF:procs_min={file}:processes:MIN', + 'DEF:procs_max={file}:processes:MAX', + 'DEF:thrds_avg={file}:threads:AVERAGE', + 'DEF:thrds_min={file}:threads:MIN', + 'DEF:thrds_max={file}:threads:MAX', + "AREA:thrds_avg#$HalfBlue", + "AREA:procs_avg#$HalfRed", + "LINE1:thrds_avg#$FullBlue:Threads ", + 'GPRINT:thrds_min:MIN:%5.1lf Min,', + 'GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,', + 'GPRINT:thrds_max:MAX:%5.1lf Max,', + 'GPRINT:thrds_avg:LAST:%5.1lf Last\l', + "LINE1:procs_avg#$FullRed:Processes", + 'GPRINT:procs_min:MIN:%5.1lf Min,', + 'GPRINT:procs_avg:AVERAGE:%5.1lf Avg,', + 'GPRINT:procs_max:MAX:%5.1lf Max,', + 'GPRINT:procs_avg:LAST:%5.1lf Last\l' ], - ps_cputime => [ + ps_cputime => ['-v', 'Jiffies', 'DEF:user_avg_raw={file}:user:AVERAGE', 'DEF:user_min_raw={file}:user:MIN', 'DEF:user_max_raw={file}:user:MAX', @@ -1981,27 +2016,7 @@ sub load_graph_definitions 'GPRINT:syst_max:MAX:%5.1lf%s Max,', 'GPRINT:syst_avg:LAST:%5.1lf%s Last\l' ], - ps_count => [ - 'DEF:procs_avg={file}:processes:AVERAGE', - 'DEF:procs_min={file}:processes:MIN', - 'DEF:procs_max={file}:processes:MAX', - 'DEF:thrds_avg={file}:threads:AVERAGE', - 'DEF:thrds_min={file}:threads:MIN', - 'DEF:thrds_max={file}:threads:MAX', - "AREA:thrds_avg#$HalfBlue", - "AREA:procs_avg#$HalfRed", - "LINE1:thrds_avg#$FullBlue:Threads ", - 'GPRINT:thrds_min:MIN:%5.1lf Min,', - 'GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,', - 'GPRINT:thrds_max:MAX:%5.1lf Max,', - 'GPRINT:thrds_avg:LAST:%5.1lf Last\l', - "LINE1:procs_avg#$FullRed:Processes", - 'GPRINT:procs_min:MIN:%5.1lf Min,', - 'GPRINT:procs_avg:AVERAGE:%5.1lf Avg,', - 'GPRINT:procs_max:MAX:%5.1lf Max,', - 'GPRINT:procs_avg:LAST:%5.1lf Last\l' - ], - ps_pagefaults => [ + ps_pagefaults => ['-v', 'Pagefaults/s', 'DEF:minor_avg={file}:minflt:AVERAGE', 'DEF:minor_min={file}:minflt:MIN', 'DEF:minor_max={file}:minflt:MAX', @@ -2022,6 +2037,17 @@ sub load_graph_definitions 'GPRINT:major_max:MAX:%5.1lf%s Max,', 'GPRINT:major_avg:LAST:%5.1lf%s Last\l' ], + ps_rss => ['-v', 'Bytes', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', + "AREA:avg#$HalfBlue", + "LINE1:avg#$FullBlue:RSS", + 'GPRINT:min:MIN:%5.1lf%s Min,', + 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,', + 'GPRINT:max:MAX:%5.1lf%s Max,', + 'GPRINT:avg:LAST:%5.1lf%s Last\l' + ], ps_state => ['-v', 'Processes', 'DEF:avg={file}:value:AVERAGE', 'DEF:min={file}:value:MIN', @@ -2070,7 +2096,7 @@ sub load_graph_definitions 'GPRINT:max:MAX:%6.2lf%sByte Max,', 'GPRINT:avg:LAST:%6.2lf%sByte Last\l' ], - ols_swap => [ + old_swap => [ 'DEF:used_avg={file}:used:AVERAGE', 'DEF:used_min={file}:used:MIN', 'DEF:used_max={file}:used:MAX', @@ -2114,6 +2140,18 @@ sub load_graph_definitions 'GPRINT:used_max:MAX:%5.1lf%s Max,', 'GPRINT:used_avg:LAST:%5.1lf%s Last\l' ], + tcp_connections => ['-v', 'Connections', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Connections", + 'GPRINT:min:MIN:%4.1lf Min,', + 'GPRINT:avg:AVERAGE:%4.1lf Avg,', + 'GPRINT:max:MAX:%4.1lf Max,', + 'GPRINT:avg:LAST:%4.1lf Last\l' + ], temperature => ['-v', 'Celsius', 'DEF:temp_avg={file}:value:AVERAGE', 'DEF:temp_min={file}:value:MIN', @@ -2127,7 +2165,7 @@ sub load_graph_definitions 'GPRINT:temp_max:MAX:%4.1lf Max,', 'GPRINT:temp_avg:LAST:%4.1lf Last\l' ], - timeleft => [ + timeleft => ['-v', 'Minutes', 'DEF:avg={file}:timeleft:AVERAGE', 'DEF:min={file}:timeleft:MIN', 'DEF:max={file}:timeleft:MAX', @@ -2211,7 +2249,7 @@ sub load_graph_definitions 'GPRINT:multimeter_max:MAX:%4.1lf Max,', 'GPRINT:multimeter_avg:LAST:%4.1lf Last\l' ], - users => [ + users => ['-v', 'Users', 'DEF:users_avg={file}:users:AVERAGE', 'DEF:users_min={file}:users:MIN', 'DEF:users_max={file}:users:MAX', @@ -2328,6 +2366,7 @@ sub load_graph_definitions $MetaGraphDefs->{'swap'} = \&meta_graph_swap; $MetaGraphDefs->{'mysql_commands'} = \&meta_graph_mysql_commands; $MetaGraphDefs->{'mysql_handler'} = \&meta_graph_mysql_commands; + $MetaGraphDefs->{'tcp_connections'} = \&meta_graph_tcp_connections; } # load_graph_definitions sub meta_graph_generic_stack @@ -2444,6 +2483,8 @@ sub meta_graph_cpu $opts->{'title'} = "$host/$plugin" . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type"; + $opts->{'rrd_opts'} = ['-v', 'Percent']; + my @files = (); $opts->{'colors'} = @@ -2701,6 +2742,7 @@ sub meta_graph_ps_state $opts->{'title'} = "$host/$plugin" . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type"; + $opts->{'rrd_opts'} = ['-v', 'Processes']; my @files = (); @@ -2760,6 +2802,7 @@ sub meta_graph_swap $opts->{'title'} = "$host/$plugin" . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type"; $opts->{'number_format'} = '%5.1lf%s'; + $opts->{'rrd_opts'} = ['-v', 'Bytes']; my @files = (); @@ -2801,4 +2844,70 @@ sub meta_graph_swap return (meta_graph_generic_stack ($opts, $sources)); } # meta_graph_swap +sub meta_graph_tcp_connections +{ + confess ("Wrong number of arguments") if (@_ != 5); + + my $host = shift; + my $plugin = shift; + my $plugin_instance = shift; + my $type = shift; + my $type_instances = shift; + + my $opts = {}; + my $sources = []; + + $opts->{'title'} = "$host/$plugin" + . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type"; + $opts->{'number_format'} = '%6.2lf'; + + $opts->{'rrd_opts'} = ['-v', 'Connections']; + + my @files = (); + + $opts->{'colors'} = + { + ESTABLISHED => '00e000', + SYN_SENT => '00e0ff', + SYN_RECV => '00e0a0', + FIN_WAIT1 => 'f000f0', + FIN_WAIT2 => 'f000a0', + TIME_WAIT => 'ffb000', + CLOSE => '0000f0', + CLOSE_WAIT => '0000a0', + LAST_ACK => '000080', + LISTEN => 'ff0000', + CLOSING => '000000' + }; + + _custom_sort_arrayref ($type_instances, + [reverse qw(ESTABLISHED SYN_SENT SYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSE + CLOSE_WAIT LAST_ACK CLOSING LISTEN)]); + + for (@$type_instances) + { + my $inst = $_; + my $file = ''; + my $title = $opts->{'title'}; + + for (@DataDirs) + { + if (-e "$_/$title-$inst.rrd") + { + $file = "$_/$title-$inst.rrd"; + last; + } + } + confess ("No file found for $title") if ($file eq ''); + + push (@$sources, + { + name => $inst, + file => $file + } + ); + } # for (@$type_instances) + + return (meta_graph_generic_stack ($opts, $sources)); +} # meta_graph_tcp_connections # vim: shiftwidth=2:softtabstop=2:tabstop=8