WARNING: this is an automatic post retrieved from the Asterisk-Users Mailing List, not an authored post
Mailing-list Collector
October 03, 2011
Asterisk Users
Tags: asterisk, COUNT, Key, query databases, result, result2, script problem, secret password
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 $cnamtotalnn”;