Skip to content
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

Getting permission denied when using unix socket #38

Open
Jacketbg opened this issue Nov 17, 2019 · 3 comments
Open

Getting permission denied when using unix socket #38

Jacketbg opened this issue Nov 17, 2019 · 3 comments

Comments

@Jacketbg
Copy link

Jacketbg commented Nov 17, 2019

Hi,
I'm starting the exporter like this:
/usr/bin/php-fpm-exporter --addr :8080 --fastcgi unix://var/run/php5-fpm.sock
The socket address is valid and nginx is connecting to it. There are no permission issues for sure and I'm even starting the exporter as root and getting the same error. Here's the error:

Nov 17 10:42:40 www php-fpm-exporter: {"level":"error","ts":1573980160.078672,"msg":"failed to get php-fpm status","error":"fastcgi dial failed: dial unix var: connect: permission denied","errorVerbose":"dial unix var: connect: permission denied\nfastcgi dial failed\ngithub.com/bakins/php-fpm-exporter.getDataFastcgi\n\t/root/go/src/github.com/bakins/php-fpm-exporter/collector.go:86\ngithub.com/bakins/php-fpm-exporter.(*collector).Collect\n\t/root/go/src/github.com/bakins/php-fpm-exporter/collector.go:148\ngithub.com/bakins/php-fpm-exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2\n\t/root/go/src/github.com/bakins/php-fpm-exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:433\nruntime.goexit\n\t/usr/lib/golang/src/runtime/asm_amd64.s:2197"}

I tried chmodding the socket to 777 just to rule out real permission issues.
The status page is configured at /status and I can open it via nginx.
I can connect via tcp, but the pool I want to monitor uses unix socket and I don’t want to change it.

Can you please give me some pointers? Thanks!

@nvanheuverzwijn
Copy link

@Jacketbg
What does ls -l /var/run/php5-fpm.sock looks like ? Even if you chmod 777 the socket, I think you still need rx on parent directory (/var and /var/run) for it to be able to reach the socket file.

What user is php-fpm-exporter is running as ? If you run it with root, does it work ? If it doesn't work with root, maybe the socket is not where you think it is ?

@2knarf
Copy link

2knarf commented Oct 7, 2021

Same issue here even when running as root, I know the socket is OK, because PHP is running from the same socket.
./php-fpm_exporter_2.0.3_linux_amd64 get --phpfpm.scrape-uri unix:///var/run/admin2.sock
ERRO[0000] Pool[unix:///var/run/admin2.sock]: Access denied.
ERRO[0000] invalid character 'A' looking for beginning of value
ERRO[0000] invalid character 'A' looking for beginning of value

root@:~# ls -al /var/run/admin2.sock
srw-rw---- 1 a a 0 Oct 7 12:34 /var/run/admin2.sock

@2knarf
Copy link

2knarf commented Oct 7, 2021

Hi, I'm starting the exporter like this: /usr/bin/php-fpm-exporter --addr :8080 --fastcgi unix://var/run/php5-fpm.sock The socket address is valid and nginx is connecting to it. There are no permission issues for sure and I'm even starting the exporter as root and getting the same error. Here's the error:

Nov 17 10:42:40 www php-fpm-exporter: {"level":"error","ts":1573980160.078672,"msg":"failed to get php-fpm status","error":"fastcgi dial failed: dial unix var: connect: permission denied","errorVerbose":"dial unix var: connect: permission denied\nfastcgi dial failed\ngithub.com/bakins/php-fpm-exporter.getDataFastcgi\n\t/root/go/src/github.com/bakins/php-fpm-exporter/collector.go:86\ngithub.com/bakins/php-fpm-exporter.(*collector).Collect\n\t/root/go/src/github.com/bakins/php-fpm-exporter/collector.go:148\ngithub.com/bakins/php-fpm-exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2\n\t/root/go/src/github.com/bakins/php-fpm-exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:433\nruntime.goexit\n\t/usr/lib/golang/src/runtime/asm_amd64.s:2197"}

I tried chmodding the socket to 777 just to rule out real permission issues. The status page is configured at /status and I can open it via nginx. I can connect via tcp, but the pool I want to monitor uses unix socket and I don’t want to change it.

Can you please give me some pointers? Thanks!

Try this:

./php-fpm_exporter_2.0.3_linux_amd64 get --phpfpm.scrape-uri "unix:///var/run/admin2.sock;/status"
Address: unix:///var/run/admin2.sock;/status
Pool: admin2
Start time: Thu, 07 Oct 2021 12:42:19 +0200
Start since: 620
Accepted connections: 13
Listen Queue: 0
Max Listen Queue: 0
Listen Queue Length: 0
Idle Processes: 4
Active Processes: 1
Total Processes: 5
Max active processes: 1
Max children reached: 0
Slow requests: 0

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

3 participants