I have a monitoring agent called scollector that is using more cpu on our loadbalancer. Perf says the CPU is mostly due to __d_lookup
. One of the things I monitor is the number of open file handles - I do this via the following code:
fds, e := ioutil.ReadDir("/proc/" + pid + "/fd")
if e != nil {
w.Remove(pid)
continue
}
...
Add(md, "linux.proc.num_fds", len(fds), tags, metadata.Gauge, metadata.Files, descLinuxProcFd)
When I strace the process, I see it calling lstat
on every file in the /fd
directory (which is going to be a lot for our active load balancer (at least .5 million fds) - so I hypothesizing that this is the source of the high dentry cache cpu usage for the process.
Anyone have a suggestion on a better way to do this?