Asterisk Console

I am not terribly fond of any of the Asterisk GUI attempts. Therefore, we are going to learn how to control Asterisk using the command line console (hence all of the Unix background knowledge and so forth).

To enter the CLI (Command Line Interface) for Asterisk (the console), issue the following command:

asterisk -r

You should see something like this:

Asterisk, Copyright (C) 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public License
version 2 and other licenses; you are welcome to redistribute it under certain conditions.
Type 'core show license' for details.
Connected to Asterisk currently running on asterisk (pid = 15927) Verbosity is at least 3

At the prompt you can enter commands. Probably the best one to start with is “help” which will give you a long list of commands and a short description of each. You can get more information about any particular command by typing:

help command_name

Some commands in particular that you should learn and learn well are:

exit - gets you out of the Asterisk CLI
module reload - reloads the configuration
sip set debug on - gives you all kinds of information regarding SIP processes (the means we are using to communication with our TSP).
sip set debug off - when you get sick of all of that information.

Other Useful commands that you might want to try (stay away from the restart and stop commands please)

core show channels Display information on channels
core show channel Display information on a specific channel
core show channeltypes List available channel types
core show channeltype Give more details on that channel type
core show codecs Displays a list of codecs
core show codec Shows a specific codec
core show file formats Displays file formats
core show functions Shows registered dialplan functions
core show function Describe a specific dialplan function
core show globals Show global dialplan variables
core show hints Show dialplan hints
core show uptime Show uptime information
dialplan reload Reload extensions and *only* extensions
dialplan show Show dialplan
file convert Convert audio file
mixmonitor Execute a MixMonitor command.
module show List modules and info
moh reload Music On Hold
moh show classes List MOH classes
moh show files List MOH file-based classes
originate Originate a call
sip set debug on Enable SIP debugging
sip set debug ip Enable SIP debugging on IP
sip set debug off Disable SIP debugging
sip set debug peer Enable SIP debugging on Peername
sip show channels List active SIP channels
sip show channel Show detailed SIP channel info
sip show domains List our local SIP domains.
sip show history Show SIP dialog history
sip show inuse List all inuse/limits
sip show peers List defined SIP peers
sip show peer Show details on specific SIP peer
sip show registry List SIP registration status
sip show settings Show SIP global settings
sip show subscriptions List active SIP subscriptions
sip show users List defined SIP users
sip show user Show details on specific SIP user
hangup request Request a hangup on a given channel
voicemail show users List defined voicemail boxes
voicemail show zones List zone message formats

Probably the most useful part of having access to the console is being able to debug your dialplan.

When a call comes in you start to see output such as this:

-- Executing Playback("SIP/ck987-7716", "beep") in new stack
-- Playing 'beep' (language 'en')
-- Executing VoiceMail("SIP/ck987-7716", "u10@testingtesting") in new stack
-- Playing 'vm-theperson' (language 'en')
-- Playing 'digits/1' (language 'en')
-- Playing 'digits/0' (language 'en')
-- Playing 'vm-isunavail' (language 'en')
-- Playing 'vm-intro' (language 'en')
-- Playing 'beep' (language 'en')
-- Recording the message
-- x=0, open writing: /var/spool/asterisk/voicemail/testingtesting/10/INBOX/msg0002 format: wav49, 0x8869280
-- x=1, open writing: /var/spool/asterisk/voicemail/testingtesting/10/INBOX/msg0002 format: gsm, 0x886d080
-- x=2, open writing: /var/spool/asterisk/voicemail/testingtesting/10/INBOX/msg0002 format: wav, 0x88780c0

You will also see error messages which helps immensly when trying to debug a problematic dialplan.