8000 process_collector.py assumes /proc/self/fd is readable for process_open_fds · Issue #95 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

process_collector.py assumes /proc/self/fd is readable for process_open_fds #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RalphCorderoy opened this issue Aug 18, 2016 · 2 comments

Comments

@RalphCorderoy
Copy link

Apache with prefork MPM, not threaded, runs process_collector.py as the chosen non-root user, but /proc/self/fd/ is still owned by root:root so its 0500 permissions cause an OSError exception, e.errno == EACCES, on the os.listdir() attempt. A patch to give up on that metric when that occurs: process_open_fds.txt

@hedgepigdaniel
Copy link

So annoying, also an issue with Ubuntu 12.04 built in uwsgi init.d service.

I assume this is a problem whenever uwsgi does its own priviledge deescalation

https://unix.stackexchange.com/questions/75045/files-in-proc-pid-e-g-ssh-agent-chrome-are-not-owned-by-user-but-by-root

When used in https://github.com/korfuri/django-prometheus the stacktrace looks like this:

Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "/home/engine/venv/local/lib/python2.7/site-packages/prometheus_client/exposition.py", line 86, in do_GET
    output = generate_latest(registry)
  File "/home/engine/venv/local/lib/python2.7/site-packages/prometheus_client/exposition.py", line 63, in generate_latest
    for metric in registry.collect():
  File "/home/engine/venv/local/lib/python2.7/site-packages/prometheus_client/core.py", line 97, in collect
    for metric in collector.collect():
  File "/home/engine/venv/local/lib/python2.7/site-packages/prometheus_client/process_collector.py", line 84, in collect
    len(os.listdir(os.path.join(pid, 'fd'))))
OSError: [Errno 13] Permission denied: '/proc/self/fd'

@hedgepigdaniel
< 9F42 details-menu class="dropdown-menu dropdown-menu-sw show-more-popover color-fg-default" style="width:185px" src="" preload > Copy link

Thanks @RalphCorderoy for the patch, it fixed the problem for me (I assume at the expense of file handle information) - I committed it here if anyone wants to try it: https://github.com/prometheus/client_python/compare/master...hedgepigdaniel:ignore-fd-permissions?expand=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0