Forum Discussion

lisanwan_54895's avatar
lisanwan_54895
Icon for Nimbostratus rankNimbostratus
Jul 21, 2010

Problem with Statistics

Hi,

 

 

I want to retrieve the information of the performance below Overview in the web, such as Memory Used, System CPU Usage, Active Connections, New Connections, etc..

 

I'm using iControl API in C application. My BIG-IP's version is "10.1.0.3341.1084".

 

I want to use System/Statistics->get_performance_graph_list and get_performance_table_list to retrieve the information, but I always get the wrong message "Something is wrong in XML document(11, 2)". I don't know why.

 

Is the way I had found right? If I did it in a wrong way, how can I retrieve the information of the performance? Thank you!

 

Following is the class I wrote several days before.

 

 

 

namespace Statistics{

 

using System.Diagnostics;

 

using System.Xml.Serialization;

 

using System;

 

using System.Web.Services.Protocols;

 

using System.ComponentModel;

 

using System.Web.Services;

 

 

///

 

[System.Diagnostics.DebuggerStepThroughAttribute()]

 

[System.ComponentModel.DesignerCategoryAttribute("code")]

 

[System.Web.Services.WebServiceBindingAttribute(Name="System.StatisticsBinding", Namespace="urn:iControl")]

 

[System.Xml.Serialization.SoapIncludeAttribute(typeof(PerformanceGraph))]

 

[System.Xml.Serialization.SoapIncludeAttribute(typeof(PerformanceTable))]

 

public class SystemStatistics : System.Web.Services.Protocols.SoapHttpClientProtocol

 

{

 

 

///

 

public SystemStatistics() {

 

this.Url = "";

 

}

 

 

///

 

[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:iControl:System/Statistics", RequestNamespace="urn:iControl:System/Statistics", ResponseNamespace="urn:iControl:System/Statistics")]

 

[return: System.Xml.Serialization.SoapElementAttribute("return")]

 

public PerformanceGraph[] get_performance_graph_list() {

 

object[] results = this.Invoke("get_performance_graph_list", new object[0]);

 

return ((PerformanceGraph[])(results[0]));

 

}

 

 

///

 

public System.IAsyncResult Beginget_performance_graph_list(System.AsyncCallback callback, object asyncState) {

 

return this.BeginInvoke("get_performance_graph_list", new object[0], callback, asyncState);

 

}

 

 

///

 

public PerformanceGraph[] Endget_performance_graph_list(System.IAsyncResult asyncResult) {

 

object[] results = this.EndInvoke(asyncResult);

 

return ((PerformanceGraph[])(results[0]));

 

}

 

 

///

 

[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:iControl:System/Statistics", RequestNamespace = "urn:iControl:System/Statistics", ResponseNamespace = "urn:iControl:System/Statistics")]

 

[return: System.Xml.Serialization.SoapElementAttribute("return")]

 

public PerformanceTable[] get_performance_table_list()

 

{

 

object[] results = this.Invoke("get_performance_table_list", new object[0]);

 

return ((PerformanceTable[])(results[0]));

 

}

 

///

 

public System.IAsyncResult Beginget_performance_table_list(System.AsyncCallback callback, object asyncState)

 

{

 

return this.BeginInvoke("get_performance_table_list", new object[0], callback, asyncState);

 

}

 

///

 

public PerformanceTable[] Endget_performance_table_list(System.IAsyncResult asyncResult)

 

{

 

object[] results = this.EndInvoke(asyncResult);

 

return ((PerformanceTable[])(results[0]));

 

}

 

 

///

 

[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:iControl:System/Statistics", RequestNamespace = "urn:iControl:System/Statistics", ResponseNamespace = "urn:iControl:System/Statistics")]

 

[return: System.Xml.Serialization.SoapElementAttribute("return")]

 

public string[] get_list_of_hosts()

 

{

 

object[] results = this.Invoke("get_list_of_hosts", new object[0]);

 

return ((string[])(results[0]));

 

}

 

///

 

public System.IAsyncResult Beginget_list_of_hosts(System.AsyncCallback callback, object asyncState)

 

{

 

return this.BeginInvoke("get_list_of_hosts", new object[0], callback, asyncState);

 

}

 

///

 

public string[] Endget_list_of_hosts(System.IAsyncResult asyncResult)

 

{

 

object[] results = this.EndInvoke(asyncResult);

 

return ((string[])(results[0]));

 

}

 

 

///

 

[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:iControl:System/Statistics", RequestNamespace = "urn:iControl:System/Statistics", ResponseNamespace = "urn:iControl:System/Statistics")]

 

[return: System.Xml.Serialization.SoapElementAttribute("return")]

 

public string get_version()

 

{

 

object[] results = this.Invoke("get_version", new object[0]);

 

return ((string)(results[0]));

 

}

 

///

 

public System.IAsyncResult Beginget_version(System.AsyncCallback callback, object asyncState)

 

{

 

return this.BeginInvoke("get_version", new object[0], callback, asyncState);

 

}

 

///

 

public string Endget_version(System.IAsyncResult asyncResult)

 

{

 

object[] results = this.EndInvoke(asyncResult);

 

return ((string)(results[0]));

 

}

 

}

 

public class PerformanceGraph

 

{

 

public string graph_name; //The key or name of the graph

 

public string graph_title; //The title of the graph as appeared in the GUI's Performance Graph

 

public string graph_description; //The text description of this graph

 

};

 

public class PerformanceTable

 

{

 

public string table_name; //The key or name of the table.

 

public string table_description; //String The text description of this table.

 

};

 

}

 

6 Replies

  •  

    I suggest that you download the iControl SDK from DevCentral (unless you have already done so) and analyze the C sample for working with Virtual Server Statistics (System Statistics will be similar)

     

     

    Here is the path to the sample in iControl SDK you need to review to see how to work with iControl and statistics in C:

     

     

    \sdk\samples\soap\c\microsoft\LocalLB\VSStats\VSStatsMain.cs

     

     

    Sam
  • Did you compile the WSDL yourself and incorporate it into your application? If so, I'd recommend going with the iControl Assembly. Just plug the .Net assembly into your project and you don't have to muck around with all the lower level bindings. You can find that download in the iControl Assembly Labs project under the Download menu.

     

     

    With that being said, I don't see anywhere in your class where you actually make the call. The "error in xml document" usually implies that the SOAP response is not well formed and I'm not sure of a case where that could happen unless there was an exception on the server and in that case you'd get a 500 error back.

     

     

    Pass along the code you are using to call the methods and I'll try to reproduce your issue and/or provide you some sample code.

     

     

    If it helps, I wrote a tech tip a while back on the performance graph interfaces and some sample code with PowerShell. The syntax is somewhat close to C so that may help you as well.

     

     

    http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/194/iControl-101--11--Performance-Graphs.aspx

     

     

    -Joe

     

  • Posted By Joe on 07/21/2010 12:01 PM

     

    Did you compile the WSDL yourself and incorporate it into your application? If so, I'd recommend going with the iControl Assembly. Just plug the .Net assembly into your project and you don't have to muck around with all the lower level bindings. You can find that download in the iControl Assembly Labs project under the Download menu.

     

     

    With that being said, I don't see anywhere in your class where you actually make the call. The "error in xml document" usually implies that the SOAP response is not well formed and I'm not sure of a case where that could happen unless there was an exception on the server and in that case you'd get a 500 error back.

     

     

    Pass along the code you are using to call the methods and I'll try to reproduce your issue and/or provide you some sample code.

     

     

    If it helps, I wrote a tech tip a while back on the performance graph interfaces and some sample code with PowerShell. The syntax is somewhat close to C so that may help you as well.

     

     

    http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/194/iControl-101--11--Performance-Graphs.aspx

     

     

    -Joe

     

     

     

    Thank you, Joe

     

    I still don't know what do you mean by "compile the WSDL yourself and incorporate it into your application" and "Just plug the .Net assembly into your project ".

     

    As the samples in icontrol sdk don't contain the statistics part, so I did it as the samples(such as "\sdk\samples\soap\c\microsoft\System\SystemInfo") do.

     

    Following is the class(ClassSystemStatistics ) to call the interface defined in the class SystemStatistics.

     

    In class ClassSystemStatistics, there are four interfaces. "GetPerformanceGraphList" and "GetPerformanceTableList" always have a run-time error, while the other two interfaces don't have.

     

     

    using System;

     

    using System.Collections.Generic;

     

    using System.Text;

     

    using Statistics;

     

    namespace BackOfficeF5

     

    {

     

    class ClassSystemStatistics : System.Net.ICertificatePolicy

     

    {

     

    private System.Net.NetworkCredential creds = new System.Net.NetworkCredential();

     

    private string m_strHostName = "";

     

    private string m_strUserName = "";

     

    private string m_strPassword = "";

     

    private SystemStatistics mySystemStatistics = new SystemStatistics();

     

     

    public ClassSystemStatistics(string sHostName, string sUserName, string sPassword)

     

    {

     

    this.m_strHostName = sHostName;

     

    this.m_strUserName = sUserName;

     

    this.m_strPassword = sPassword;

     

    }

     

     

    public PerformanceGraph[] GetPerformanceGraphList()

     

    {

     

    System.Net.ServicePointManager.CertificatePolicy = this;

     

    mySystemStatistics.Credentials = creds;

     

    mySystemStatistics.Url = "https://" + m_strHostName + "/iControl/iControlPortal.cgi";

     

    creds.UserName = m_strUserName;

     

    creds.Password = m_strPassword;

     

    mySystemStatistics.PreAuthenticate = true;

     

    try

     

    {

     

    PerformanceGraph[] myPerformanceGraph = mySystemStatistics.get_performance_graph_list();

     

    return myPerformanceGraph;

     

    }

     

    catch (Exception e)

     

    {

     

    string str = e.Message;

     

    return null;

     

    }

     

    }

     

     

    public PerformanceTable[] GetPerformanceTableList()

     

    {

     

    System.Net.ServicePointManager.CertificatePolicy = this;

     

    mySystemStatistics.Credentials = creds;

     

    mySystemStatistics.Url = "https://" + m_strHostName + "/iControl/iControlPortal.cgi";

     

    creds.UserName = m_strUserName;

     

    creds.Password = m_strPassword;

     

    mySystemStatistics.PreAuthenticate = true;

     

    try

     

    {

     

    PerformanceTable[] myPerformanceTable = mySystemStatistics.get_performance_table_list();

     

    return myPerformanceTable;

     

    }

     

    catch (Exception e)

     

    {

     

    string str = e.Message;

     

    return null;

     

    }

     

    }

     

     

    public string GetVersion()

     

    {

     

    System.Net.ServicePointManager.CertificatePolicy = this;

     

    mySystemStatistics.Credentials = creds;

     

    mySystemStatistics.Url = "https://" + m_strHostName + "/iControl/iControlPortal.cgi";

     

    creds.UserName = m_strUserName;

     

    creds.Password = m_strPassword;

     

    mySystemStatistics.PreAuthenticate = true;

     

    try

     

    {

     

    string strVersion = mySystemStatistics.get_version();

     

    return strVersion;

     

    }

     

    catch (Exception e)

     

    {

     

    string str = e.Message;

     

    return null;

     

    }

     

    }

     

     

    public string[] GetListOfHosts()

     

    {

     

    System.Net.ServicePointManager.CertificatePolicy = this;

     

    mySystemStatistics.Credentials = creds;

     

    mySystemStatistics.Url = "https://" + m_strHostName + "/iControl/iControlPortal.cgi";

     

    creds.UserName = m_strUserName;

     

    creds.Password = m_strPassword;

     

    mySystemStatistics.PreAuthenticate = true;

     

    try

     

    {

     

    string[] myHosts = mySystemStatistics.get_list_of_hosts();

     

    return myHosts;

     

    }

     

    catch (Exception e)

     

    {

     

    string str = e.Message;

     

    return null;

     

    }

     

    }

     

     

    region ICertificatePolicy Members

     

    public bool CheckValidationResult(System.Net.ServicePoint srvPoint, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Net.WebRequest request, int certificateProblem)

     

    {

     

    return true;

     

    }

     

    endregion

     

    }

     

    }
  • Thanks to everyone who had read my topic.

     

    The interface I used is right, but I made a stupid mistake while I made the call.

     

    Look at the class PerformanceGraph in namespace Statistics. I should have defined the class as following,

     

     

    [System.Xml.Serialization.SoapTypeAttribute("System.Statistics.PerformanceGraph", "urn:iControl")] //I missed this declaration

     

    public class PerformanceGraph

     

    {

     

    public string graph_name; //The key or name of the graph

     

    public string graph_title; //The title of the graph as appeared in the GUI's Performance Graph

     

    public string graph_description; //The text description of this graph

     

    };
  • You still shouldn't have to be defining the classes yourself. The SDK is a bit out of date with regards to the .Net samples. For future development, we have provided a .Net assembly with all the iControl interfaces and objects bundled up for you. Go to the Download.Labs page and select the iControl Assembly. By clicking on the "Discussions and Downloads" link you can get the iControl Assembly for .Net. In your VS.Net project, just select "Add Reference" and point it to the downloaded iControl.dll and you can access all the iControl interfaces and methods from a newly instantiated iControl.Interfaces object. The code looks something like this

     

     

    iControl.Interfaces interfaces = new iControl.Interfaces();
    interfaces.initialize("bigip_addr", "username", "password");
    string [] vip_list = interfaces.LocalLBVirtualServer.get_list();

     

     

    This will help avoid a lot of issues in the future.

     

     

    -Joe

     

  • Thank you, Joe

     

    I tried to download the iControl Assembly, but failed as the network didn't help.

     

    Please transfer the iControl Assembly for .Net to my email, thanks a lot!

     

    My email is "lisanbinforever@gmail.com".