Good Way To Query Data From Asterisk Realtime With Asterisk Manager API

Home » Asterisk Users » Good Way To Query Data From Asterisk Realtime With Asterisk Manager API
Asterisk Users 6 Comments

Hello.

I am trying to use Asterisk Manager API query data from realtime. From Asterisk CLI, we could use realtime load
query realtime it would have response like

Column Name Column Value
——————– ——————–
id 1
mykey content
myvalue value

I am wondering how I could make this type of query from Manager API.

Thanks for your time in advance.

6 thoughts on - Good Way To Query Data From Asterisk Realtime With Asterisk Manager API

  • There might be a specific command to do it, but you can do almost any CLI
    command using “command” function.

    —–Original Message—

  • Is there a specific reason you want to access the realtime data through the Manager API and not directly from the database itself? It seems like the Manager API would add an extra layer to whatever you’re trying to accomplish.

  • Do you think it is a good way to use Manager API “command action” to implement this feature?

  • For some reason, we don’t want directly access database. more over, it avoid to develop different database connection code, and leave the database connection part with Asterisk

  • 31 aug 2012 kl. 16:58 skrev Shitian Long :

    No. The command action should be avoided since the output from the CLI commands is not made for parsing by applications and may change too. Sometimes we cut of informaiton to fit into a terminal window. If you use manager actions instead, you will always get the full data in a format you can parse. If you have to use the command action you have found a place where a manager action is missing and we developers would like to know that and fix it 🙂

    For realtime, there’s a dialplan function REALTIME() that you can use with the manager actions that change or read channel variables. That’s the best way, since we lack manager realtime commands.

    One reason for not going directly to the database API is that when building 3rd party apps, we don’t know what database you are using and can benefit from the ARA interface to databases, exactly like Asterisk. It’s not as effecient as going directly when you can, but sometimes you just don’t know what’s behind ARA and thanks to ARA you don’t have to. 🙂

    /Olle

    * The new Edvina SIP Masterclass – Stockholm, Sweden Oct and Miami, FL, Dec 2012
    http://edvina.net/training/new-sip-masterclass/

  • Thanks for everyone’s message, Finally, I figure out how to use AMI fetch data from realtime.

    After log in AMI. First step, a setVar action should be sent
    (for example, in this case, I am interested in the content of realtime family = test_family, key = mykey,)

    setVar action should look like

    Action: Setvar Variable: REALTIME(test_family, key, mykey)

    After that, I should have a success response like

    Response: Success Message: Variable Set

    Afterward. I could use getVar action to fetch the result

    Action: Getvar Variable: REALTIME(test_family, key, mykey)

    Finally, query result will be in the response.

    From this practice, it seems, AMI getVar and setVar action have more function than I through.

    Thanks for every one’s help.