From 354fa3a2dac79b239d7a29d2979a2fbfdd54b0a7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 27 Jul 2008 17:22:26 +0200 Subject: [PATCH] contrib/collection3: Add a generic `instance' placeholder. It will be replaced by either the type or plugin instance, depending on which is defined.. This is handy for temperatures and stuff like that, where sometimes the type instance doesn't exist. --- contrib/collection3/etc/collection.conf | 4 ++-- contrib/collection3/lib/Collectd/Graph/Type.pm | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/contrib/collection3/etc/collection.conf b/contrib/collection3/etc/collection.conf index a8be4fda..e60316fe 100644 --- a/contrib/collection3/etc/collection.conf +++ b/contrib/collection3/etc/collection.conf @@ -108,7 +108,7 @@ GraphWidth 400 DataSources value DSName value RPM - RRDTitle "Fanspeed ({type_instance})" + RRDTitle "Fanspeed ({instance})" RRDVerticalLabel "RPM" RRDFormat "%6.1lf" Color value 00b000 @@ -263,7 +263,7 @@ GraphWidth 400 DataSources value DSName value Temp - RRDTitle "Temperature ({type_instance})" + RRDTitle "Temperature ({instance})" RRDVerticalLabel "°Celsius" RRDFormat "%4.1lf°C" diff --git a/contrib/collection3/lib/Collectd/Graph/Type.pm b/contrib/collection3/lib/Collectd/Graph/Type.pm index 60097e5c..1fb60afe 100644 --- a/contrib/collection3/lib/Collectd/Graph/Type.pm +++ b/contrib/collection3/lib/Collectd/Graph/Type.pm @@ -248,6 +248,20 @@ sub getTitle my $plugin_instance = $ident->{'plugin_instance'}; my $type = $ident->{'type'}; my $type_instance = $ident->{'type_instance'}; + my $instance; + + if (defined $type_instance) + { + $instance = $type_instance; + } + elsif (defined $plugin_instance) + { + $instance = $plugin_instance; + } + else + { + $instance = 'no instance'; + } if (!defined $plugin_instance) { @@ -264,6 +278,7 @@ sub getTitle $title =~ s#{plugin_instance}#$plugin_instance#g; $title =~ s#{type}#$type#g; $title =~ s#{type_instance}#$type_instance#g; + $title =~ s#{instance}#$instance#g; return ($title); } -- 2.30.2