jwestbrook / datadog-asteriskpbx

DataDog Agent plugin for the Open Source Asterisk PBX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List Index out of Range

rmammina opened this issue · comments

commented

Finally got the asteriskpbx to integrate, but seeing a new issue coming up.

Ubuntu 14.04, Asterisk 1.8, Datadog Agent 6.

screen shot 2019-02-06 at 10 17 13 pm

Hi @rmammina
it'll happen for all unloaded/unnecessary modules.
You can quickly fix it in this case by adding a response verification regexp for "No such command":

#IAX2 Peers

iax_result = mgr.command('iax2 show peers')
iax_results = iax_result.data.split('\n')
iax_total_line = iax_results[len(iax_results)-3]

if not re.findall(r'No such command',iax_total_line)[0]:

    iax_peers_total = re.findall(r'([0-9]+) iax2 peers',iax_total_line)[0]
    iax_peers_online = re.findall(r'\[([0-9]+) online',iax_total_line)[0]
    iax_peers_offline = re.findall(r'([0-9]+) offline',iax_total_line)[0]
    iax_peers_unmonitored = re.findall(r'([0-9]+) unmonitored',iax_total_line)[0]

    print('Total IAX2 Peers')
    print(iax_peers_total)
    print('IAX2 Peers Online')
    print(iax_peers_online)
    print('IAX2 Peers Offline')
    print(iax_peers_offline)
    print('IAX2 Peers Unmonitored')
    print(iax_peers_unmonitored)
I'll try to improve it since i'll use it for production monitoring too. Hope that helps you.

That's a good fix.. I'll try to put it on all the requests to the PBX through the AMI. Thanks a lot..

Fixed with #21