The fs_cli program allows a user to connect to a running FreeSWITCH instance. The fs_cli program can connect to the FreeSWITCH process on the local machine or on a remote system. (Network connectivity to the remote system is, of course, required.) The fs_cli program uses FreeSWITCH's event socket to send commands issued by the user and to collect the server responses to send to the display. A C-based socket library, ESL, was developed for use with fs_cli although a programmer could use this library for any C language program that needs to connect to the event socket. With the -x switch (see below) fs_cli can issue a command to the server, get a response, and then disconnect.
Note the fs_cli requires the mod_event_socket to be loaded in order to connect to the freeswitch server.
The default mod_event_socket configuration binds only to 127.0.0.1, this will need to be be changed to be able to connect from remote servers. There are security risks to doing this, so you should also limit access via a firewall and/or ACL, as well as never using the default password.
The FreeSWITCH server will build and install the fs_cli client by default.
The client can also be built without needing to build the entire FreeSWITCH server.
- make current
- cd libs/esl
The usage for fs_cli is:
fs_cli [-H <host>] [-P <port>] [-p <secret>] [-d <level>] [-x command] [profile]
The command line arguments are:
- -H - Host name or IP address (default is 127.0.0.1)
- -P - TCP port number (default is "8021")
- -p - Logon password (default is "ClueCon")
- -d - Debug level 0-7 (default is 6, NOT the same as log level)
- -l - Log level level warning/info/debug (default is debug)
- -q - Disable logging
- -r or -R - Retry connection every two seconds until connected (or until 2 minutes has passed)
- -x - Command to execute, wrapped in quotes
- -b or --batchmode (for all os's). Batch mode causes more aggressive flushing of stdout and no colorization so external programs can harness fs_cli. It reduces the input complexity (tabbing, input completion etc) to best work for being batch fed commands. Note in most cases you should be using the ESL library (available for just about every language) rather than fs_cli.
- profile - Profile name from .fs_cli_conf file
While connected the user can issue any command normally available on the FreeSWITCH command line. Additionally, there are several commands that can be issued using a forward slash (/) character. The following commands all disconnect from the FreeSWITCH command line:
Other "slash" commands correspond to mod_event_socket commands:
- /event - Enable events (More Info)
- /noevents - Disable all events previously enabled with /event
- /nixevent - Enable all but one type of event (More Info)
- /log - set loglevel of the FreeSWITCH daemon (e.g. /log info or /log alert) (More Info)
- /nolog - Disable logging (More Info)
- /uuid - Filter logs for a single call uuid
- /filter (More Info)
- /help - List fs_cli commands
Additional command available only in fs_cli
- /logfilter <string> - Displays only lines in /log containing <string>. /logfilter without argument disables logfilter
Optional configuration files can be set up. The config file uses a simple INI-style layout and allows for multiple profiles. This allows one to access many FreeSWITCH systems from a single workstation.
There is /etc/fs_cli.conf for system-wide settings and ~/.fs_cli.conf for user-specific settings.
An example file:
[default] ; Put me in /etc/fs_cli.conf or ~/.fs_cli_conf ;overide any default options here loglevel => 6 log-uuid => false quiet => false key_f1 => help key_f2 => status key_f3 => show channels key_f4 => show calls key_f5 => sofia status key_f6 => reloadxml key_f7 => /log console key_f8 => /log debug key_f9 => sofia status profile internal key_f10 => sofia global siptrace on key_f11 => sofia global siptrace off key_f12 => version [profile1] host => 192.168.1.10 port => 8021 password => secret_password debug => 7 [profile2] host => 192.168.1.11 port => 8021 password => someother_password loglevel => info
Debian 7 defaults to localhost pointing to ipv6 address ::1
Either invoke fs_cli with "-H 127.0.0.1" or edit /etc/hosts to remove references to the ipv6 localhost address mapping.
Launches fs_cli which connects to local machine using default username, password, and debug level.
Launches fs_cli using profile named "My_profile" found in .fs_cli_conf file.
Sending a command and then logging off
fs_cli -x "sofia status profile internal"
Launches fs_cli and sends a command before logging off. The output of the above command looks like this:
fs_cli -x "sofia status" Name Type Data State ================================================================================================= external profile sip:email@example.com:5080 RUNNING (0) example.com gateway sip:firstname.lastname@example.org NOREG internal profile sip:email@example.com:5060 RUNNING (0) 192.168.50.229 alias internal ALIASED internal-ipv6 profile sip:mod_sofia@[::1]:5060 RUNNING (0) default alias internal ALIASED nat alias external ALIASED outbound alias external ALIASED ================================================================================================= 3 profiles 4 aliases
- Option to see all output to include FS console output.
- Option to see all output from all fs_cli instances connected to the FS box, plus the console.
- Option to connect to more than one FS box.