Forum Discussion
Nicolas_Menant
Employee
Apr 10, 2008Retrieve number of current connections ?
Hi,
i developp an iControl api that will interact with the servers depending on the number of connection on each.
I have some issue to retrieve the number of current connections on each pool member:
Here is a test i do:
Here is the code
for (j = 0; j < mbstat[0].statistics[1].statistics.Length; j++)
if (mbstat[0].statistics[1].statistics[j].type == iControl.CommonStatisticType.STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS)
MessageBox.Show(mbstat[0].statistics[1].statistics[j].type.ToString() + ":" + mbstat[0].statistics[1].statistics[j].value.high.ToString());
I retrieve some value, it seems to always be 0 with high and with low i seem to have the proper value... what is the difference between the high and low value ?
When i add another test equivalent to this one i crash the application:
for (j = 0; j < mbstat[0].statistics[1].statistics.Length; j++)
if (mbstat[0].statistics[1].statistics[j].type == iControl.CommonStatisticType.STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS)
MessageBox.Show(mbstat[0].statistics[1].statistics[j].type.ToString() + ":" + mbstat[0].statistics[1].statistics[j].value.high.ToString());
if (mbstat[0].statistics[1].statistics[j].type == iControl.CommonStatisticType.STATISTIC_SERVER_SIDE_MAXIMUM_CONNECTIONS)
essageBox.Show(mbstat[0].statistics[1].statistics[j].type.ToString() + ":" + mbstat[0].statistics[1].statistics[j].value.high.ToString());
I have this error: Index was outside the bounds of the array. ... looks like it doesn't like STATISTIC_SERVER_SIDE_MAXIMUM_CONNECTIONS ?
Thanks for your help !
3 Replies
- Don_MacVittie_1Historic F5 AccountHi nmenant!
The return value is 64 bits long, so we return it as two 32 bit numbers. Looks like you're using C, here's a thread that discusses this topic for C and VB: http://devcentral.f5.com/Default.aspx?tabid=53&forumid=1&postid=15946&view=topic
For your other code snippet, no, the problem is cropping up because you don't have curly braces around the if statements - so the for is only working on the first one, not the second.
If you change the for statement to be for(...) {
and then close the curly-brace after the second if statement, you'll be good.
The reason you're getting that specific error is because the for runs, checking only the first if statement, and when the for loop is finished the value of j is mbstat[0].statistics[1].statistics.Length, which is indeed outside the bounds since the bounds of a C array are 0..Length-1
I do hope that makes sense and I didn't belabor the point.
Regards,
Don. - Nicolas_Menant
Employee
i'm ashamed for the curly brace issue -_-'
that's what's happening when looking for a while on the same statement of code ...
Thanks for all your answers !
Best regards,
N. - Don_MacVittie_1Historic F5 AccountYou're correct. I wonder if the Web GUI is showing idle persistent connections? Those would only die if they were up and something got sent over them.
What are you showing through iControl? The same number or not?
Don.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects