[HELP] "Status" vs. "core show channels"


I’m looking for some guidance from Asterisk old-timers regarding polling an Asterisk server on a regular basis (every second) for channel information.

Here is the requirement for this particular project. We have about a 100 users on our system and our line-of-business application is a very slow ASP.NET WebForms application with a myriad performance issues, so the point of this exercise is to try and get away from relying on the LOB application to do all the heavy lifting such as speaking to Asterisk directly. So, basically we’ve come down to the following idea and that is to build a Windows Service hosting a little socket server to which the LOB application can speak to get information for a specific channel. Inside the Windows Service a collection of ‘Call’ objects are maintained which is basically just digested results of “core show channels” or “Status” action wrapped nicely in a strongly-typed class for easy handling by the Windows Service itself and the LOB application calling data from it.

In terms of technology and libraries… The Windows Service is built with C# and I’m using the AsterNET library to handle the interchange between the Windows Service and Asterisk.

I guess that should be more than enough background to answer my question. So here goes, basically what I’m trying to establish is the best-practice around getting channel information from Asterisk. I’ve fiddled around with “core show channels” but I’m leaning towards the “Status” action implemented by AsterNET which already exposes the “Status” command nicely. I thought it would be nice to stick to something where I don’t need to reinvent the wheel e.g. consuming the raw data from Asterisk. Though, I’m not too scared to digest the raw data if “core show channels” is the better or more accepted way of doing this. Please give me some guidance around what the tenured/experienced community regard as the “best-practice” for this particular scenario?

Thank you in advance and thank you to the Asterisk/Digium team for all their awesome efforts with Asterisk.


Use AMI events and model the system state.

Although the system will probably cope, polling that fast is somewhat hostile.

Thanks for the reply david55.

Some follow-up questions to your response…

  1. If we do stick to a fixed interval polling strategy, is it advisable to increase that polling interval to something like every 3 or 5 seconds? Would that sort of polling strategy qualify as ‘safe’ ?

  2. What are the possible implications of polling all channels this frequently? Could this deteriorate the stability of our Asterisk server?

Thank you,

The process will involve taking locks. That increases the chances of finding locking bugs and may delay the processing of speech data. Your specific usage may turn out to be benign but I know that running queue show takes locks that can last long enough to cause real problems if the TCP channel to the management client stalls.

I can’t tell you what a safe interval would be, just that the design will not have been optimised for rapid fire use of such commands and such usage is unlikely to have been well tested.

I’m going to do a bit of fiddling with a local Asterisk VM to see how it responds with the constant interval polling. Based on my discoveries with that I’ll adapt the service to use a longer interval and see how that goes. Otherwise the design will need to be revised to rather query a specific channel on demand. After all, we’ve got full control over where and when we need to have the channel information available in the web front-end of our LOB application, which probably translates to something like 20 - 30%.

Thanks for the guidance and the information, it is much appreciated.