From 571806f201f21a10f6f700a4adf57480fafe5d54 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 26 Aug 2009 13:46:36 +0200 Subject: [PATCH] collection3: Add the possibility to scale generic graphs. --- contrib/collection3/etc/collection.conf | 8 +++++++ .../collection3/lib/Collectd/Graph/Type.pm | 22 +++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/contrib/collection3/etc/collection.conf b/contrib/collection3/etc/collection.conf index 86cb3aa1..f4c7f5d6 100644 --- a/contrib/collection3/etc/collection.conf +++ b/contrib/collection3/etc/collection.conf @@ -501,6 +501,14 @@ GraphWidth 400 RRDVerticalLabel "°Celsius" RRDFormat "%4.1lf°C" + + DataSources value + DSName "value Time" + RRDTitle "Time {instance}" + RRDVerticalLabel "Seconds" + RRDFormat "%6.2lf %ss" + Scale 0.001 + DataSources users DSName users Users diff --git a/contrib/collection3/lib/Collectd/Graph/Type.pm b/contrib/collection3/lib/Collectd/Graph/Type.pm index 1fb60afe..01c2417c 100644 --- a/contrib/collection3/lib/Collectd/Graph/Type.pm +++ b/contrib/collection3/lib/Collectd/Graph/Type.pm @@ -349,10 +349,24 @@ sub getRRDArgs $f =~ s#:#\\:#g; $ds_name =~ s#:#\\:#g; - push (@ret, - "DEF:min${i}=${f}:${ds_name}:MIN", - "DEF:avg${i}=${f}:${ds_name}:AVERAGE", - "DEF:max${i}=${f}:${ds_name}:MAX"); + if (exists ($obj->{'scale'})) + { + my $scale = 0.0 + $obj->{'scale'}; + push (@ret, + "DEF:min${i}_raw=${f}:${ds_name}:MIN", + "DEF:avg${i}_raw=${f}:${ds_name}:AVERAGE", + "DEF:max${i}_raw=${f}:${ds_name}:MAX", + "CDEF:max${i}=max${i}_raw,$scale,*", + "CDEF:avg${i}=avg${i}_raw,$scale,*", + "CDEF:min${i}=min${i}_raw,$scale,*"); + } + else + { + push (@ret, + "DEF:min${i}=${f}:${ds_name}:MIN", + "DEF:avg${i}=${f}:${ds_name}:AVERAGE", + "DEF:max${i}=${f}:${ds_name}:MAX"); + } } if (@$ds == 1) -- 2.30.2