How to display COUNTER (not per second but totaling diff) ?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
long
Posts: 45
Joined: Tue Oct 12, 2010 9:27 pm
Location: Canada

How to display COUNTER (not per second but totaling diff) ?

Post by long »

Hi,

Here's the scenario:

Polling every minute.

Code: Select all

minute:          0      1      2        3       4        5
value:           0     30     60       60     120      150
difference       0     30     30        0      60       30
COUNTER:         0    0.5    0.5        0       1      0.5
Regular Consolidation 5 points using AVERAGE CF: 0.5 + 0.5 + 1 + 0.5 = 2.5/5 = 0.5 per sec
Totaling difference 5 points (what I want): 30 + 30 + 60 + 30 = 150 (totaling all differences between each reading (so that at 5 pt consolidation, it looks like we polled every 5 minutes, not every minute), not divided by any time frame)
So basically, is there a way to alter the display of COUNTER data type, to instead of displaying per seconds, to display per step size at each higher level of consolidation (Daily, Weekly, Monthly, Yearly). That means never do the division by step_size and always adding the difference of each reading. So Daily would be the total for 5 min, Weekly would be the total for 30 mins, and so on.

So how to display COUNTER, not as rate of change per second, but showing the difference at each reading ?

Thanks,
Long
Last edited by long on Thu May 05, 2011 9:15 am, edited 1 time in total.
long
Posts: 45
Joined: Tue Oct 12, 2010 9:27 pm
Location: Canada

Re: How to display COUNTER (not per second but totaling diff

Post by long »

Anyone has an idea?

Thanks,
Long
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: How to display COUNTER (not per second but totaling diff

Post by gandalf »

long wrote:Hi,

Here's the scenario:

Polling every minute.

Code: Select all

minute:          0      1      2        3       4        5
value:           0     30     60       60     120      150
difference       0     30     30        0      60       30
COUNTER:         0    0.5    0.5        0       1      0.5
Regular Consolidation 5 points : 0.5 + 0.5 + 1 + 0.5 = 2.5/300sec = 0.0083 per sec
Totaling difference 5 points (what I want): 30 + 30 + 60 + 30 = 150 (totaling all differences between each reading (so that at 5 pt consolidation, it looks like we polled every 5 minutes, not every minute), not divided by any time frame)
So basically, is there a way to alter the display of COUNTER data type, to instead of displaying per seconds, to display per step size at each higher level of consolidation (Daily, Weekly, Monthly, Yearly). That means never do the division by step_size and always adding the difference of each reading. So Daily would be the total for 5 min, Weekly would be the total for 30 mins, and so on.

So how to display COUNTER, not as rate of change per second, but showing the difference at each reading ?

Thanks,
Long
As told on the rrdtool mailing list, e.g. http://www.vandenbogaerdt.nl/rrdtool/total.php explains the trick (unfortunately, we do not yet support VDEF; this will be introduced with Cacti 088).
We need the AVERAGE of the interval displayed and multiply it by the timespan to get the total.
In your example, the AVERAGE is 30/min and the timespan is 5 min which results in a grand total of 150, as wanted.
R.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: How to display COUNTER (not per second but totaling diff

Post by gandalf »

Best matching solution is to use http://docs.cacti.net/manual:087:6_refe ... _variables on bandwidth summation.
E.g. a COMMENT of |sum:0:current:2:auto| should do. Using |sum:auto:current:2:auto| unfortunately adds a unit description of bytes|kb|MB|GB and the like which will not match when using data sources that do not represent a traffic counter.
An example can be found in the Graph Templates for Traffic that are labeled "Total Bandwidth"
R.
long
Posts: 45
Joined: Tue Oct 12, 2010 9:27 pm
Location: Canada

Re: How to display COUNTER (not per second but totaling diff

Post by long »

Hi gandalf,

I've used the "bandwidth summation" feature in my traffic graphs.

I understand what it does. It sums up all the values in the graph time range (the viewable range of the graph) so if my graph starts at day 1 and finish at day 2, it will adds up all the values within one day time range. That's not what I need.

If I am polling every 5 minutes and that 1 day time range graph has a resolution of 30 minutes, then I want each data point (that present 30 mins) to have the sum of each of the 5 minutes data points, not the sum of the whole day (not the sum of all the data points in the viewable range of the graph).

Any realistic expected date for 0.8.8 release?

Thanks,
Long
long
Posts: 45
Joined: Tue Oct 12, 2010 9:27 pm
Location: Canada

Re: How to display COUNTER (not per second but totaling diff

Post by long »

Hi,

I have patched RRDTool 1.4.5 and Cacti 0.8.7g to do what I described in this thread. I introduced a new Data Type called DIFFERENCE which behave like COUNTER without the division by the step period and a new Consolidation Function SUM that does the sum.

RRDTool patch: http://rrd-mailinglists.937164.n2.nabbl ... ?by-user=t
RRDTool forum discussion thread http://rrd-mailinglists.937164.n2.nabbl ... 90330.html

Here's the Cacti patch corresponding to the RRDTool patch above. It's created from svn://svn.cacti.net/cacti/cacti/branches/0.8.7

Code: Select all

Index: lib/functions.php
===================================================================
--- lib/functions.php	(revision 6338)
+++ lib/functions.php	(working copy)
@@ -1310,6 +1310,9 @@
 			case "LAST":
 				$new_cfs[] = array_search('LAST', $consolidation_functions);
 				break;
+			case "SUM":
+				$new_cfs[] = array_search('SUM', $consolidation_functions);
+				break;
 			}
 		}
 	}
Index: lib/rrd.php
===================================================================
--- lib/rrd.php	(revision 6338)
+++ lib/rrd.php	(working copy)
@@ -1039,6 +1039,8 @@
 				$cf_id = 2; /* CF: MIN */
 			}elseif (isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[4])) {
 				$cf_id = 4; /* CF: LAST */
+			}elseif (isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[5])) {
+				$cf_id = 5; /* CF: SUM */
 			}else{
 				$cf_id = 1; /* CF: AVERAGE */
 			}
