Samba: troubleshooting smb taking 100% cpu but no samba activity

Title:Troubleshooting smb taking 100% cpu but no samba activity
Author:Douglas O’Leary <dkoleary@olearycomputers.com>
Description:How to troubleshoot smbd taking 100% of cpu w/no samba activity
Date created:07/2014
Date updated:07/2014
Disclaimer:Standard: Use the information that follows at your own risk. If you screw up a system, don’t blame it on me...

Problem;

Situation: System rebooted for non-related reasons. When it comes back, everything’s operational; but, smbd and winbind are taking 100% of a cpu each and smbstatus shows no activity.

What’s eating the cpu?

Solution:

Thanks to this url, I found the problem fairly quickly as a corrupted tdb file. Finding out which tdb file to remove, though, is the interesting bit.

  1. find out where the tdb files are. Mine are under /var/lib/samba. /var/cache/samba might be another potential.

  2. Run the following inline script:

    for f in *.tdb
    do
        echo ${f}
        tdbbackup -v ${f}
    done
    account_policy.tdb
    account_policy.tdb : 17 records
    brlock.tdb
    brlock.tdb : 0 records
    connections.tdb
    connections.tdb : 4 records
    gencache.tdb
    gencache.tdb : 93 records
    locking.tdb
    locking.tdb : 0 records
    messages.tdb
    messages.tdb : 0 records
    mutex.tdb
    mutex.tdb : 0 records
    netsamlogon_cache.tdb
    restoring netsamlogon_cache.tdb
    netsamlogon_cache.tdb.bak: No such file or directory
    notify.tdb
    notify.tdb : 0 records
    ntdrivers.tdb
    ntdrivers.tdb : 1 records
    ntforms.tdb
    ntforms.tdb : 0 records
    ntprinters.tdb
    ntprinters.tdb : 1 records
    registry.tdb
    registry.tdb : 90 records
    sessionid.tdb
    sessionid.tdb : 0 records
    share_info.tdb
    share_info.tdb : 1 records
    unexpected.tdb
    unexpected.tdb : 7 records
    winbindd_cache.tdb
    winbindd_cache.tdb : 70 records
    winbindd_idmap.tdb
    winbindd_idmap.tdb : 71 records
    
The tdbbackup command will hang on a corrupted tdb file. In my case, it was the gencache.tdb. Moved it out of the way and everything was good.
  1. Remove the corrupted file and restart samba

Once done, smbd should go back to just sucking wind instead of sucking up all of your cpu cycles...