Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Dialplan debugging

Old News Asterisk Recommended Links Extensions Reference Dialplan debugging
Inspecting Channels Inspecting the Dial-Plan Editing Dial-Plan in CLI Asterisk variables Simple menu programming Queue
Users, Peers and Friends Dialplan Programming Constructs Troubleshooting Festival Humor Etc

Here's some general advice on debugging complex Asterisk dialplans.

There are several more specific debugging tricks:

Use pattern  _.  temporarily if nothing else will work

Turn on debugging and watch the CLI while a call is passing through that context, so you can see what the actual extension is. Then rewrite the context to either use that extension directly in place of _. or use a pattern that will catch that extension. As a last resort, if you don't need to preserve the extension, you may be able to use two contexts to get rid of the ambiguity (which still has some risk, but limits the time of exposure):

   [unknownextension]
   exten => _.,1,Goto(itmatches,s,1)
   .....
   [itmatches]
   exten => s,1,NoOp(Now using s extension)
   .....

Do not leave a pattern of _. in the dialplan after the debugging as this will match everything including Asterisk special extensions like i, t, h, etc.  If really necessary, use something like _X. or which will not match __special__ extensions..

Connect to Asterisk using asterisk -rvvvvvvv

In this case asterisk provides trace of commands which can help you in debugging, especially if you add NoOp() in critical places.

Use NoOp() to view variables

It works as a printf if your verbose level is set to 3 or higher.

For example:

exten => s,1,Answer
exten => s,2,NoOp(${CALLERID})

This works with any variable, so NoOp(${any_var_name}) will print the value of the named variable on the console when that step in the extension is reached.

Note that this is a side effect of the verbosity level being 3 or higher, not a function of the application itself. The application NoOp does nothing.

If you would like output at other verbosity levels (for example, 0), you are encouraged to use the Verbose command.

Test the order of extensions and patterns using dialplan show

Adapted from Practical Asterisk 1.4 (unstable)

An example dialplan looks like this:

[general]

[my-phones]
exten => 23,1,Answer()
exten => 23,2,Playback(hello-world)
exten => 23,3,Hangup()

We can call dialplan show from the CLI (invoked with asterisk -r if Asterisk is already running) to verify that our dialplan has been loaded:

*CLI> dialplan show
[ Context 'default' created by 'pbx_config' ]

[ Context 'my-phones' created by 'pbx_config' ]
  '23' =>           1. Answer()                                   [pbx_config]
                    2. Playback(hello-world)                      [pbx_config]
                    3. Hangup()                                   [pbx_config]

[ Context 'parkedcalls' created by 'res_features' ]
  '700' =>          1. Park()                                     [res_features]

-= 2 extensions (4 priorities) in 3 contexts. =-
*CLI>

The output includes all the dialplan rules that Asterisk knows about. Notice that there is a 'parkedcalls' context that we haven't seen before; this is activated by default in features.conf and needn't concern us further. What if we are only interested in the my-phones context? We can make our request more specific with dialplan show my-phones:

*CLI> dialplan show my-phones
[ Context 'my-phones' created by 'pbx_config' ]
  '23' =>           1. Answer()                                   [pbx_config]
                    2. Playback(hello-world)                      [pbx_config]
                    3. Hangup()                                   [pbx_config]

-= 1 extension (3 priorities) in 1 context. =-
*CLI> 

The command dialplan show can also be used to show what Asterisk will do if we dial a specific number. Say we want to dial '25' from a phone in the my-phones context. We can see what will happen with the command dialplan show 25@my-phones:

*CLI> dialplan show 25@my-phones
There is no existence of 25@my-phones extension
*CLI>

Nothing happens because there is no match for '25' in the context. If we dial '23' instead, we get this output:

*CLI> dialplan show 23@my-phones
[ Context 'my-phones' created by 'pbx_config' ]
  '23' =>           1. Answer()                                   
                    2. Playback(hello-world)                      
                    3. Hangup()                                   

-= 1 extension (3 priorities) in 1 context. =-
*CLI> 

If we want to check '23' against all the accessible contexts, we use dialplan show 23@:

*CLI> dialplan show 23@
[ Context 'my-phones' created by 'pbx_config' ]
  '23' =>           1. Answer()                                   
                    2. Playback(hello-world)                      
                    3. Hangup()                                   

-= 1 extension (3 priorities) in 1 context. =-
*CLI>

Let's expand our dialplan with an additional context by editing extensions.conf like so:

[general]

[my-phones]
exten => 23,1,Answer()
exten => 23,2,Playback(hello-world)
exten => 23,3,Hangup()

[department-q]
exten => _2X,1,Answer()
exten => _2X,2,Playback(hello-world)
exten => _2X,3,Hangup()

Now we go back to the CLI and, after reloading the dialplan with the reload command, run dialplan show 23@:

*CLI> dialplan show 23@
[ Context 'department-q' created by 'pbx_config' ]
  '_2X' =>          1. Answer()                                   
                    2. Playback(hello-world)                      
                    3. Hangup()                                   

[ Context 'my-phones' created by 'pbx_config' ]
  '23' =>           1. Answer()                                   [pbx_config]
                    2. Playback(hello-world)                      [pbx_config]
                    3. Hangup()                                   [pbx_config]

-= 2 extensions (6 priorities) in 2 contexts. =-
*CLI> 

All the matching extensions are displayed. Let's try it with dialplan show 25@:

