Asterisk - commands. Using the Asterisk Console
The modern rhythm of life is inconceivable without creationa clear and customized system of communication between representatives of various spheres of production, services, and any business. Providing telephone support is one of the important steps in creating feedback or advisory services. The Asterisk project is the optimal solution for the deployment of computer telephony.
So what is Asterisk?
If it's easy, then Asterisk is a classic automatic telephone exchange,It has a large set of functions, plug-ins, modules and extensions that can increase the range of capabilities. The software package is distributed under the license of open source software, which allows many free developers-enthusiasts to support and develop the project.
The operating system does not matter forfull functioning of the complex, as the product is cross-platform. The flexibility of Asterisk is that it has the ability to create custom modules based on the built-in language.
The system supports many known protocols, for example, SIP, MGCP, SCCP.
Asterisk also has its own IAX protocol, which allows exchanging information between servers of the same system.
Some special equipment for workAsterisk is not required. All known devices do not interfere with the system without any problems. In some cases, it makes sense to use branded equipment from the company Digium, the creators of the system.
All the functioning of the system is due toread from configuration files. The most important of them is sip.conf. In its depths, information about the operation of the SIP protocol, NAT settings and other key functions is concluded.
By default, it is immediately ready for use and allows the use of Asterisk in its full functionality. However, the account information must be filled in. There are three types of sip.conf:
The latter includes the previous two, so many experts almost always use it.
To manage and analyze the operation of the systemA special command line interface is used. You can login to it using rasterisk. The same effect will be given by the command asterisk -rvvv. The -rvvv switch is needed to change the logging level.
First, consider the common CLI commands of Asterisk:
- sip show peers - Extensive information about all subscribers of the system, their numbers, ip addresses, pings and more. other;
- sip show registry - shows all available SIP registrations;
- sip reload - the command is used after certain changes were made to the configuration file sip.conf. In fact, it reboots the module;
- sip show channels - shows currently active channels with information about users, call identifiers and other;
- sip show settings - displays all global SIP settings;
- sip set debug - enables debugging mode. You can specify a specific address or feast;
- dialplan show - displays the used dialplan;
- dialplan reload - will perform its reboot;
- core show codecs - displays information about all codecs installed in the Asterisk system;
- core restart now - will immediately reboot Asterisk;
- core show help - list of commands used in Asterisk.
The following commands are used less often, but they are also important and may be useful for setting up and analyzing:
- keys show - displays all RSA keys;
- keys init - set the password for a single RSA key;
- indication show - display of the list of indicators and countries;
- http show status - displays the status of the HTTP server;
- database showkey - displays information from the database by key;
- database del - removes the key and values from the database;
- core show threads - displays information about running applications;
- core show function - shows information about the special functions of the current dialplan.
AMI - Asterisk commands
To manage the system from external applications wasthought of a special interface. It's called AMI. And this process happens by way of entering special Asterisk AMI commands. They are transmitted over the TCP protocol. This is a very convenient mechanism for remote management of the system from various software solutions.
Briefly we will tell: A connection is established between the client application and the server, and the settings are changed using the Asterisk commands. For this, a string is passed to it, which consists of the following elements:
- key - a keyword that contains a description for the information in the incoming line;
- value is the value of the key.
In order to be able to sendserver Asterisk command, you need to connect to it first. Once the connection is established, you can send packets. They can be transmitted in any order. The key must be one of the following words: Action, Event, Response. Now a little more about them:
- Action. After the server receives this type of package, some action will be taken. For one package - one action.
- Response. Here is the response of the server after the action.
- Event. Information about the event that occurred on the server.
Response can take multiple values, independing on what action the server has performed. For example, successful completion will be initiated by the word Success, error - Error, Follows - information about the server reaction will be transmitted in the following packages.
Usage and examples
To understand how to use the Asterisk commands, you need to consider a few examples.
Action: login Username: admin Secret: secret12
In this line, an Action packet is transmitted, containinguser name with password. The login keyword means that you need to log in to the system with the specified parameters. In response, the server can send something like this: Response: Success Message: Authentification accepted.
This line indicates that the operation was successful.
You can disconnect from Asterisk by passing the Action: logoff command. In the answer will come the message with a farewell.
The following example shows how using commandsAsterisk and AMI can make a call: Action: Originate Channel: SIP / 2001 Context: incoming Exten: 2001 Priority: 1 Callerid: 2001 Variable: ANSWER = 1 Variable: _ACC = 1.
The command transmits data about the user making the call. This is reflected in Callerid and Channel.
In fact, through AMI, you can implement many different operations and functions. You can see the full list in the official guide on the manufacturer's website.
Using the Asterisk console commands gives flexibility and versatility to the system. So, you can apply it remotely. In this case, it is possible to save the entire functionality of the complex.
Among other things, the company developer hassoftware solution and for those users who dislike the command line. It has a convenient graphical interface and has all the necessary functions.
For some solutions, third-party developersuse the web version of the program. It does not require installation on a computer, but it allows you to fully use the Asterisk system. For its operation, it will only need a PC connected to the network, and a browser installed on it.