hipages / php-fpm_exporter

A prometheus exporter for PHP-FPM.
Apache License 2.0
604 stars 123 forks source link

Can not Connect latest version using socket #46

Closed anishvarghese closed 5 years ago

anishvarghese commented 5 years ago

Getting this issue while connect using socket

root@php:/opt/phpexporter1.0.0# ./php-fpm_exporter server --phpfpm.scrape-uri unix:///var/run/php5-fpm.sock;/status


INFO[0000] Starting server on :9253 with path /metrics
ERRO[0012] Pool[unix:///var/run/php5-fpm.sock]: Access denied.
ERRO[0012] invalid character 'A' looking for beginning of value
ERRO[0012] Error scraping PHP-FPM: invalid character 'A' looking for beginning of value```
estahn commented 5 years ago

@anishvarghese Can you please run it like this:

root@php:/opt/phpexporter1.0.0# ./php-fpm_exporter server --phpfpm.scrape-uri 'unix:///var/run/php5-fpm.sock;/status'
anishvarghese commented 5 years ago

What a great support Sir, Getting lot of metrics but showing this error root@php:/opt/phpexporter1.0.0# ./php-fpm_exporter server --phpfpm.scrape-uri 'unix:///var/run/php5-fpm.sock;/status' INFO[0000] Starting server on :9253 with path /metrics ERRO[0004] Inconsistent active and idle processes reported. Set --fix-process-count to have this calculated by php-fpm_exporter instead.

anishvarghese commented 5 years ago

root@php:/opt/phpexporter1.0.0# ./php-fpm_exporter server --phpfpm.scrape-uri 'unix:///var/run/php5-fpm.sock;/status' --phpfpm.fix-process-count . It helped me

estahn commented 5 years ago

I should probably change this to a warning instead of an error.

See details here https://github.com/hipages/php-fpm_exporter#why---phpfpmfix-process-count

estahn commented 5 years ago

@anishvarghese I will close this issue. If you need further help please feel free to reopen it.

wsilva commented 5 years ago

Can we reopen?

I am running version 1.0.0 from the exporter and php-fpm version 5.6.38 both running locally.

PHP version:


$ php-fpm5.6 -v
PHP 5.6.38-1+ubuntu14.04.1+deb.sury.org+2 (fpm-fcgi)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Exporter version:

$ /usr/local/bin/php-fpm-exporter version
php-fpm_exporter 1.0.0, commit e34cefc91b6ed545aa97c3bf40d17b16e8a07f6c, built at 2018-12-30T23:44:42

Running the server using www-data user and the socket file ownership and permissions:

$ whoami
www-data
$ ls -la /var/run/php5.6-fpm.sock
srw-rw---- 1 www-data www-data 0 Jun 18 20:27 /var/run/php5.6-fpm.sock
$ /usr/local/bin/php-fpm-exporter server --web.listen-address ':9999' --phpfpm.scrape-uri 'unix:///var/run/php5.6-fpm.sock;/status'
INFO[0000] Starting server on :9999 with path /metrics
ERRO[0006] Pool[unix:///var/run/php5.6-fpm.sock;/status]: Access denied.
ERRO[0006] invalid character 'A' looking for beginning of value
ERRO[0006] Error scraping PHP-FPM: invalid character 'A' looking for beginning of value
ERRO[0010] Pool[unix:///var/run/php5.6-fpm.sock;/status]: Access denied.
ERRO[0010] invalid character 'A' looking for beginning of value
ERRO[0010] Error scraping PHP-FPM: invalid character 'A' looking for beginning of value

Trying to scrape with:

$ curl -s http://localhost:9999/metrics | grep phpfpm
# HELP phpfpm_scrape_failures The number of failures scraping from PHP-FPM.
# TYPE phpfpm_scrape_failures counter
phpfpm_scrape_failures{pool=""} 2
# HELP phpfpm_up Could PHP-FPM be reached?
# TYPE phpfpm_up gauge
phpfpm_up{pool=""} 0

Trying to use get:

$ /usr/local/bin/php-fpm-exporter get --phpfpm.scrape-uri 'unix:///var/run/php5.6-fpm.sock;/status'
ERRO[0000] Pool[unix:///var/run/php5.6-fpm.sock;/status]: Access denied.
ERRO[0000] invalid character 'A' looking for beginning of value
Address:                unix:///var/run/php5.6-fpm.sock;/status
Pool:
Start time:             Mon, 01 Jan 0001 00:00:00 +0000
Start since:            0
Accepted connections:   0
Listen Queue:           0
Max Listen Queue:       0
Listen Queue Length:    0
Idle Processes:         0
Active Processes:       0
Total Processes:        0
Max active processes:   0
Max children reached:   0
Slow requests:          0

The php-fpm proccess

$ ps aux | grep php-fpm | grep master
root     26460  0.0  1.4 352284 29420 ?        Ss   Jun18   0:03 php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)

And it's configuration:

$ cat /etc/php/5.6/fpm/php-fpm.conf | grep '^[^;]'
[global]
pid = /var/run/php5.6-fpm.pid
error_log = /var/log/php5.6-fpm.log
include=/etc/php/5.6/fpm/pool.d/*.conf
$ cat /etc/php/5.6/fpm/pool.d/*.conf | grep '^[^;]'
[www]
user = www-data
group = www-data
listen = /var/run/php5.6-fpm.sock
listen.backlog = 65535
listen.owner = www-data
listen.group = www-data
# PHP-FPM worker pool tuning
pm = static
pm.max_children = 1
pm.max_requests = 20000
shipilovds commented 4 years ago

Hello! I have the same issue, but with tcp

$ docker exec -it php-fpm_exporter ./php-fpm_exporter get --phpfpm.scrape-uri "tcp://backend:9001/status"
ERRO[0000] Pool[tcp://backend:9001/status]: Access denied. 
ERRO[0000] invalid character 'A' looking for beginning of value 
Address:                tcp://backend:9001/status      
Pool:                                                  
Start time:             Mon, 01 Jan 0001 00:00:00 +0000
Start since:            0                              
Accepted connections:   0                              
Listen Queue:           0                              
Max Listen Queue:       0                              
Listen Queue Length:    0                              
Idle Processes:         0                              
Active Processes:       0                              
Total Processes:        0                              
Max active processes:   0                              
Max children reached:   0                              
Slow requests:          0
$ docker exec -it php-fpm_exporter ./php-fpm_exporter version
php-fpm_exporter 1.0.0, commit e34cefc91b6ed545aa97c3bf40d17b16e8a07f6c, built at 2018-12-30T23:44:42Z

"Access denied" - what exactly this message about?

Should I open new issue or we can reopen this one?

ebuildy commented 4 years ago

@shipilovds how is your "php-fpm.conf" configured?

bussnet commented 4 years ago

For me the Access Denied comes from a non-standard pm.status_path setting in the pool conf:

pm.status_path = /php5/status

So I need to add this path instead of /status to the uri. Seems so easy and clear... afterwards 🤦

zhaozhenxiang commented 2 years ago
su -s /bin/bash -c '/tmp/php-fpm_exporter server --phpfpm.fix-process-count --phpfpm.scrape-uri "unix:///dev/shm/php-cgi.sock;/php-fpm_status"' www

May help.