X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=contrib%2Fcollection.cgi;h=1231ce8b2159d27017ce317e6e802cca4ee884af;hb=5d0a10f15f361c6f019b48d0619e87ee8bb936e3;hp=7de8bcc839b49341d7d03aedceada67a96abf1f4;hpb=568420ac172981edccb8587cc9651952fe350365;p=collectd.git diff --git a/contrib/collection.cgi b/contrib/collection.cgi index 7de8bcc8..1231ce8b 100755 --- a/contrib/collection.cgi +++ b/contrib/collection.cgi @@ -1,4 +1,25 @@ #!/usr/bin/perl +# Copyright (c) 2006-2010 Florian Forster +# Copyright (c) 2006-2008 Sebastian Harl +# Copyright (c) 2008 Mirko Buffoni +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. use strict; use warnings; @@ -13,6 +34,7 @@ use Data::Dumper (); our $Config = "/etc/collection.conf"; our @DataDirs = (); +our @DontShowTypes = (); our $LibDir; our $ValidTimespan = @@ -78,6 +100,10 @@ sub read_config $value =~ s#/*$##; $LibDir = $value; } + elsif ($key eq 'dontshowtype') + { + push (@DontShowTypes, $value); + } else { print STDERR "Unknown key: $key\n"; @@ -239,6 +265,7 @@ sub _find_types my $name = "$_"; $name =~ s/\.rrd$//i; my ($type, $instance) = split (m/-/, $name, 2); + if (grep { $_ eq $type } @DontShowTypes) { next; } $types{$type} = [] if (!$types{$type}); push (@{$types{$type}}, $instance) if (defined ($instance)); } @@ -951,9 +978,9 @@ sub load_graph_definitions $GraphDefs = { - apache_bytes => ['DEF:min_raw={file}:count:MIN', - 'DEF:avg_raw={file}:count:AVERAGE', - 'DEF:max_raw={file}:count:MAX', + apache_bytes => ['DEF:min_raw={file}:value:MIN', + 'DEF:avg_raw={file}:value:AVERAGE', + 'DEF:max_raw={file}:value:MAX', 'CDEF:min=min_raw,8,*', 'CDEF:avg=avg_raw,8,*', 'CDEF:max=max_raw,8,*', @@ -970,9 +997,31 @@ sub load_graph_definitions 'GPRINT:avg:LAST:%5.1lf%s Last', 'GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)\l' ], - apache_requests => ['DEF:min={file}:count:MIN', - 'DEF:avg={file}:count:AVERAGE', - 'DEF:max={file}:count:MAX', + apache_connections => ['DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Connections", + 'GPRINT:min:MIN:%6.2lf Min,', + 'GPRINT:avg:AVERAGE:%6.2lf Avg,', + 'GPRINT:max:MAX:%6.2lf Max,', + 'GPRINT:avg:LAST:%6.2lf Last' + ], + apache_idle_workers => ['DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Idle Workers", + 'GPRINT:min:MIN:%6.2lf Min,', + 'GPRINT:avg:AVERAGE:%6.2lf Avg,', + 'GPRINT:max:MAX:%6.2lf Max,', + 'GPRINT:avg:LAST:%6.2lf Last' + ], + apache_requests => ['DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', "AREA:max#$HalfBlue", "AREA:min#$Canvas", "LINE1:avg#$FullBlue:Requests/s", @@ -981,9 +1030,9 @@ sub load_graph_definitions 'GPRINT:max:MAX:%6.2lf Max,', 'GPRINT:avg:LAST:%6.2lf Last' ], - apache_scoreboard => ['DEF:min={file}:count:MIN', - 'DEF:avg={file}:count:AVERAGE', - 'DEF:max={file}:count:MAX', + apache_scoreboard => ['DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', "AREA:max#$HalfBlue", "AREA:min#$Canvas", "LINE1:avg#$FullBlue:Processes", @@ -1290,9 +1339,9 @@ sub load_graph_definitions 'GPRINT:avg:LAST:%4.1lf Last\l' ], spam_check => [ - 'DEF:avg={file}:hits:AVERAGE', - 'DEF:min={file}:hits:MIN', - 'DEF:max={file}:hits:MAX', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', "AREA:max#$HalfMagenta", "AREA:min#$Canvas", "LINE1:avg#$FullMagenta:Count ", @@ -1301,6 +1350,18 @@ sub load_graph_definitions 'GPRINT:max:MAX:%4.1lf Max,', 'GPRINT:avg:LAST:%4.1lf Last\l' ], + conntrack => ['-v', 'Entries', + 'DEF:avg={file}:entropy:AVERAGE', + 'DEF:min={file}:entropy:MIN', + 'DEF:max={file}:entropy:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Count", + 'GPRINT:min:MIN:%4.0lf Min,', + 'GPRINT:avg:AVERAGE:%4.0lf Avg,', + 'GPRINT:max:MAX:%4.0lf Max,', + 'GPRINT:avg:LAST:%4.0lf Last\l' + ], entropy => ['-v', 'Bits', 'DEF:avg={file}:entropy:AVERAGE', 'DEF:min={file}:entropy:MIN', @@ -2544,11 +2605,96 @@ sub load_graph_definitions 'GPRINT:max:MAX:%5.1lf Max,', 'GPRINT:avg:LAST:%5.1lf Last\l', ], + vmpage_number => ['-v', 'Pages', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Number", + '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' + ], + vmpage_faults => [ + "DEF:minf_avg={file}:minflt:AVERAGE", + "DEF:minf_min={file}:minflt:MIN", + "DEF:minf_max={file}:minflt:MAX", + "DEF:majf_avg={file}:majflt:AVERAGE", + "DEF:majf_min={file}:majflt:MIN", + "DEF:majf_max={file}:majflt:MAX", + 'CDEF:overlap=majf_avg,minf_avg,GT,minf_avg,majf_avg,IF', + "AREA:majf_avg#$HalfGreen", + "AREA:minf_avg#$HalfBlue", + "AREA:overlap#$HalfBlueGreen", + "LINE1:majf_avg#$FullGreen:Major", + 'GPRINT:majf_min:MIN:%5.1lf%s Min,', + 'GPRINT:majf_avg:AVERAGE:%5.1lf%s Avg,', + 'GPRINT:majf_max:MAX:%5.1lf%s Max,', + 'GPRINT:majf_avg:LAST:%5.1lf%s Last\l', + "LINE1:minf_avg#$FullBlue:Minor", + 'GPRINT:minf_min:MIN:%5.1lf%s Min,', + 'GPRINT:minf_avg:AVERAGE:%5.1lf%s Avg,', + 'GPRINT:minf_max:MAX:%5.1lf%s Max,', + 'GPRINT:minf_avg:LAST:%5.1lf%s Last\l' + ], + vmpage_io => [ + "DEF:rpag_avg={file}:in:AVERAGE", + "DEF:rpag_min={file}:in:MIN", + "DEF:rpag_max={file}:in:MAX", + "DEF:wpag_avg={file}:out:AVERAGE", + "DEF:wpag_min={file}:out:MIN", + "DEF:wpag_max={file}:out:MAX", + 'CDEF:overlap=wpag_avg,rpag_avg,GT,rpag_avg,wpag_avg,IF', + "AREA:wpag_avg#$HalfGreen", + "AREA:rpag_avg#$HalfBlue", + "AREA:overlap#$HalfBlueGreen", + "LINE1:wpag_avg#$FullGreen:OUT", + 'GPRINT:wpag_min:MIN:%5.1lf%s Min,', + 'GPRINT:wpag_avg:AVERAGE:%5.1lf%s Avg,', + 'GPRINT:wpag_max:MAX:%5.1lf%s Max,', + 'GPRINT:wpag_avg:LAST:%5.1lf%s Last\l', + "LINE1:rpag_avg#$FullBlue:IN ", + 'GPRINT:rpag_min:MIN:%5.1lf%s Min,', + 'GPRINT:rpag_avg:AVERAGE:%5.1lf%s Avg,', + 'GPRINT:rpag_max:MAX:%5.1lf%s Max,', + 'GPRINT:rpag_avg:LAST:%5.1lf%s Last\l' + ], + vmpage_action => ['-v', 'Pages', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Number", + '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' + ], + virt_cpu_total => ['-v', 'Milliseconds', + 'DEF:avg_raw={file}:ns:AVERAGE', + 'DEF:min_raw={file}:ns:MIN', + 'DEF:max_raw={file}:ns:MAX', + 'CDEF:avg=avg_raw,1000000,/', + 'CDEF:min=min_raw,1000000,/', + 'CDEF:max=max_raw,1000000,/', + "AREA:avg#$HalfBlue", + "LINE1:avg#$FullBlue:CPU time", + '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' + ], }; $GraphDefs->{'if_multicast'} = $GraphDefs->{'ipt_packets'}; $GraphDefs->{'if_tx_errors'} = $GraphDefs->{'if_rx_errors'}; $GraphDefs->{'dns_qtype'} = $GraphDefs->{'dns_opcode'}; $GraphDefs->{'dns_rcode'} = $GraphDefs->{'dns_opcode'}; + $GraphDefs->{'vmpage_io-memory'} = $GraphDefs->{'vmpage_io'}; + $GraphDefs->{'vmpage_io-swap'} = $GraphDefs->{'vmpage_io'}; + $GraphDefs->{'virt_cpu_total'} = $GraphDefs->{'virt_cpu_total'}; $MetaGraphDefs->{'cpu'} = \&meta_graph_cpu; $MetaGraphDefs->{'dns_qtype'} = \&meta_graph_dns; @@ -2562,6 +2708,8 @@ sub load_graph_definitions $MetaGraphDefs->{'mysql_commands'} = \&meta_graph_mysql_commands; $MetaGraphDefs->{'mysql_handler'} = \&meta_graph_mysql_commands; $MetaGraphDefs->{'tcp_connections'} = \&meta_graph_tcp_connections; + $MetaGraphDefs->{'vmpage_number'} = \&meta_graph_vmpage_number; + $MetaGraphDefs->{'vmpage_action'} = \&meta_graph_vmpage_action; } # load_graph_definitions sub meta_graph_generic_stack @@ -3163,4 +3311,131 @@ sub meta_graph_tcp_connections return (meta_graph_generic_stack ($opts, $sources)); } # meta_graph_tcp_connections + +sub meta_graph_vmpage_number +{ + 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', 'Pages']; + + my @files = (); + + $opts->{'colors'} = + { + anon_pages => '00e000', + bounce => '00e0ff', + dirty => '00e0a0', + file_pages => 'f000f0', + mapped => 'f000a0', + page_table_pages => 'ffb000', + slab => '0000f0', + unstable => '0000a0', + writeback => 'ff0000', + }; + + _custom_sort_arrayref ($type_instances, + [reverse qw(anon_pages bounce dirty file_pages mapped page_table_pages slab unstable writeback)]); + + 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_vmpage_number + +sub meta_graph_vmpage_action +{ + 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', 'Pages']; + + my @files = (); + + $opts->{'colors'} = + { + activate => '00e000', + deactivate => '00e0ff', + free => '00e0a0', + alloc => 'f000f0', + refill => 'f000a0', + scan_direct => 'ffb000', + scan_kswapd => '0000f0', + steal => '0000a0', + }; + + _custom_sort_arrayref ($type_instances, + [reverse qw(activate deactivate alloc free refill scan_direct scan_kswapd steal)]); + + 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_vmpage_action # vim: shiftwidth=2:softtabstop=2:tabstop=8