Asterisk CPU usage at 100% with FreePBX

Yesterday I spent way too long troubleshooting an issue with an Asteirsk server that I hadn’t seen before, so I thought I’d do a short write-up here in case anyone else sees similar symptoms.

The system is running Asterisk 1.8 with FreePBX 2.8 and FOP2.

The symptoms were a little erratic but included –

– CPU for Asterisk process climbed to 100% and stayed there

– FreePBX gave message when trying to Apply Setting regarding a problem with retrieve_conf

– Running ‘sip show peers’ in the Asterisk console would not list any peers (there were around 50)

– Running ‘sip show peers’ again would cause the Asterisk console to freeze

– Asterisk process showed 800mb of VIRT mem usage

– Starting Asterisk would cause 3 or 4 SEGFAULT messages before safe_asterisk finally managed to start the Asterisk process

What I tried to resolve the issue –

– Upgraded Asterisk to the latest 1.8 release made no difference

– Restore the Asterisk .conf files from a previous days backup made no difference

– Disabling some of the Asterisk modules would sometimes cause the Asterisk process to start correctly, with low CPU usage. This was intermittent though and there was no clear pointer to any specific module

The solution

It actually turned out to be a corrupt Asterisk Database (AstDB) file. This is normally stored here – /var/lib/asterisk/astdb and records some settings about follow-me’s, caller ids, etc. Renaming this file enabled Asterisk to start correctly. Asterisk will create another file but if you’re running FreePBX you need to go to every extension and click ‘Submit’ and then ‘Apply Changes’ at the end to recreate the extension settings in that file.

Additional

If you’re having to track down what is causing high CPU usage in Asterisk then here is a really great blog post describing a process to find exactly what part of the Asterisk code is causing the issue.

It might give you some pointers to where the problem lies –

Why does Asterisk consume 100% CPU?

2 thoughts on “Asterisk CPU usage at 100% with FreePBX

  1. Jeremy

    Hi,

    I have many elastix in prod with same issues ….

    Instead of click on each phone you can use :

    http://YOURPBX/admin/config.php?type=setup&display=devices&action=resetall

    Problem :
    Call waiting are not recreated.

    Solution :
    Small php script :
    <?
    $myArray = file('extensions_list.txt');
    echo(count($myArray)." recordsn");
    for($i=0;$i
    where extensions_list.txt is
    100
    101
    102
    etc

    Problem :
    Followme are not recreated

    Solution :
    asterisk -rx “database show” |grep followme

    ex :
    /AMPUSER/100/followme/changecid : default
    /AMPUSER/100/followme/ddial : EXTENSION
    /AMPUSER/100/followme/fixedcid :
    /AMPUSER/100/followme/grpconf : DISABLED
    /AMPUSER/100/followme/grplist : 101-102
    /AMPUSER/100/followme/grptime : 20
    /AMPUSER/100/followme/prering : 0

    Pass on every followme /AMPUSER/xxx on the GUI and click on “Submit”

    Hoping it helps you,

    Jeremy

  2. matt Post author

    Hi Jeremy,

    That’s great, many thanks for the comment. Hopefully that will come in useful for someone and I’ll remember it for next time.

    Cheers, Matt

Comments are closed.