Code

contrib/collection.cgi: Added ability to hide specified types.
authorPavel Piatruk <piatruk.p@gmail.com>
Fri, 22 Jan 2010 08:13:29 +0000 (09:13 +0100)
committerFlorian Forster <octo@huhu.verplant.org>
Fri, 22 Jan 2010 08:13:29 +0000 (09:13 +0100)
It is useful when you don't want to see many graphs. How to use the patch:
apply it to collection.cgi and add lines with keyword ,,dontshowtype'' to
/etc/collectd/collection.conf:

dontshowtype: "if_errors"
dontshowtype: "if_packets"

Then you will see only if_octets types in "interface" plugin page.

Via Debian bug #566199.

contrib/collection.cgi

index cbdb76e846df35eed803e7de3940c03d00b98bdd..100c0c73b2a469d37081b64200bd3e3375ba43e2 100755 (executable)
@@ -13,6 +13,7 @@ use Data::Dumper ();
 
 our $Config = "/etc/collection.conf";
 our @DataDirs = ();
+our @DontShowTypes = ();
 our $LibDir;
 
 our $ValidTimespan =
@@ -78,6 +79,10 @@ sub read_config
                        $value =~ s#/*$##;
                        $LibDir = $value;
                }
+               elsif ($key eq 'dontshowtype')
+               {
+                 push (@DontShowTypes, $value);
+               }
                else
                {
                        print STDERR "Unknown key: $key\n";
@@ -239,6 +244,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));
     }