[collectd] [PATCH] collection.cgi: Made sorting of graphs configurable.

Sebastian Harl sh<span style="display: none;">.trailing-username</span>(a)<span style="display: none;">leading-domain.</span>tokkee.org
Thu Feb 1 15:53:06 CET 2007


On Thu, Feb 01, 2007 at 01:56:41PM +0100, Dieter Bloms wrote:
> I want to change the order when viewing the results in a browser like:
> 
> cpu usage
> load usage
> hddtemp
> traffic
> 
> is it possible to do it ?

Please try the attached patch. Simply set the value of @plugins to the list of
plugins you want to display.
(e.g. "@plugins = (qw( cpu load hddtemp traffic ))")

Signed-off-by: Sebastian Harl <sh.trailing-username(a)leading-domain.tokkee.org>
---
 contrib/collection.cgi |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/contrib/collection.cgi b/contrib/collection.cgi
index 5c8bd4d..559fa5d 100755
--- a/contrib/collection.cgi
+++ b/contrib/collection.cgi
@@ -12,6 +12,10 @@ use Carp (qw(carp cluck confess croak));
 
 our $Config = read_config ();
 
+# if this array contains any elements, only plugins listed therein are
+# displayed in the given order
+my @plugins = ();
+
 our $AbsDir;
 our $RelDir;
 our $Type;
@@ -1891,10 +1895,21 @@ HTML
 			print "</ul>\n";
 		}
 
-		for (sort (keys %$files))
+		my @tmp;
+
+		if (scalar @plugins > 0) {
+			@tmp = @plugins;
+		}
+		else {
+			@tmp = sort keys %$files;
+		}
+
+		for (@tmp)
 		{
 			my $type = $_;
 
+			next if (! defined $files->{$type});
+
 			if (ref ($GraphMulti->{$type}) eq 'CODE')
 			{
 				print qq(\t\t<a href="$MySelf$RelDir/$type" />),
-- 
1.4.3.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20070201/64d69797/attachment.pgp


More information about the collectd mailing list