*CLI> dialplan show 25@
[ Context 'department-q' created by 'pbx_config' ]
  '_2X' =>          1. Answer()                                   [pbx_config]
                    2. Playback(hello-world)                      [pbx_config]
                    3. Hangup()                                   [pbx_config]

-= 1 extension (3 priorities) in 1 context. =-
*CLI>

There is only one match, in context department-q. In this example, if you dial '25' from a phone in the my-phones context, you still won't hear the 'hello world' message. Extension '25' only works for phones in the department-q context.

Pattern matching order

Do not assume that Asterisk runs through the dialplan in a completely sequential manner; while this is generally the case, it does prioritize patterns based on the quality of the match.

The reason for this is simple: more than one pattern might match a dialled number. If two extensions match a dialled number, Asterisk will always choose the better match. Before deciding which extension matches best, it processes the entire context.

An example:

[sales]
exten => _12X.,1,NoOp{12X}
exten => 12345,1,NoOp(12345}
exten => _1234.,1,NoOp{1234.}

It is not immediately clear which extension is executed when we dial '12345'. To find out, we use dialplan show 12345@sales:

*CLI> dialplan show 12345@sales
[ Context 'sales' created by 'pbx_config' ]
  '12345' =>        1. NoOp(12345})                               [pbx_config]
  '_1234.' =>       1. NoOp{1234.}()                              [pbx_config]
  '_12X.' =>        1. NoOp{12X}()                                [pbx_config]

-= 3 extensions (3 priorities) in 1 context. =-
*CLI> 

Asterisk shows all the hits, but gives extension 12345,1,NoOP{12345} first priority. The highest priority extension is always displayed at the top.

Let's try it with '12346' using the command dialplan show 12346@sales:

*CLI> dialplan show 12346@sales
[ Context 'sales' created by 'pbx_config' ]
  '_1234.' =>       1. NoOp{1234.}()                              [pbx_config]
  '_12X.' =>        1. NoOp{12X}()                                [pbx_config]

-= 2 extensions (2 priorities) in 1 context. =-
*CLI> 

Again, the pattern with the best match to the dialled digits is listed first.

[Important]  
The order in which the patterned extensions appear in the dialplan makes no difference. Patterned extensions are matched strictly in order of match precision.

 

Let's try adding the extension "_." to our previous dialplan example:

[sales]
exten => _12X.,1,NoOp{12X}
exten => 12345,1,NoOp(12345}
exten => _1234.,1,NoOp{1234.}

exten => _.,1,NoOp{Bingo}

When we try testing '12346' with dialplan show 12346@sales, we get the following output:

*CLI> dialplan show 12346@sales
[ Context 'sales' created by 'pbx_config' ]
  '_1234.' =>       1. NoOp{1234.}()                              [pbx_config]
  '_12X.' =>        1. NoOp{12X}()                                [pbx_config]
  '_.' =>           1. NoOp{Bingo}()                              [pbx_config]

-= 3 extensions (3 priorities) in 1 context. =-
*CLI>

In Asterisk 1.4 is is assigned the lowest priority.

Still  it is preferable to use "_X." as the wildcard pattern (if we use a wildcard pattern at all!).

[sales]
exten => _12X.,1,NoOp{12X}
exten => 12345,1,NoOp(12345}
exten => _1234.,1,NoOp{1234.}

exten => _X.,1,NoOp{Bingo}

The priorities appear as follows in both versions:

*CLI> dialplan show 12346@sales
[ Context 'sales' created by 'pbx_config' ]
  '_1234.' =>       1. NoOp{1234.}()                              [pbx_config]
  '_12X.' =>        1. NoOp{12X}()                                [pbx_config]
  '_X.' =>          1. NoOp{Bingo}()                              [pbx_config]

-= 3 extensions (3 priorities) in 1 context. =-
*CLI> 

Checklist

Provided by Rich Adamson
 

A couple of items to consider (in addition to the technical * implementation issues) are:

  1. Check end-to-end connectivity: most corporate  hubs/switches are not on UPSs. If power supply to the phome of PBX  are located under someone's desk, the power cord can be kicked.
  2. Legal issues: what happens when an employee needs to call emergency personnel and the phone system doesn't work for whatever reason
  3. QoS: how will you deal with QoS issues when they pop up? (someone decides to backup their fixed disk across the local net; the latest virus/Trojan is consuming all available bandwidth; user drag/drops very large directory or files.) Take a look at this guide that will help you prioritize VOIP QoS
  4. Network connectivity: your ISP decides to block a range of ports and didn't tell you; what's the backup plan and how quickly can it be operational
  5. Redundancy: are there requirements for a primary & backup * system, and should this be configured with some automated failover process or left to support personnel to handle manually
  6. Version handling: should you have a formal change control process and how does it apply to downloading cvs updates that can break production * boxes? Should you consider separate Development, Test and Production asterisk machines for hardware and/or software promotion?
  7. Staff backup: are there any business requirements for backup support personnel should you get hit by a bus on the way home from work
  8. 24 x 7 support: its not uncommon for infrastructure personnel (eg, switches, routers) to reboot, swap out, upgrade, etc, stuff for various reasons. Is there a need to treat those support requirements different when mgmt is accustomed to phone systems being operational 99.999% of the time?
  9. Rollout: should your plan to implement * include a phase-in approach where only a small part of the business is impacted before moving to the next phase?

Recommended Links

Practical Asterisk 1.4 (unstable)

Asterisk CLI - voip-info.org

InformIT- Practical Asterisk- Installation and "Hello World" > 2.2 ...

Troubleshooting and Debugging VoIP Call Basics [Gateway Protocols ...



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: July 28, 2019