asterdeve Posted April 5, 2018 Share Posted April 5, 2018 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 https://forums.phpfreaks.com/topic/307057-obtain-latency-information-from-asterisk-in-php/ Share on other sites More sharing options...
Barand Posted April 5, 2018 Share Posted April 5, 2018 As this is a repost of an earlier topic of yours and still doesn't address the reply you received I am closing this thread. Link to comment https://forums.phpfreaks.com/topic/307057-obtain-latency-information-from-asterisk-in-php/#findComment-1557669 Share on other sites More sharing options...
Recommended Posts