[PATCH] Graphing Nth Percentile in Cacti

Anything that you think should be in Cacti.

Moderators: Developers, Moderators

Post Reply
JuanK
Posts: 2
Joined: Sun Jul 24, 2005 1:34 am
Location: Medellín, Colombia

[PATCH] Graphing Nth Percentile in Cacti

Post by JuanK »

Hi,

In order to show any percentile of the traffic graph, not only the 95th percentile, I have made some changes to a pair of the php Cacti files which are located in /lib folder.

I am working with Cacti 0.8.6c. The changes were as follows:

1. In file rrd.php locate the label /* 95th percentile */
2. Replace the "95" in the regular expression pattern with [0-9]{2}
3. Add this line just after foreach sentence:

Code: Select all

$percent = substr($match[0],1,2);
4. Add $percent as the last variable in the variable_ninety_fifth_percentile function

5. In the file graph_variables.php locate the function declaration for variable_ninety_fifth_percentile.
6. Include $percent as a new variable of this function.
7. Look into variable_ninety_fifth_percentile for both of the ninety_fifth_percentile function calls and add $percent as the last variable in both of them.
8. Locate the function declaration for ninety_fifth_percentile.
9. Add $percent as the last variable in the function.
10. Replace the line

Code: Select all

$target = ((count($values_array) + 1) * 0.05);
with

Code: Select all

$target = ((count($values_array) + 1) * (1-$percent/100));
After this changes you can define any percentile using the same format, it means |N:(bits|bytes):[0-9]:(current|total|max):[0-9]|.

Note that the percentil N value must be a 2-digit number.
Bye,

Juan_K
Colombia, SouthAmerica
User avatar
Pumpi
Cacti User
Posts: 259
Joined: Wed Jan 14, 2004 3:23 am
Location: Germany

Post by Pumpi »

JuanK,

have you modified this also for Cacti 08.6g ?

Perhaps you can forward me your rrd.php and graph_variables.php

??
:roll:
Last edited by Pumpi on Tue Nov 29, 2005 10:36 am, edited 1 time in total.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Um, add a feature request, I will look at placing this into 0.9.0.
[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]
User avatar
Pumpi
Cacti User
Posts: 259
Joined: Wed Jan 14, 2004 3:23 am
Location: Germany

Post by Pumpi »

rony,

perhaps you can help me with the current release, because I have to monitor my customer now with 80th percentage ??

Best regards

Pumpi
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

I'm going to work on including this change in 0.8.6.

Please post a bug/feature request at bugs.cacti.net. Link this post in that feature request.
[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]
User avatar
Pumpi
Cacti User
Posts: 259
Joined: Wed Jan 14, 2004 3:23 am
Location: Germany

Post by Pumpi »

Done:

Mantis ID 0000640


:wink:
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

How about this... :D
Attachments
Nth Percentile Example
Nth Percentile Example
nth_test1.png (125.6 KiB) Viewed 10754 times
[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]
User avatar
Pumpi
Cacti User
Posts: 259
Joined: Wed Jan 14, 2004 3:23 am
Location: Germany

Post by Pumpi »

:D Yes, that's what I'm looking for - Thanks a lot !

BTW, is Cacti using this technique for calculating the Percentage, for example for a 95th Percentage (found this post somewhere else):
a) take the number of bytes xfered over a 5 minute period, and determine
rate for both the inbound and outbound. Store this in your favorite
data-store.

b) at billing time, presumably on the first of the month or some other
monthly increment, take all the samples, sort them from greatest to least,
hacking off the top 5% of samples. Actually, this is done twice, once for
inbound, once for outbound. Then, take the higher of those two, and multiply it by your favorite $ multiple (ie, $500 per megabit per second, or $1 per kilobit per second, etc).

I think that most people agree with the above; the issue we are running into is one rogue provider who is billing this at in + out, not the greater of in or out.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Cacti uses more than one technique for calculating Nth percentile...

Check out my beta 2 post in the announcements and review the "Graph Variables" section of the attached documentation for explainations of the available Nth percentile calculations.
[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]
JuanK
Posts: 2
Joined: Sun Jul 24, 2005 1:34 am
Location: Medellín, Colombia

Thanks for considering my code modification

Post by JuanK »

Rony, thanks for considering my modifications to this great code made by you and the other developers.

I was reviewing for some answers after posting my changes but due to diverse situations I was not able to review the forum until today.

Thanks again for considering my changes. I hope this change be useful to other users and developers.
Bye,

Juan_K
Colombia, SouthAmerica
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest