Calculate an average per time base

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

Moderators: Developers, Moderators

Post Reply
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Calculate an average per time base

Post by BelgianViking »

I'm trying to define a CDEF that calculates an average increase of a graph item per time basis, but I can't seem to solve this. Mind you, this is completely different from the average function which is 'built-in'.
As an example, I have a graph showing the total number of pages printed on a certain printer. I would like to print the number of pages printed per day (hour, week, ... maybe). In this example this value should be calculated as (161308-159672)/32 days = 54,5 pages/day. So I need the minimum and maximum value of the selected time period and the lenght of the selected period in the graph to calculate this value.
I have searched the forums, but apparently, this has never been done before. Maybe it is not even possible ... ?
Thanks in advance !
Attachments
A sample graph
A sample graph
printer_graph_image.png (19.25 KiB) Viewed 2806 times
[size=75][color=#EE5019]| Cacti 0.8.6g | MySQL 4.1.14 w Query Cache | Net-SNMP 5.2.1 | IIS 6 | fast-cgi | PHP 5.0.3 | RRDtool 1.2.9 | Windows 2003 Server SP1 | Cactid 0.8.6f |
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
africanw
Cacti User
Posts: 130
Joined: Thu Mar 31, 2005 4:24 pm
Location: Sydney, Asutralia
Contact:

Post by africanw »

Just do the Calcs before it gets to Cacti.

So if you are gathering the data via a script do it there then just put the results on the datasource and then into the graph.
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

I don't immediately see how I can do that ...
Suppose I get the value of the value of the total number of pages printed, and this value is 161431 pages; how can I calculate an average number of pages over the last hour, last day, last week from that value only ?
I also would like to have this average printed for whichever period selected in the graph.
[size=75][color=#EE5019]| Cacti 0.8.6g | MySQL 4.1.14 w Query Cache | Net-SNMP 5.2.1 | IIS 6 | fast-cgi | PHP 5.0.3 | RRDtool 1.2.9 | Windows 2003 Server SP1 | Cactid 0.8.6f |
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

See http://www.cacti.net/downloads/docs/htm ... _VARIABLES for some "statistic functions" of cacti
Reinhard
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Well, if you had made this data source a COUNTER instead of a GAUGE, you would be seeing the data you would like to see.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

If I make it a counter, I loose the total number of pages printed, don't I ? I agree that that would make it easy to calculate the number of pages printed in a certain period of time.
[size=75][color=#EE5019]| Cacti 0.8.6g | MySQL 4.1.14 w Query Cache | Net-SNMP 5.2.1 | IIS 6 | fast-cgi | PHP 5.0.3 | RRDtool 1.2.9 | Windows 2003 Server SP1 | Cactid 0.8.6f |
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

Maybe I could live with just the number of pages printed in the period that is displayed in the graph. This would be 'easy', I thought: just take the current (or max) value and subtract the MIN value. However, I don't seem to be able to do that in a CDEF. This can't be true, can it ?
[size=75][color=#EE5019]| Cacti 0.8.6g | MySQL 4.1.14 w Query Cache | Net-SNMP 5.2.1 | IIS 6 | fast-cgi | PHP 5.0.3 | RRDtool 1.2.9 | Windows 2003 Server SP1 | Cactid 0.8.6f |
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

BelgianViking wrote:If I make it a counter, I loose the total number of pages printed, don't I ? I agree that that would make it easy to calculate the number of pages printed in a certain period of time.
That was already solved by a "nasty" workaround: Store both types, GAUGE _and_ COUNTER. Use two rrd's with one ds each or one rrd with two ds (this will require a wrapper script that prints the same data twice). Then use COUNTER for increments and GAUGE for absolute numbers
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests