Jump to content

Obtain Latency Information From Asterisk in PHP?


asterdeve

Recommended Posts

This is asterisk AMI output of sip peers, here I give you like this to make understand batter.

 

$org = Array ( [0] => Response: Follows [1] => Privilege: Command [2] => Name/username Host Dyn Forcerport ACL Port Status [3] => Test-Call 198.15.126.41 5060 OK (256 ms) );

 

& here we are getting IP address from a database of peers, its Codeigniter Code

 

$this->db->where('status',1);

$query=$this->db->get('simpro_originator'); 

$results=$query->result_array();

foreach($results as $row)

{

$data[$i]['id']=$row['id'];

$data[$i]['name']=$row['name'];

$data[$i]['pass']=$row['pass'];

$data[$i]['orig_ip']=$row['orig_ip'];

$data[$i]['call_limit']=$row['call_limit'];

$data[$i]['status']=$row['status'];

$data[$i]['created_on']=$row['created_on'];

foreach($org as $str)

 

& then here we are getting asterisk AMI output & match with database peers IP, if matched & IP has OK text then it will output in array "active":"OK" else "active":"NOTOK"

 

{

 

if(stripos($str,$row['orig_ip']))

{

if(stripos($str,'OK'))

{

$data[$i]['active']='OK';

}

else

$data[$i]['active']='NOTOK';

}

}

 

$i++;

}

 

print_r($data);

 

return data = {"":{"id":"1","name":"Test-Call","pass":"Google","orig_ip":"198.15.126.41","call_limit":"128","status":"1","created_on":"2018-01-14 08:04:44","active":"OK"}}

}

 

So when we get data from asterisk we are getting also getting Latency of that IP which is located nearby OK text within () xxx ms, So I want to get that value in my return data like below 

 

return data = {"":{"id":"1","name":"Test-Call","pass":"Google","orig_ip":"198.15.126.41","call_limit":"128","status":"1","created_on":"2018-01-14 08:04:44","active":"OK","latency":"256 ms"}}

 

 

I have tried my best to make you guys understand, Hope you will able to answer now, Thanks for your time.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.