cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
761
Views
0
Helpful
0
Comments
cdnadmin
Level 11
Level 11
This document was generated from CDN thread

Created by: Leonard LECOUEY on 26-04-2010 09:17:57 AM
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>
      <soaperfmonOpenSession 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' => '"CUCMB 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'}->{'ns1erfmonOpenSessionResponse'}->{'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>
      <ns1erfmonAddCounter 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>
      </ns1erfmonAddCounter>
   </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' => '"CUCMB 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>
      <soaperfmonCollectSessionData 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>
      </soaperfmonCollectSessionData>
   </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' => '"CUCMB 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'}->{'ns1erfmonCollectSessionDataResponse'}->{'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>
      <soaperfmonCloseSession 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>
      </soaperfmonCloseSession>
   </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' => '"CUCMB 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";
}

Subject: RE: Perl : CallManager monitoring script
Replied by: Indrajit Chakrabarty on 24-05-2010 01:44:50 AM
Does anyone have a C#/.NET sample of this script?

Subject: RE: Perl : CallManager monitoring script
Replied by: Chester Rieman on 01-06-2012 08:55:19 AM
I'm trying this out but getting:

500 Internal Server Error
Use of uninitialized value in concatenation (.) or string at test8.pl line 60.

Any ideas whats incorrect?

TIA
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links