ncabatoff / process-exporter

Prometheus exporter that mines /proc to report on selected processes
MIT License
1.67k stars 265 forks source link

namedprocess_namegroup_worst_fd_ratio doesn't seem to work properly #268

Closed jsfrerot closed 1 year ago

jsfrerot commented 1 year ago

When I wanted to test if the alert works well, I created this small script to open as many files as it can:

#!/usr/bin/env python3
import time

files = [] 

try:
    for f in range(1, 1025):
        fh = open("test-{0}".format(f), "w")
        print ("Opened file number ...", f)
        files.append(fh)
except IOError as e:        
    print ("IOError: ", str(e))
    input("Press any key to exit")

so while running this script, the output is as follow:

...
Opened file number ... 1020
Opened file number ... 1021
IOError:  [Errno 24] Too many open files: 'test-1022'
Press any key to exit

but the exporter doesn't report any openfile for the python3 process, and namedprocess_namegroup_worst_fd_ratio indicates 0

[jsfrerot@jsfrerot-lnx ~]$ curl -s 'http://yul-debrepo-001.ludia.me:9256/metrics' | grep python3 | egrep 'worst|open_filedesc'
namedprocess_namegroup_open_filedesc{groupname="python3"} 0
namedprocess_namegroup_worst_fd_ratio{groupname="python3"} 0

running lsof on the server returns

[jsfrerot@yul-debrepo-001 ~]$ lsof | grep python3 | wc -l
1037
jsfrerot commented 1 year ago

Nevermind, simply have to run the exporter as root...