prometheus / procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Apache License 2.0
769 stars 319 forks source link

Feature request: procfs TotalFileDescriptorsLen #577

Closed BinSquare closed 6 months ago

BinSquare commented 1 year ago

Often times when debugging for a fd leak - it is not clear which process is the root cause of such leak and having the exact count instance wide would be really helpful.

The implementation can be done fairly straight-forwardly using fs.AllProcs() and proc.FileDescriptorsLen() that looks something like below in https://github.com/prometheus/procfs/blob/ff0ad85f7e8bcd5c677d99143f14a2a3aab533aa/proc.go#L245:

ps, err := fs.AllProcs() // this is a list of processes

sum = 0

for _, process := range ps {

c, err := process.FileDescriptorsLen()

sum += c
}

Can implement it if procfs team thinks it's worthwhile to be part of the project

dswarbrick commented 11 months ago

This can already be accomplished with process-exporter: https://github.com/ncabatoff/process-exporter#open_filedesc-gauge

BinSquare commented 11 months ago

@dswarbrick For sure. Is it reasonable to consider that an additional data point for incorporating such feature into procfs itself?

discordianfish commented 10 months ago

Seems trivial enough to implement in the caller, don't feel like we need to implement that here

rexagod commented 6 months ago

ACK, in that case, I think this can be closed now.