<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/CLI+commands+useful+for+debugging">CLI commands useful for debugging</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://wiki.asterisk.org/wiki/display/~rnewton">Rusty Newton</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <div>
<ul>
    <li><a href='#CLIcommandsusefulfordebugging-%27coreshowlocks%27'>'core show locks'</a></li>
    <li><a href='#CLIcommandsusefulfordebugging-%27coreshowtaskprocessors%27'>'core show taskprocessors'</a></li>
    <li><a href='#CLIcommandsusefulfordebugging-%27coreshowthreads%27'>'core show threads'</a></li>
</ul></div>


<p>Example output on this page is from Asterisk 11.</p>


<h3><a name="CLIcommandsusefulfordebugging-%27coreshowlocks%27"></a>'core show locks'</h3>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Warning!</b><br />Compiling with DEBUG_THREADS can reduce the performance of Asterisk. Primarily in terms of memory consumption.</td></tr></table></div>

<p>This command is not available until you compile with <a href="/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Options" title="Using Menuselect to Select Asterisk Options">DEBUG_THREADS</a>. If compiled with DEBUG_THREADS enabled and if you have glibc, then issuing the "core show locks" CLI command will give lock information output as well as a backtrace of the stack which led to the lock calls.</p>

<p>See the <a href="/wiki/display/AST/Getting+a+Backtrace" title="Getting a Backtrace">Getting a Backtrace</a> page for an example on why you might use this command.</p>


<p>Example command output: (lock during a feature code attended transfer)</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">ubuntu*CLI&gt; core show locks

=======================================================================
=== Currently Held Locks ==============================================
=======================================================================
===
=== &lt;pending&gt; &lt;lock#&gt; (&lt;file&gt;): &lt;lock type&gt; &lt;line num&gt; &lt;function&gt; &lt;lock name&gt; &lt;lock addr&gt; (times locked)
===
=== Thread ID: 0x7f13ea9ed700 (pbx_thread           started at [ 6612] pbx.c ast_pbx_start())
=== ---&gt; Lock #0 (features.c): RDLOCK 3304 ast_rdlock_call_features &amp;features_lock 0x815660 (1)
        asterisk(ast_bt_get_addresses+0xe) [0x4fa57e]
        asterisk(__ast_rwlock_rdlock+0xc3) [0x4f7a93]
        asterisk() [0x4c4639]
        asterisk() [0x4c5378]
        asterisk() [0x4c5841]
        asterisk(ast_bridge_call+0x8ec) [0x4ced2c]
        /usr/lib/asterisk/modules/app_dial.so(+0xbe0c) [0x7f13f7d72e0c]
        /usr/lib/asterisk/modules/app_dial.so(+0xcd96) [0x7f13f7d73d96]
        asterisk(pbx_exec+0x123) [0x526a53]
        asterisk() [0x531381]
        asterisk() [0x536998]
        asterisk() [0x5381eb]
        asterisk() [0x57a384]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a) [0x7f143ada1e9a]
        /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f143bed0cbd]
=== -------------------------------------------------------------------
===
=======================================================================</pre>
</div></div>

<h3><a name="CLIcommandsusefulfordebugging-%27coreshowtaskprocessors%27"></a>'core show taskprocessors'</h3>

<p>List instantiated task processors and statistics</p>

<p>Example command output:</p>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">ubuntu*CLI&gt; core show taskprocessors

        +----- Processor -----+--- Processed ---+- In Queue -+- Max Depth -+
               app_queue                   8            0            0
   core_event_dispatcher                  29            0            1
           app_voicemail                   0            0            0
                pbx-core                  11            0            0
           ast_msg_queue                   0            0            0
               CCSS core                   0            0            0
           iax2_transmit                   0            0            0
        +---------------------+-----------------+------------+-------------+
        7 taskprocessors</pre>
</div></div>


<h3><a name="CLIcommandsusefulfordebugging-%27coreshowthreads%27"></a>'core show threads'</h3>

<p>Shows running threads&#33;&nbsp; Doesn't require any compilation flags to be set.</p>

<p>Example command output:</p>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">ubuntu*CLI&gt; core show threads
0x7f869a7fb700 25102 netconsole           started at [ 1442] asterisk.c listener()
0x7f869a877700 25100 tps_processing_function started at [  471] taskprocessor.c ast_taskprocessor_get()
0x7f869a8f3700 25099 do_monitor           started at [ 5743] chan_unistim.c restart_monitor()
0x7f869a96f700 25098 tps_processing_function started at [  471] taskprocessor.c ast_taskprocessor_get()
0x7f869a9eb700 25097 process_clearcache   started at [ 2267] pbx_dundi.c start_network_thread()
0x7f869aa67700 25096 process_precache     started at [ 2266] pbx_dundi.c start_network_thread()
0x7f869aae3700 25095 network_thread       started at [ 2265] pbx_dundi.c start_network_thread()
0x7f869ab5f700 25094 cleanup              started at [  414] pbx_realtime.c load_module()
0x7f869abdb700 25093 lock_broker          started at [  509] func_lock.c load_module()

... &lt;snip&gt;</pre>
</div></div>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
       <a href="https://wiki.asterisk.org/wiki/display/AST/CLI+commands+useful+for+debugging">View Online</a>
              |
       <a href="https://wiki.asterisk.org/wiki/display/AST/CLI+commands+useful+for+debugging?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>