FreeSWITCH命令大全

 

FreeSWITCH啓動、查看、及關閉

  FreeSWITCH通常安裝在路徑 /usr/local/freeswitch ,可執行程序位於/usr/local/freeswitch/bin 下,配置文件位於/usr/local/freeswitch/conf(固然這寫不是絕對的,具體還要看你本身安裝時候的配置)sql

FreeSWITCH幫助命令session

freeswitch -help
'''
Usage: freeswitch [OPTIONS]

These are the optional arguments you can pass to freeswitch:
    -nf                    -- no forking
    -reincarnate           -- restart the switch on an uncontrolled exit
    -reincarnate-reexec    -- run execv on a restart (helpful for upgrades)
    -u [user]              -- specify user to switch to
    -g [group]             -- specify group to switch to
    -core                  -- dump cores
    -help                  -- this message
    -version               -- print the version and exit
    -rp                    -- enable high(realtime) priority settings
    -lp                    -- enable low priority settings
    -np                    -- enable normal priority settings
    -vg                    -- run under valgrind
    -nosql                 -- disable internal sql scoreboard
    -heavy-timer           -- Heavy Timer, possibly more accurate but at a cost
    -nonat                 -- disable auto nat detection
    -nonatmap              -- disable auto nat port mapping
    -nocal                 -- disable clock calibration
    -nort                  -- disable clock clock_realtime
    -stop                  -- stop freeswitch
    -nc                    -- do not output to a console and background
    -ncwait                -- do not output to a console and background but wait until the system is ready before exiting (implies -nc)
    -c                     -- output to a console and stay in the foreground

    Options to control locations of files:
    -base [basedir]         -- alternate prefix directory
    -cfgname [filename]     -- alternate filename for FreeSWITCH main configuration file
    -conf [confdir]         -- alternate directory for FreeSWITCH configuration files
    -log [logdir]           -- alternate directory for logfiles
    -run [rundir]           -- alternate directory for runtime files
    -db [dbdir]             -- alternate directory for the internal database
    -mod [moddir]           -- alternate directory for modules
    -htdocs [htdocsdir]     -- alternate directory for htdocs
    -scripts [scriptsdir]   -- alternate directory for scripts
    -temp [directory]       -- alternate directory for temporary files
    -grammar [directory]    -- alternate directory for grammar files
    -certs [directory]      -- alternate directory for certificates
    -recordings [directory] -- alternate directory for recordings
    -storage [directory]    -- alternate directory for voicemail storage
    -cache [directory]      -- alternate directory for cache files
    -sounds [directory]     -- alternate directory for sound files
'''
View Code

 

啓動、關閉app

  若是不帶參數的話,直接在命令行中輸入 freeswitch 就能啓動,當你看到下面所示內容時基本就是啓動正常了dom

# 啓動freeswitch
freeswitch

# 關閉freeswitch
shutdown

 

