IBM Support

Obtain monitoring data through the Agent Service Interface

Technical Blog Post


Abstract

Obtain monitoring data through the Agent Service Interface

Body

Recently we received a request from a customer that wanted to collect monitoring data using the Agent Service Interface, but he had some doubts on how to achieve this.

Here's how to do it:

You should be able to access the agent service interface, unless you have disabled the internal web server (port 1920 or 3660) of the agent.

Let's assume you have a Linux OS agent called linuxagent:LZ, then you should redirect your browser to http://linuxagent:1920, to access the service interface.

Then you then get to:

Service Point: linuxagent_lz

, and click on the corresponding link.

 

Next, select 'Queries' in the following window:

 

 

There you will have the opportunity to query the available attribute groups.

 

The same can be achieved in the 'Service Interface Request', which allows you to make XML requests.

An example would be:

<REPORT>
<SQLTABLE>
<TABLENAME>KLZCPU</TABLENAME>
 <OUTPUT>
 <COLUMN>TIMESTAMP</COLUMN>
 <COLUMN>CPUID</COLUMN>
 <COLUMN>USRCPU</COLUMN>
 <COLUMN>SYSCPU</COLUMN>
 <COLUMN>IDLECPU</COLUMN>
 <COLUMN>BUSYCPU</COLUMN>
 </OUTPUT>
</SQLTABLE>
</REPORT>

 

This will give an output like this:

image

 

To make the same request through a script, you can use the following procedure:

1. Create a file with these contents:

<REPORT>
<SQLTABLE>
<TABLENAME>KLZCPU</TABLENAME>
<OUTPUT>
<COLUMN>TIMESTAMP</COLUMN>
<COLUMN>CPUID</COLUMN>
<COLUMN>USRCPU</COLUMN>
<COLUMN>SYSCPU</COLUMN>
<COLUMN>IDLECPU</COLUMN>
<COLUMN>BUSYCPU</COLUMN>
</OUTPUT>
</SQLTABLE>
</REPORT>

Let's call the file metrics.asi

 

2. Execute the report (html get) using the "curl" or "wget" Linux command. See sample below.

curl -H "Content-Type: text/xml; charset=utf-8" -d@metrics.asi http://user:password@linuxagent:1920/linuxagent_lz/linuxagent_lz

 

You will get a similar result:

<REPORTDATA><SQLTABLE><TABLENAME>KLZCPU</TABLENAME><ROWCOUNT>3</ROWCOUNT><ROW><COLUMN><NAME>TIMESTAMP</NAME><DATA><![CDATA[1190104143731000]]></DATA></COLUMN><COLUMN><NAME>CPUID</NAME><DATA>-1</DATA></COLUMN><COLUMN><NAME>USRCPU</NAME><DATA>70</DATA></COLUMN><COLUMN><NAME>SYSCPU</NAME><DATA>92</DATA></COLUMN><COLUMN><NAME>IDLECPU</NAME><DATA>9833</DATA></COLUMN><COLUMN><NAME>BUSYCPU</NAME><DATA>167</DATA></COLUMN></ROW><ROW><COLUMN><NAME>TIMESTAMP</NAME><DATA><![CDATA[1190104143731000]]></DATA></COLUMN><COLUMN><NAME>CPUID</NAME><DATA>0</DATA></COLUMN><COLUMN><NAME>USRCPU</NAME><DATA>67</DATA></COLUMN><COLUMN><NAME>SYSCPU</NAME><DATA>87</DATA></COLUMN><COLUMN><NAME>IDLECPU</NAME><DATA>9846</DATA></COLUMN><COLUMN><NAME>BUSYCPU</NAME><DATA>154</DATA></COLUMN></ROW><ROW><COLUMN><NAME>TIMESTAMP</NAME><DATA><![CDATA[1190104143731000]]></DATA></COLUMN><COLUMN><NAME>CPUID</NAME><DATA>1</DATA></COLUMN><COLUMN><NAME>USRCPU</NAME><DATA>74</DATA></COLUMN><COLUMN><NAME>SYSCPU</NAME><DATA>97</DATA></COLUMN><COLUMN><NAME>IDLECPU</NAME><DATA>9816</DATA></COLUMN><COLUMN><NAME>BUSYCPU</NAME><DATA>184</DATA></COLUMN></ROW></SQLTABLE></REPORTDATA>

 

If you want to extract data using a script, but the agent HTTP server (port 1920 or 3660) has been disabled, you could configure historical data collection for the desired attribute groups, and then extract the monitoring data from the warehouse or the short-term history files on the agent. In order to extract from the latter, you can use the krarloff utility:
/support/pages/node/1083135

You can then embed the krarloff utility in a script, and have it extract the data from the short-term history files.

 

I hope it is useful!

[{"Business Unit":{"code":"BU004","label":"Hybrid Cloud"},"Product":{"code":"","label":""},"Component":"","Platform":[{"code":"","label":""}],"Version":"","Edition":""}]

UID

ibm11084263