Directories in Asterisk on Linux

Directories Used by Asterisk
Asterisk uses several directories on a Linux system to manage the various aspects of
the system, such as voicemail recordings, voice prompts, and configuration files.
This section discusses the necessary directories, all of which are created during
installation and configured in the asterisk.conf file.

/etc/asterisk/
The /etc/asterisk/ directory contains the Asterisk configuration files. One file, however—
zaptel.conf—is located in the /etc/ directory. The Zaptel hardware was originally
designed by Jim Dixon of the Zapata Telephony Group as a way of bringing
reasonable and affordable computer telephony equipment to the world. Asterisk
makes use of this hardware, but any other software can also make use of the Zaptel
hardware and drivers. Consequently, the zaptel.conf configuration file is not directly
located in the /etc/asterisk/ directory.

/usr/lib/asterisk/modules/
The /usr/lib/asterisk/modules/ directory contains all the Asterisk loadable modules.
Within this directory are the various applications, codecs, formats, and channels
used by Asterisk. By default, Asterisk loads all of these modules at startup. You can
disable any modules you are not using in the modules.conf file, but be aware that certain
modules are required by Asterisk or are dependencies of other modules.
Attempting to load Asterisk without these modules will cause an error at startup.

/var/lib/asterisk
The /var/lib/asterisk/ directory contains the astdb file and a number of subdirectories.
The astdb file contains the local Asterisk database information, which is somewhat
like the Microsoft Windows Registry. The Asterisk database is a simple
implementation based on v1 of the Berkeley database. The db.c file in the Asterisk
source states that this version was chosen for the following reason: “DB3 implementation
is released under an alternative license incompatible with the GPL. Thus in
order to keep Asterisk licensing simplistic, it was decided to use version 1 as it is
released under the BSD license.”
The subdirectories within /var/lib/asterisk/ include:

agi-bin/
The agi-bin/ directory contains your custom scripts, which can interface with
Asterisk via the various built-in AGI applications. For more information about
AGI.
firmware/
The firmware/ directory contains firmware for various Asterisk-compatible
devices. It currently contains only the iax/ subdirectory, which holds the binary
firmware image for Digium’s IAXy.

images/
Applications that communicate with channels supporting graphical images look
in the images/ directory. Most channels do not support the transmission of
images, so this directory is rarely used. However, if more devices that support
and make use of graphical images are released, this directory will become more
relevant.
keys/
Asterisk can use a public/private key system to authenticate peers connecting to
your box via an RSA digital signature. If you place a peer’s public key in your
keys/ directory, that peer can be authenticated by channels supporting this
method (such as the IAX2 channels). The private key is never distributed to the
public. The reverse is also true: you can distribute your public key to your peers,
allowing you to be authenticated with the use of your private key. Both the public
and private keys—ending in the .pub and .key file extensions, respectively—
are stored in the keys/ directory.
mohmp3/
When you configure Asterisk for Music on Hold, applications utilizing this feature
look for their MP3 files in the mohmp3/ directory. Asterisk is a bit picky
about how the MP3 files are formatted, so you should use constant bitrate (CBR)
encoding and strip the ID3 tags from your files.

/var/spool/asterisk/
The Asterisk spool directory contains several subdirectories, including outgoing/,
qcall/, tmp/, and voicemail/ (see Figure 3-2). Asterisk monitors the outgoing and qcall
directories for text files containing call request information. These files allow you to
generate a call simply by copying or moving the correctly structured file into the outgoing/
directory.

/var/run/
The /var/run/ directory contains the process ID (pid) information for all active processes
on the system, including Asterisk (as specified in the asterisk.conf file). Note
that /var/run/ is OS-dependent and may differ.

/var/log/asterisk/
The /var/log/asterisk/ directory is where Asterisk logs information. You can control
the type of information being logged to the various files by editing the logger.conf file
located in the /etc/asterisk/ directory. Basic configuration of the logger.

/var/log/asterisk/cdr-csv
The /var/log/asterisk/cdr-csv directory is used to store the CDRs in comma-separated
value (CSV) format. By default information is stored in the Master.csv file, but individual
accounts can store their own CDRs in separate files with the use of the
accountcode option.


///////////////////COMMAND LINE///////////////////

CLI Commands
The Asterisk binary is, by default, located at /usr/sbin/asterisk. If you run /usr/sbin/
asterisk, it will be loaded as a daemon. There are also a few switches you should be
aware of that allow you to (re)connect to the Asterisk CLI, set the verbosity of CLI
output, and allow core dumps if Asterisk crashes (for debugging with gdb). To
explore the full range of options, run Asterisk with the –h switch:
# /usr/sbin/asterisk –h
Here is a list of the most commonly used options:
-c
Console. This allows you to connect to the Asterisk CLI.
-v
Verbosity. This is used to set the amount of output for CLI debugging.
-g
Core dump. If Asterisk were to crash unexpectedly, this would cause a core file
to be created for later tracing with gdb.
-r
Remote. This is used to reconnect remotely to an already running Asterisk process.
(The process is remote from the standpoint of the console connecting to it
but is actually a local process on the machine. This has nothing to do with
connecting to a remote process over a network using a protocol such as IP, as
this is not supported.)
-rx "restart now"
Execute. Using this command in combination with –r allows you to execute a
CLI command without having to connect to the CLI and type it manually.
Let’s look at some examples. To start Asterisk and connect to the CLI with a verbosity
level of 3, use the following command:
# /usr/sbin/asterisk –cvvv
If the Asterisk process is already running (for example, if you started Asterisk with
/usr/sbin/asterisk), instead use the reconnect switch, like so:
# /usr/sbin/asterisk –vvvr
If you want Asterisk to dump a core file after a crash, you can use the –g switch when
starting Asterisk:
# /usr/sbin/asterisk –g
To execute a command without connecting to the CLI and typing it (perhaps for use
within a script), you can use the –x switch in combination with the –r switch:
# /usr/sbin/asterisk –rx "restart now"
If you are experiencing crashes and would like to output to a debug file, use the following
command:
# /usr/sbin/asterisk –vvvvvvvvvc | tee /tmp/debug.log

Comments

Popular posts from this blog

Error : DependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.adobe.aem:uber-jar:jar:apis -> version 6.3.0 vs 6.4.0

Operators in Asterisk with Linux

ERROR Exception while handling event Sitecore.Eventing.Remote.PublishEndRemoteEventException: System.AggregateExceptionMessage: One or more exceptions occurred while processing the subscribers to the 'publish:end:remote'