Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

Perl example client for CM monitoring SOAP RPC API

The following is a perl script to call the retrieveTrafficStats call on the central-manager with ip and using the userid admin password default for the WAE called test-wae for the time period of 12:00 until 14:00 UTC on September 27 2010 for the outgoing optimized traffic per hour.

It is just a simple example client for demonstration purposes, if you break something while using this you get to keep both pieces.


use LWP::UserAgent;

# this is the RPC call:
$xml_file = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Header xmlns:wsse="">
<wsse:Security SOAP-ENC:root="1">
<wsse:Username xsi:type="xsd:string">admin</wsse:Username>
<wsse:Password xsi:type="xsd:string">default</wsse:Password>
<ns1:retrieveTrafficStats xmlns:ns1="" SOAP-ENC:root="1">
<startTime xsi:type="xsd:string">2010-09-27T12:00:00</startTime>
<endTime xsi:type="xsd:string">2010-09-27T14:00:00</endTime>
<frequency xsi:type="xsd:string">lasthour</frequency>
<timezone xsi:type="xsd:string">utc</timezone>

my $server      =  '';
my $port        =  '8443';
my $RPCPath  =  '/ws/TrafficStats';

my $uri = 'https://' . $server . ':' . $port . $RPCPath;

my $ua = LWP::UserAgent->new;
# we need to authenticate the https connection:
$ua->credentials( "", "TrafficStats", "admin", "default" );

my $header = HTTP::Headers->new;
$header->header('SOAPAction' => '"retrieveTrafficStats"');
# this is to define what SOAP RPC call we are making
my $request = HTTP::Request->new("POST",$uri,$header );

my $response = $ua->request($request);

print $response->as_string;
print "\n";

This produces output like:

we got back:
HTTP/1.1 200 OK
Connection: close
Date: Tue, 28 Sep 2010 10:53:42 GMT
Server: Apache/1.3.41 (Unix) mod_ssl/2.8.31 OpenSSL/0.9.8g mod_jk/1.2.15 mod_auth_pam/1.0a
Content-Type: text/xml;charset=UTF-8
Client-Date: Tue, 28 Sep 2010 10:53:43 GMT
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/ST=California/L=San Jose/OU=CNBU/O=Cisco Systems, Inc/CN=CDN-WAVE-274-1
Client-SSL-Cert-Subject: /C=US/ST=California/L=San Jose/OU=CNBU/O=Cisco Systems, Inc/CN=CDN-WAVE-274-1
Client-SSL-Cipher: DHE-RSA-AES256-SHA
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xm....

Version history
Revision #:
1 of 1
Last update:
‎09-28-2010 03:49 AM
Updated by:
Cisco Employee

Great doc Peter!