How do I configure Asterisk for TNG to work (AMI)

Moderators: Leon van Heerden, Luanda_Junzi, Belinda Frick, Lee Hendricks

How do I configure Asterisk for TNG to work (AMI)

Postby Belinda Frick » Mon Nov 15, 2010 8:50 am

TNG connects to Asterisk via the network to the Asterisk Manager Interface (AMI). The AMI normally runs on TCP port 5038 on the Asterisk machine.

    Step 1: Enable the Asterisk Manager Interface
    Step 2: Add a user for TNG
    Step 3: Enable CDR on Asterisk
    Step 4: Enable CDR via the AMI
    Step 5: Force Asterisk to reload the configuration
    Step 6: Configure TNG
    Step 7: Check that TNG has connected successfully

    Explanation of log entries

Steps:

  • Step 1: Enable the Asterisk Manager Interface

    We first ensure that the AMI is enabled.

    File /etc/asterisk/manager.conf
    Code: Select all
    [general]
    enabled = yes
    port = 5038
    bindaddr = 0.0.0.0

    You should not enable the AMI on a public IP address.
    If you do, people on the Internet will be able to connect to
    the AMI and may cause problems.

    Block this TCP port with iptables (or other firewall software).



  • Step 2: Add a user for TNG
    The default Asterisk has a manager_custom.conf file, which
    is included from /etc/asterisk/manager.conf. Usually, additional
    users are configured in this file.

    For example, if we want to use login "tng", password "test",
    and TNG will connect from IP 192.168.0.4, this would be the
    configuration:

    File /etc/asterisk/manager_custom.conf
    Code: Select all
    [tng]
    secret=tng
    deny=0.0.0.0/0.0.0.0
    permit=192.168.0.4/255.255.255.255
    read=system,command
    write=system,command



    Historically we used these settings, but it caused High CPU Usage.
    read=system,call,log,verbose,command,agent,user
    write=system,call,log,verbose,command,agent,user

    You can make the login and password anything you want,
    as long as TNG is configured to use the same login and password.



  • Step 3: Enable CDR on Asterisk
    File /etc/asterisk/cdr.conf
    Code: Select all
    [general]
    enabled=yes




  • Step 4: Enable CDR via the AMI

    File /etc/asterisk/cdr_manager.conf
    Code: Select all
    [general]
    enabled=yes


  • Step 5: Force Asterisk to reload the configuration

    Check whether the cdr_manager module is loaded...

    Code: Select all
    root@asterisk:/etc/asterisk# asterisk -rx "show modules like cdr_manager"
    Module                         Description                              Use Count
    cdr_manager.so                 Asterisk Call Manager CDR Backend        0
    1 modules loaded
    root@asterisk:/etc/asterisk#



    If you don't see the cdr_manager module or it says "0 modules loaded",
    you need to compile it into Asterisk. Please see the Asterisk documentation.



    If the module is there, configure your TNG with the login and password
    you set in Step 2.

    Force Asterisk to reload the configuration:

    Code: Select all
    root@asterisk:/etc/asterisk# asterisk -rx "reload"


    For good measure, you can also run the following commands:

    Code: Select all
    root@asterisk:/etc/asterisk# asterisk -rx "reload manager"
    root@asterisk:/etc/asterisk# asterisk -rx "reload cdr"
    root@asterisk:/etc/asterisk# asterisk -rx "reload cdr_manager"


    which explicitly specify which modules to reload.


    TNG should now be able to connect to Asterisk.


  • Step 6: Configure TNG
    Make sure that TNG is installed.

    Login on TNG using a web browser, and click on the
    "General Settings" icon (a gear and spanner) on the
    main page.

    TNG will prompt for a "technical" password. Enter the
    technical password and search on the screen for the
    Asterisk Interface configuration.

    Here you enter the IP address of the Asterisk server,
    AMI port (default 5038), Login and password that you
    configured in Step 2.

    Click any of the "Apply Changes" buttons to save.



  • Step 7: Check that TNG has connected successfully
    Back on Asterisk, at the command-line, check that TNG has connected:

    Code: Select all
    root@asterisk:/etc/asterisk# asterisk -rx "show manager connected"
      Username         IP Address
      tng              192.168.0.5


    If you don't see this, check the TNG log file for
    error messages.



  • Explanation of log entries

    Look for these messages to check settings
    Code: Select all
    Setting AMI Host :192.168.0.4
    Setting AMI Port :5038                 
    Setting AMI Login Name :tng     


    • Error message
      Code: Select all
      AMI Exception:ConnectToAsterisk: Socket Error # 10061[13][10]Connection refused.


      Explanation: Failed to connect to AMI
      Reason: Incorrect IP or port, or a firewall

      tngforAsterisk-notconnected.PNG

    • Error messages
      Code: Select all
      AMI Exception:Disconnected.
      AMI Exception:Send: Action: Login[13][10]Username: tng[13][10]Secret: test[13][10] - Socket Error # 10057[13][10]Socket is not connected.
      AMI connected to port 5038 on 192.168.0.4


      Explanation: Successful connect, connection was closed almost immediately
      Reason: Incorrect login or password


    SAMPLE FORMAT

    Code: Select all
    "0000000000","0000000000","s"  ,"all-hangup","Zap/1-1","SIP/5006-091feb88","Dial","SIP/5006|60","2007-11-09 11:24:32","2007-11-09 11:24:32","2007-11-09 11:24:35","3","3","ANSWERED","DOCUMENTATION","","1194600272.3176","2021"

Please find a detailed TNG installation and user’s guide in the help folder on your TNG CD.
You do not have the required permissions to view the files attached to this post.
Belinda Frick
 
Posts: 3808
Joined: Fri Nov 12, 2010 4:25 pm

Return to Support Archive's (TNG)

Who is online

Users browsing this forum: No registered users and 1 guest