1. Bicom Systems
  2. Solution home
  3. Quick problem solving documents
  4. Quick problem solving documents

General :: Useful Asterisk commands

When one needs to debug an issue or gather additional info on various problems with PBXware, Asterisk' own CLI can come in handy. 

It provides you with additional info by default and you have an option to even enable higher levels of verbosity and debug, along with the ability to see the SIP traffic and packets.

Entering CLI

Before you can see any of the messages in Asterisk CLI, you need to ssh to the system by using the ssh command (if using Linux on your computer) or using Putty or similar software if on PC/MAC. 

After that, you can enter the Asterisk CLI via the following command

asterisk -rvvvvv

The amount of "v" flags defines the level of verbosity in the asterisk CLI.

Once inside you will see a lot of useful information printed out for all actions on the system, Asterisk related though. You will see;

  • Phone calls

  • endpoint/aor registrations

  • Subscribe notifications

  • reload of system components

Entering CLI with additional debugging

If for some reason you have some inexplicable issues, like Asterisk not being able to start, you can try to run the CLI with different sets of switches which should give some application-specific debug info including start-up sequence, database connection, registration retries, etc.

asterisk -rddddd

where the number of Ds defines the verbosity of these debug messages.

If the above command tells you that asterisk is not running:

Try the following command:

asterisk -cdddddd

The "c" flag will run asterisk in foreground and show you what happens during the boot procedure.

Running commands outside of CLI

If you don't need to be inside CLI, or you need just to execute some command without concern of output from CLI, you can do so by running the Asterisk command with the following switches being used:

asterisk -rx ‘type your command’

For example:

asterisk -rx ‘pjsip show endpoints’

Above will list endpoints without going into CLI:

This is a very useful command and flag because it allows you to combine it with for example "grep" command, which would allow you to find something specific if the command you execute provides lots of information.

PJSIP Debugging

Starting with PBXware version 5, we introduced a great tool for troubleshooting named SNGREP: https://support.bicomsystems.com/a/solutions/articles/67000673400

However, troubleshooting can be done inside of Asterisk CLI as well.

The first important command to know is:

pjsip set logger on

Enable debugging for specific IP address:

pjsip set logger host XXX

Where XXX is an IP address for which you are enabling debugging:

An additional command that can be used is the ability to store pjsip logger output to PCAP file:

For example:

pjsip set logger pcap /tmp/test.pcap

The path to the output is: /opt/pbxware/pw/tmp.

To read a PCAP file, we can use tcpdump or SNGREP, or we can download it to our computer and use Wireshark!

With tcpdump: tcpdump -r /opt/pbxware/pw/tmp/test.pcap

With SNGREP: /opt/pbxware/sh/sngrep -I /tmp/test.pcap

When you finish debugging, you need to turn off debugging since leaving that running clutters the CLI output and you might miss other important information on the system.

To turn off PJSIP debugging run this command:

pjsip set logger off

Codec transcoding list

If for some reason you have audio problems, some of the messages might indicate codec incompatibilities on the system. In such cases you can see the possible translation paths in Asterisk with the following command:

core show translation

List codecs on the system with the command 

core show codecs

Reloading the complete Asterisk configuration

In cases, and not limited to, where you did manual modifications to the Asterisk dial plan, you need to reload the complete configuration of the Asterisk subsystem which can be done by a simple command:


This will reload all the configurations related to the Asterisk telephony engine.

Restarting the Asterisk

If reloading Asterisk is not enough for the changes made, or there is another reason to do so, you can restart complete Asterisk with:

restart now

Printing out the Dialplan

PBXware’s implementation of the Asterisk engine uses AGI to control how Asterisk should route the call, but for various reasons, you might be inclined to change a few aspects of how the calls should route. 

By default, Asterisk uses Dialplan to route the calls to various other places. Dialplan information is located in several conf files (please check official Asterisk documents on this).

When you change the dial plan in extensions.conf file, for example, you will reload the Asterisk configuration. After that, you will want to show the dial plan to verify that your changes have been applied to it.

To list the complete dial plan in Asterisk run:

diaplan show

Similar will appear:

To list specific dialplan that you wrote/changed run:

dialplan show “dialplan name”

for example:

dialplan show t-custom

List aors and endpoints

When checking extensions and/or availability of trunks, you can print aors/endpoints on the system:

pjsip show endpoints

pjsip show aors

Checking for one specific endpoint with the command:

pjsip show endpoint XXX

Where XXX is an extension or trunk on the system:

pjsip show aor XXX