Hello,
I wrote a Perl script to get the ActiveCall on the CallManager using AXL and XML::Simple. The goal is to supervise the CallManager and get all information like RTMT.
I first start with the active calls (I can also get CallsCompleted, CallsInProgress, etc) and hope to get all other the important information (FXO, MGCP gateway information, active port, etc).
I can get like three counters in a same request if I want, but I don't arrive to extract the result correctly. So I only do one counter per XML request to get the selected result.
I used XML::Simple because I had some trouble using SOAP::Lite with perfmon request. In my script, I do four requests:
1)Open the session (and get the session ID)
2)Add the counter
3)Collect the counter result
4)Close the session
It's working but I don't know if I¿m doing it correctly and I imagine there is a simple way to get this type of information.
If you have suggestion, ideas or correction, please let me know!
----------------------------------------------------------------------------------------------------------------------
#!c:/perl/bin/perl -w
use strict;
use LWP::UserAgent;
use XML::Simple;
# CallManager informations
my $cucm = "your callmanager ip address";
my $axlport = "8443";
my $axluser = "axl login";
my $axlpwd = "axl password";
# Globals
my $session = undef;
my $xml = undef;
my $soapEnv = undef;
my $req = undef;
my $res = undef;
######################## OPEN AND GET THE SESSIONHANDLE ########################
$soapEnv = <<AXL;
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.cisco.com/ast/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap

erfmonOpenSession soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</soapenv:Body>
</soapenv:Envelope>
AXL
# Create a request
$req = HTTP::Request->new(POST => "https://$cucm:$axlport/perfmonservice/services/PerfmonPort?wsdl");
$req->content_type('text/xml');
$req->header('Accept' => 'text/*');
$req->header('SOAPAction' => '"CUCM

B ver=6.1"');
$req->content($soapEnv);
$req->authorization_basic($axluser,$axlpwd);
# Pass request to the user agent and get a response back
$res = LWP::UserAgent->new->request($req);
# Check the outcome of the response and get the session ID
if ($res->{_rc} == 200) {
$xml = eval {XMLin($res->content,KeyAttr => "return")};
if($@){
$res=$@;
}else {
$res=$xml;
}
# Get the session ID
$session = $res->{'soapenv:Body'}->{'ns1

erfmonOpenSessionResponse'}->{'SessionHandle'}->{'content'};
}
else {
print $res->status_line, "\n";
}
################################## ADD COUNTER #################################
$soapEnv = <<AXL;
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1

erfmonAddCounter soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schemas.cisco.com/ast/soap/">
<SessionHandle xsi:type="ns1:SessionHandleType" xs:type="type:SessionHandleType" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">$session</SessionHandle>
<ArrayOfCounter soapenc:arrayType="ns1:CounterType[2]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<item xsi:type="ns1:CounterType">
<Name xsi:type="ns1:CounterNameType">\\\\$cucm\\Cisco CallManager\\CallsActive</Name>
</item>
</ArrayOfCounter>
</ns1

erfmonAddCounter>
</soapenv:Body>
</soapenv:Envelope>
AXL
# Create a request
$req = HTTP::Request->new(POST => "https://$cucm:$axlport/perfmonservice/services/PerfmonPort?wsdl");
$req->content_type('text/xml');
$req->header('Accept' => 'text/*');
$req->header('SOAPAction' => '"CUCM

B ver=6.1"');
$req->content($soapEnv);
$req->authorization_basic($axluser,$axlpwd);
# Pass request to the user agent and get a response back
$res = LWP::UserAgent->new->request($req);
# Check the outcome of the response
if ($res->{_rc} == 200){
$xml = eval {XMLin($res->content,KeyAttr => "")};
if($@){
$res=$@;
}else{
$res=$xml;
}
}
else {
print $res->status_line, "\n";
}
########################### GET THE CALL INFORMATION ###########################
$soapEnv = <<AXL;
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.cisco.com/ast/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap

erfmonCollectSessionData soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SessionHandle xsi:type="soap:SessionHandleType" xs:type="type:SessionHandleType" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">$session</SessionHandle>
</soap

erfmonCollectSessionData>
</soapenv:Body>
</soapenv:Envelope>
AXL
# Create a request
$req = HTTP::Request->new(POST => "https://$cucm:$axlport/perfmonservice/services/PerfmonPort?wsdl");
$req->content_type('text/xml');
$req->header('Accept' => 'text/*');
$req->header('SOAPAction' => '"CUCM

B ver=6.1"');
$req->content($soapEnv);
$req->authorization_basic($axluser,$axlpwd);
# Pass request to the user agent and get a response back
$res = LWP::UserAgent->new->request($req);
# Check the outcome of the response
if ($res->{_rc} == 200){
$xml = eval {XMLin($res->content,KeyAttr => "return")};
if($@){
$res=$@;
}else{
$res=$xml;
}
$res = $res->{'soapenv:Body'}->{'ns1

erfmonCollectSessionDataResponse'}->{'ArrayOfCounterInfo'}->{'item'}->{'Value'}->{'content'};
print "Active calls: " . $res;
}
else {
print $res->status_line, "\n";
}
############################## CLOSE THE SESSION ###############################
$soapEnv = <<AXL;
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.cisco.com/ast/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap

erfmonCloseSession soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SessionHandle xsi:type="soap:SessionHandleType" xs:type="type:SessionHandleType" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance">$session</SessionHandle>
</soap

erfmonCloseSession>
</soapenv:Body>
</soapenv:Envelope>
AXL
# Create a request
$req = HTTP::Request->new(POST => "https://$cucm:$axlport/perfmonservice/services/PerfmonPort?wsdl");
$req->content_type('text/xml');
$req->header('Accept' => 'text/*');
$req->header('SOAPAction' => '"CUCM

B ver=6.1"');
$req->content($soapEnv);
$req->authorization_basic($axluser,$axlpwd);
# Pass request to the user agent and get a response back
$res = LWP::UserAgent->new->request($req);
# Check the outcome of the response
if ($res->{_rc} == 200){
$xml = eval {XMLin($res->content,KeyAttr => "return")};
if($@){
$res=$@;
}else{
$res=$xml;
}
}
else {
print $res->status_line, "\n";
}