[asterisk-users] Asterisk 1.8 Manager Perl Script Problem

JR Richardson jmr.richardson at gmail.com
Mon Oct 3 17:01:35 CDT 2011


Hi All,

Trying to upgrade some call servers, in the lab making sure all my
applications work, ran into an issue with some manager perl scripts
that pull and reset database info, it seems the command and result
responses have changed but I'm not sure how to resolve.  My scripts
are using CPAN Asterisk::Manager; and are working fine on asterisk
1.2.32 but not on Asterisk 1.8.6.0.

Here is the abbreviated script where 1.2.32 is astman1 and 1.8.6.0 is astman2:


#!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
use Asterisk::Manager;

##setup manager connections##
my $astman1 = new Asterisk::Manager;
$astman1->user('username');
$astman1->secret('password');
$astman1->host('10.10.14.101');
$astman1->connect || die $astman1->error . "\n";

my $astman2 = new Asterisk::Manager;
$astman2->user('username');
$astman2->secret('password');
$astman2->host('10.10.14.102');
$astman2->connect || die $astman2->error . "\n";

##query databases for cnam count##
$astman1->sendcommand(Action => 'DBGet', Family => 'cnam', Key => 'count');
my @result1 = $astman1->sendcommand(Event => 'DBGetResponse');
my $cnamcount1 = "0$result1[7]";

$astman2->sendcommand(Action => 'DBGet', Family => 'cnam', Key => 'count');
my @result2 = $astman2->sendcommand(Event => 'DBGetResponse');
my $cnamcount2 = "0$result2[7]";

##total cnam count##
my $cnamtotal = ($cnamcount1+$cnamcount2);

##reset cnam count to 0##
$astman1->sendcommand(Action => 'DBPut', Family => 'cnam', Key =>
'count', Val => '0');
my @result101 = $astman1->sendcommand(Event => 'DBGetResponse');
my $cnamreset1 = $result101[1];

$astman2->sendcommand(Action => 'DBPut', Family => 'cnam', Key =>
'count', Val => '0');
my @result102 = $astman2->sendcommand(Event => 'DBGetResponse');
my $cnamreset2 = $result102[1];

##disconnect the manager connections##
$astman1->disconnect;
$astman2->disconnect;

print "Total CNAM Count for last month is $cnamtotal\n\n";
-----end script----


The response from the 1.8.6.0 server is "Response Success Message
Result will follow" but is seems the actual response is not pulled
into $result2.  The DBPut command works fine and I get a success
response.  I've searched through all the upgrade docs but nothing
mentions command syntax changes.

Any help is appreciated.

Thanks.
JR
-- 
JR Richardson
Engineering for the Masses



More information about the asterisk-users mailing list