Page 1 of 1

AST_update_AMI2 Code Error ?

PostPosted: Thu Jan 11, 2024 4:19 am
by nextdial
Hi Guys,
In AST_update_AMI2.pl how it can be possible

Line 747
if ( $channel_ref->{'Channel'} =~ /^Local/ )
{
$cid_chan_hash{"$call_id"}->{'channel'} = $channel_ref->{'Channel'};
$cid_chan_hash{"$call_id"}->{'uniqueid'} = $channel_ref->{'Uniqueid'};
$cid_chan_hash{"$call_id"}->{'linkedid'} = $channel_ref->{'Linkedid'};
$cid_chan_hash{"$call_id"}->{'calleridname'} = $channel_ref->{'CallerIDName'};
$cid_chan_hash{"$call_id"}->{'connectedlinename'} = $channel_ref->{'ConnectedLineName'};
}
else
{
$cid_chan_hash{"$call_id"}->{'dest_channel'} = $channel_ref->{'Channel'};
$cid_chan_hash{"$call_id"}->{'dest_uniqueid'} = $channel_ref->{'Uniqueid'};
$cid_chan_hash{"$call_id"}->{'linkedid'} = $channel_ref->{'Linkedid'};
$cid_chan_hash{"$call_id"}->{'calleridname'} = $channel_ref->{'CallerIDName'};
$cid_chan_hash{"$call_id"}->{'connectedlinename'} = $channel_ref->{'ConnectedLineName'};
}

Line 993

( $cid_chan_hash{"$call_id"}->{'channel'} ne "" ) && ( $cid_chan_hash{"$call_id"}->{'dest_channel'} ne "" ) )

How $cid_chan_hash{"$call_id"}->{'channel'} AND $cid_chan_hash{"$call_id"}->{'dest_channel'} can be both not equal "" ?

we populate $cid_chan_hash{"$call_id"}->{'channel'} if /^Local/ AND $cid_chan_hash{"$call_id"}->{'dest_channel'} IF NOT /^Local/

Re: AST_update_AMI2 Code Error ?

PostPosted: Fri Jan 12, 2024 9:01 am
by mcargile
I will have to dig into the code as I wrote this several years ago. There are two things to keep in mind though.

1. The AST_update_AMI2.pl script was a reimplementation of Matt's original AST_update.pl script. For the most part I kept the same logic as Matt's code if it did not break anything. Matt's code dates back to before Asterisk was even properly released. Originally it was only available via repository checkouts and was constantly being changed by the developers. He put code in there that dealt with weird situations that would pop up. It is quite possible that this is some of that code.

2. Asterisk is notorious for giving bad data. Even after it became stable and was released, under high load it will still give garbage results. Never assume that you got a valid channel data. Even in my testing on much newer versions I have run across situations where the data does not make sense. It is quite possible that in my testing on an overloaded Asterisk server that I got results back from Asterisk with a valid uniqueid but no channels.