Calculate an average per time base
Moderators: Developers, Moderators
-
- Cacti User
- Posts: 97
- Joined: Thu Mar 24, 2005 4:59 am
- Location: Brussels, Belgium
Calculate an average per time base
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 !
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
- printer_graph_image.png (19.25 KiB) Viewed 2810 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]
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
-
- Cacti User
- Posts: 97
- Joined: Thu Mar 24, 2005 4:59 am
- Location: Brussels, Belgium
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.
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]
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
See http://www.cacti.net/downloads/docs/htm ... _VARIABLES for some "statistic functions" of cacti
Reinhard
Reinhard
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
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]
[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]
-
- Cacti User
- Posts: 97
- Joined: Thu Mar 24, 2005 4:59 am
- Location: Brussels, Belgium
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]
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
-
- Cacti User
- Posts: 97
- Joined: Thu Mar 24, 2005 4:59 am
- Location: Brussels, Belgium
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]
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
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 numbersBelgianViking 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.
Reinhard
Who is online
Users browsing this forum: No registered users and 1 guest