@@ -1711,6 +1713,8 @@
 				$cf_id = 2; /* CF: MIN */
 			}elseif (isset($cf_ds_cache{$xport_item["data_template_rrd_id"]}[4])) {
 				$cf_id = 4; /* CF: LAST */
+			}elseif (isset($cf_ds_cache{$xport_item["data_template_rrd_id"]}[5])) {
+				$cf_id = 5; /* CF: SUM */
 			}else{
 				$cf_id = 1; /* CF: AVERAGE */
 			}
Index: include/global_arrays.php
===================================================================
--- include/global_arrays.php	(revision 6338)
+++ include/global_arrays.php	(working copy)
@@ -157,13 +157,15 @@
 	"AVERAGE",
 	"MIN",
 	"MAX",
-	"LAST");
+	"LAST",
+	"SUM");
 
 $data_source_types = array(1 =>
 	"GAUGE",
 	"COUNTER",
 	"DERIVE",
-	"ABSOLUTE");
+	"ABSOLUTE",
+	"DIFFERENCE");
 
 $graph_item_types = array(
 	GRAPH_ITEM_TYPE_COMMENT => "COMMENT",
fire555
Posts: 1
Joined: Mon May 02, 2011 7:39 pm
Location: Australia

Re: How to display COUNTER (not per second but totaling diff

Post by fire555 »

Hi Long,

I have attempted to patch rrdtool using the patch you supplied in the previous post. However I get the following error.

Code: Select all

patching file src/rrd_format.c
Hunk #3 FAILED at 100.
1 out of 3 hunks FAILED -- saving rejects to file src/rrd_format.c.rej
I am using version 1.4.5 of the source as downloaded from http://www.mrtg.org/rrdtool/pub/rrdtool-1.4.5.tar.gz. Are you able to shed any light on this?

Btw, I have been looking at a way to do this in Cacti for some time. Thanks for spending the time to develop this!
long
Posts: 45
Joined: Tue Oct 12, 2010 9:27 pm
Location: Canada

Re: How to display COUNTER (not per second but totaling diff

Post by long »

Hi fire555,

The error you got is normal. The RRDTool patch has been developed from the trunk so on the 1.4 branch, one of the hunk didn't exist yet so that's why the failure.

Just go ahead and build RRDTool. Everything should work.

Long
fernandocosta
Posts: 7
Joined: Fri Mar 25, 2011 9:10 am

Re: How to display COUNTER (not per second but totaling diff

Post by fernandocosta »

Well, I'm using version 0.8.8a and I still don't know how to get this working (without patching rrdtool).
Fernando
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests