opendirectoryd consumes 40% of CPU

23

19

I have a MacBook Pro with Lion 10.7.2, 2.26 GHz CPU and 2GB DDR3 RAM.

If I call

top -o cpu

the /usr/libexec/opendirectoryd process consumes more than 40% of CPU.

$ ps aux | grep opend                                                                       
root 27834 40,4 0,3 2472048 5780 ?? Rs 6:36PM 167:19.66 /usr/libexec/opendirectoryd

enter image description here

juanpablo

Posted 2011-10-26T18:17:24.450

Reputation: 5 216

@slhck /usr/libexec/opendirectoryd – juanpablo – 2011-10-26T20:55:38.887

Answers

23

The problem is related to the dead symlinks in Dropbox. Find them using:

find ~/Dropbox -type l -printf "%Y %p\n" | grep "^N"

The solution is: Remove the dead symlinks. If find doesn't have the printf option, use:

find -L ~/Dropbox -type l

References

To find dead symlinks

juanpablo

Posted 2011-10-26T18:17:24.450

Reputation: 5 216

BSD version of the find command that list broken symlinks: find '~/Dropbox' -type l -print0 | xargs -0 file | grep broken – Piotr Czapla – 2015-09-18T11:30:35.887

finding broken links with test should work everywhere: find ~/Dropbox -type l ! -exec test -e {} \; -print. Then if you like the looks of the output you can add -delete to remove them. – spinup – 2020-01-14T19:00:22.123

Wonder how you got the first solution to work with the BSD find in OS X. You have to at least install GNU findutils for getting the printf option. – slhck – 2012-03-11T12:35:38.217

I have installed findutils

find --version                                              13:17
find (GNU findutils) 4.4.2
 – juanpablo  – 2012-03-11T17:21:17.983

Okay, well it doesn't ship with OS X so that command you used wouldn't have worked. – slhck – 2012-03-11T17:43:27.620

11

As mentioned by @juanpablo, this may be caused by symlinks.

Apparently, if a symlink points to /home, autofs or automountd fire and take a lot of CPU to figure out that the place indeed doesn't exist.

Take a look at /etc/auto_home and /etc/autofs.conf.

To see if you're being hit by this particular problem, set

AUTOMOUNTD_VERBOSE=TRUE

option in autofs.conf, restart automountd

sudo launchctl stop com.apple.automountd

and review the syslog.log (you may use application: Console). You're affected by this problem if you see something like that:

May 20 17:53:43 xxx automountd[31709]: od_search failed

To workaround, edit the file /etc/auto_master and remove (or hash out #) the line starting with /home. Then run:

sudo automount -vc

Marek

Posted 2011-10-26T18:17:24.450

Reputation: 211

1Thank you, this solved my problem as well, and it was related to Dropbox - I had some dead links pointing to /home in my Dropbox folder (leftover backups from previous systems) that were causing this behavior. Disabling /home in auto_home fixed it. – Diego Zamboni – 2014-08-21T14:06:30.680

1

For me what really solved it was unplugging ethernet cable from my iMac. Crazy as it sounds :) I was being attacked from outside, bruteforce on my sshd. The router I have (from UPC, Cisco EPC3925) by default forwards all the traffic from outside to the single ethernet port it has. By unplugging the cable the attack stopped as the iMac was left on WiFi only.

Apparently sshd is using opendirectoryd and that's why this was happening.

skrat

Posted 2011-10-26T18:17:24.450

Reputation: 171