freeswitch@d0a5f22d2bb3> 2019-06-06 09:48:51.667336 [CONSOLE] switch_core.c:2438 
.=============================================================.
|   _____              ______        _____ _____ ____ _   _   |
|  |  ___| __ ___  ___/ ___\ \      / /_ _|_   _/ ___| | | |  |
|  | |_ | '__/ _ \/ _ \___ \\ \ /\ / / | |  | || |   | |_| |  |
|  |  _|| | |  __/  __/___) |\ V  V /  | |  | || |___|  _  |  |
|  |_|  |_|  \___|\___|____/  \_/\_/  |___| |_| \____|_| |_|  |
|                                                             |
.=============================================================.
|   Anthony Minessale II, Michael Jerris, Brian West, Others  |
|   FreeSWITCH (http://www.freeswitch.org)                    |
|   Paypal Donations Appreciated: paypal@freeswitch.org       |
|   Brought to you by ClueCon http://www.cluecon.com/         |
.=============================================================.

.=======================================================================================================.
|       _                            _    ____ _             ____                                       |
|      / \   _ __  _ __  _   _  __ _| |  / ___| |_   _  ___ / ___|___  _ __                             |
|     / _ \ | '_ \| '_ \| | | |/ _` | | | |   | | | | |/ _ \ |   / _ \| '_ \                            |
|    / ___ \| | | | | | | |_| | (_| | | | |___| | |_| |  __/ |__| (_) | | | |                           |
|   /_/   \_\_| |_|_| |_|\__,_|\__,_|_|  \____|_|\__,_|\___|\____\___/|_| |_|                           |
|                                                                                                       |
|    ____ _____ ____    ____             __                                                             |
|   |  _ \_   _/ ___|  / ___|___  _ __  / _| ___ _ __ ___ _ __   ___ ___                                |
|   | |_) || || |     | |   / _ \| '_ \| |_ / _ \ '__/ _ \ '_ \ / __/ _ \                               |
|   |  _ < | || |___  | |__| (_) | | | |  _|  __/ | |  __/ | | | (_|  __/                               |
|   |_| \_\|_| \____|  \____\___/|_| |_|_|  \___|_|  \___|_| |_|\___\___|                               |
|                                                                                                       |
|     ____ _             ____                                                                           |
|    / ___| |_   _  ___ / ___|___  _ __         ___ ___  _ __ ___                                       |
|   | |   | | | | |/ _ \ |   / _ \| '_ \       / __/ _ \| '_ ` _ \                                      |
|   | |___| | |_| |  __/ |__| (_) | | | |  _  | (_| (_) | | | | | |                                     |
|    \____|_|\__,_|\___|\____\___/|_| |_| (_)  \___\___/|_| |_| |_|                                     |
|                                                                                                       |
.=======================================================================================================.


2019-06-06 09:48:51.667349 [INFO] switch_core.c:2447 
FreeSWITCH Version 1.8.5~64bit ( 64bit)

FreeSWITCH Started
Max Sessions [1000]
Session Rate [30]
SQL [Enabled]

 

  若是有錯誤信息,會以紅色字體的形式提現出來,這時須要本身去排查錯誤nosql

 

後臺啓動、關閉socket

  固然咱們通常運行 FreeSWITCH 都是之後臺的形式tcp

# 後臺啓動
freeswitch -nc

# 關閉後臺freeswitch
freeswitch -stop

 

查看相關日誌ide

  咱們能夠首先查看一下FreeSWITCH是否正常啓動oop

netstat -anp | grep freeswitch
'''
tcp        0      0 172.17.0.7:8081         0.0.0.0:*               LISTEN      14252/freeswitch    
tcp        0      0 172.17.0.7:8082         0.0.0.0:*               LISTEN      14252/freeswitch    
tcp        0      0 172.17.0.7:7443         0.0.0.0:*               LISTEN      14252/freeswitch    
tcp        0      0 172.17.0.7:5080         0.0.0.0:*               LISTEN      14252/freeswitch    
tcp        0      0 172.17.0.7:5060         0.0.0.0:*               LISTEN      14252/freeswitch    
tcp        0      0 172.17.0.7:2855         0.0.0.0:*               LISTEN      14252/freeswitch    
tcp        0      0 172.17.0.7:2856         0.0.0.0:*               LISTEN      14252/freeswitch    
tcp        0      0 172.17.0.7:5066         0.0.0.0:*               LISTEN      14252/freeswitch    
udp        0      0 0.0.0.0:1337            0.0.0.0:*                           14252/freeswitch    
udp        0      0 172.17.0.7:52133        172.17.0.1:5351         ESTABLISHED 14252/freeswitch    
udp        0      0 172.17.0.7:5060         0.0.0.0:*                           14252/freeswitch    
udp        0      0 172.17.0.7:5080         0.0.0.0:*                           14252/freeswitch    
unix  3      [ ]         STREAM     CONNECTED     2109650  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2105745  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2107133  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2105746  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2108033  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2107132  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2108032  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2109651  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2107134  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2107131  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2102897  14252/freeswitch     
unix  3      [ ]         STREAM     CONNECTED     2102898  14252/freeswitch     
'''
View Code

 

  後臺啓動了FreeSWITCH後咱們須要查看相關日誌須要用 fs_cli 命令,若是出現下圖內容就說明連上了字體

fs_cli
'''
.=======================================================.
|            _____ ____     ____ _     ___              |
|           |  ___/ ___|   / ___| |   |_ _|             |
|           | |_  \___ \  | |   | |    | |              |
|           |  _|  ___) | | |___| |___ | |              |
|           |_|   |____/   \____|_____|___|             |
|                                                       |
.=======================================================.
| Anthony Minessale II, Ken Rice,                       |
| Michael Jerris, Travis Cross                          |
| FreeSWITCH (http://www.freeswitch.org)                |
| Paypal Donations Appreciated: paypal@freeswitch.org   |
| Brought to you by ClueCon http://www.cluecon.com/     |
.=======================================================.

.=======================================================================================================.
|       _                            _    ____ _             ____                                       |
|      / \   _ __  _ __  _   _  __ _| |  / ___| |_   _  ___ / ___|___  _ __                             |
|     / _ \ | '_ \| '_ \| | | |/ _` | | | |   | | | | |/ _ \ |   / _ \| '_ \                            |
|    / ___ \| | | | | | | |_| | (_| | | | |___| | |_| |  __/ |__| (_) | | | |                           |
|   /_/   \_\_| |_|_| |_|\__,_|\__,_|_|  \____|_|\__,_|\___|\____\___/|_| |_|                           |
|                                                                                                       |
|    ____ _____ ____    ____             __                                                             |
|   |  _ \_   _/ ___|  / ___|___  _ __  / _| ___ _ __ ___ _ __   ___ ___                                |
|   | |_) || || |     | |   / _ \| '_ \| |_ / _ \ '__/ _ \ '_ \ / __/ _ \                               |
|   |  _ < | || |___  | |__| (_) | | | |  _|  __/ | |  __/ | | | (_|  __/                               |
|   |_| \_\|_| \____|  \____\___/|_| |_|_|  \___|_|  \___|_| |_|\___\___|                               |
|                                                                                                       |
|     ____ _             ____                                                                           |
|    / ___| |_   _  ___ / ___|___  _ __         ___ ___  _ __ ___                                       |
|   | |   | | | | |/ _ \ |   / _ \| '_ \       / __/ _ \| '_ ` _ \                                      |
|   | |___| | |_| |  __/ |__| (_) | | | |  _  | (_| (_) | | | | | |                                     |
|    \____|_|\__,_|\___|\____\___/|_| |_| (_)  \___\___/|_| |_| |_|                                     |
|                                                                                                       |
.=======================================================================================================.

Type /help <enter> to see a list of commands




[This app Best viewed at 160x60 or more..]
+OK log level  [7]
freeswitch@d0a5f22d2bb3> 
'''

 

問題解決  

  若是 fs_cli 命令連不上,報錯信息以下:

[ERROR] fs_cli.c:1679 main() Error Connecting []
Usage: fs_cli [-H <host>] [-P <port>] [-p <secret>] [-d <level>] [-x command] [-t <timeout_ms>] [profile]

  -?,-h --help                    Usage Information
  -H, --host=hostname             Host to connect
  -P, --port=port                 Port to connect (1 - 65535)
  -u, --user=user@domain          user@domain
  -p, --password=password         Password
  -i, --interrupt                 Allow Control-c to interrupt
  -x, --execute=command           Execute Command and Exit
  -l, --loglevel=command          Log Level
  -U, --log-uuid                  Include UUID in log output
  -S, --log-uuid-short            Include shortened UUID in log output
  -q, --quiet                     Disable logging
  -r, --retry                     Retry connection on failure
  -R, --reconnect                 Reconnect if disconnected
  -d, --debug=level               Debug Level (0 - 7)
  -b, --batchmode                 Batch mode
  -t, --timeout                   Timeout for API commands (in miliseconds)
  -T, --connect-timeout           Timeout for socket connection (in miliseconds)
  -n, --no-color                  Disable color

 

  這時須要修改一下鏈接IP,首先咱們須要啓動 enable the mod_event_socket 模塊,文件 位於 /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml ,而後修改默認的啓動IP,修改文件位於  /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml ,而後重啓 FreeSWITCH 便可

nano  /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml

'''
<configuration name="event_socket.conf" description="Socket Client">
  <settings>
    <param name="nat-map" value="false"/>
    <param name="listen-ip" value="::"/>
    <param name="listen-port" value="8021"/>
    <param name="password" value="ClueCon"/>
    <!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
    <!--<param name="stop-on-bind-error" value="true"/>-->
  </settings>
</configuration>
'''

# 將上面的<param name="listen-ip" value="::"/>改成<param name="listen-ip" value="0.0.0.0"/>

 

查看狀態

  在 fs_cli 中輸入 status

freeswitch@d0a5f22d2bb3> status
'''
UP 0 years, 0 days, 0 hours, 0 minutes, 17 seconds, 869 milliseconds, 212 microseconds
FreeSWITCH (Version 1.8.5  64bit) is ready
0 session(s) since startup
0 session(s) - peak 0, last 5min 0 
0 session(s) per Sec out of max 30, peak 0, last 5min 0 
1000 session(s) max
min idle cpu 0.00/99.50
Current Stack Size/Max 240K/8192K
'''

 

  在 fs_cli 中輸入 sofia status

freeswitch@d0a5f22d2bb3> sofia status
'''
                     Name       Type                                          Data    State
=================================================================================================
               172.17.0.7      alias                                      internal    ALIASED
                 external    profile                 sip:mod_sofia@172.17.0.7:5080    RUNNING (0)
    external::example.com    gateway                       sip:joeuser@example.com    NOREG
                 internal    profile                 sip:mod_sofia@172.17.0.7:5060    RUNNING (0)
=================================================================================================
2 profiles 1 alias
'''

 

添加一個用戶

  在 /usr/local/freeswitch/comf/directory/default 下有默認的1000-1019共20個帳號,能夠經過 copy 並修改其中的 user_id 來實現增長新的帳號

 

路由配置

  • 默認路由文件:/usr/local/freeswitch/comf/dialplan/default.xml ,能夠修改他
  • 添加新的路有也能夠修改文件:/usr/local/freeswitch/comf/dialplan/default 
  • 外線來電路有配置文件:/usr/local/freeswitch/comf/dialplan/public.xml

 

 

 

 

 

 待續....

 

配置文件

  FreeSwitch的配置文件默認是放在 FreeSwitch\Conf\ 下,最頂層是的 FreeSwitch.xml,也就是說最早加載的就是這個 XML, FreeSwitch 根據這個 XML 依次加載 Conf 目錄下的其它配置文件。

先說conf根目錄下的文件
  • freeswitch.xml:主配置文件,它會使用include語句裝入其它文件。
  • vars.xml:一些經常使用變量,都在這個配置文件中定義。
再說conf下的文件夾
  • autoload_configs:存放自動加載的配置文件。
    • 此文件夾下的modules.conf.xml:配置當freeswitch啓動時自動裝載哪些模塊。
    • 此文件夾下其它xml:通常來講都是對應每一個模塊的配置文件。
  • chatplan文件夾:存放的是聊天計劃配置文件。
  • dialplan文件夾:存放的是撥號計劃配置文件。
  • directory文件夾:用戶目錄,存儲跟用戶相關的信息。
    • 此文件夾下的的defalut目錄是默認的用戶目錄配置,default下的xml文件是對應每一個sip用戶的,每一個sip用戶都有一個配置文件。
  • ivr_menus文件夾:IVR菜單配置文件。
  • jingle_profiles文件夾:鏈接Google Talk的相關配置文件。
  • lang文件夾:多語言支持配置文件。
    • 此文件夾下的en爲英語,fr文件夾是法語。
  • mrcp_profiles文件夾:MRCP的相關配置,用於跟第三方語音合成和語音識別系統對接。
  • sip_profiles文件夾:sip配置文件
    • 此文件夾下的internal.xml:一個SIP profile,或稱做一個SIP-UA,監聽在本地IP及端口5060。
    • 此文件夾下的externa.xml:另外一個SIP-UA,用做外部鏈接,端口5080。
  • skinny_profiles文件夾:思科SCCP協議話機的配置文件。

                          

 待續...

相關文章
相關標籤/搜索