Php-fpm check ubuntu

Hi there,

I’m trying to set up a check for php-fpm.

I created a new file with the content of https://raw.githubusercontent.com/elcamlost/checkmk-php-fpm-plugin/master/php-fpm/agents/plugins/php_fpm_pools

vi /usr/lib/check_mk_agent/plugins/php-fpm-check

chmod +x php-fpm-check

./php-fpm-check

get this error:
image

When I create the file php_fpm_pools.cfg in /etc/check_mk I get this error

Traceback (most recent call last):
File "./php-fpm-check", line 140, in <module>
execfile(config_file)
File "/etc/check_mk/php_fpm_pools.cfg", line 1
php-fpm = [
SyntaxError: can't assign to operator

php_fpm_pools.cfg

php_fpm = [
{"socket": ("localhost", 9000)},
{"socket": "/var/run/php/php7.4-fpm.sock", "path": "/fpm_status"},
]

I think my php_fpm_pools.cfg is wrong? Can someone help me out?
Thanks in advance!

Tim

First check if your curl http://localhost:9000/fpm_status works…If this is not reachable then you have to fix this or else remove this. For example:

# curl http://localhost/status
pool:                 www
process manager:      dynamic
start time:           06/Jan/2021:00:34:55 +0100
start since:          1419
accepted conn:        96
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       1
active processes:     1
total processes:      2
max active processes: 2
max children reached: 0
slow requests:        0
 #  cat /etc/check_mk/php_fpm_pools.cfg 
php_fpm = [
 {"socket": "/var/run/php/php7.4-fpm.sock", "path": "/status"},
]

/usr/lib/check_mk_agent/plugins# ./php_fpm_pools
<<<php_fpm_pools>>>
www dynamic active_processes 1
www dynamic accepted_conn 102
www dynamic listen_queue 0
www dynamic start_since 1466
www dynamic idle_processes 1
www dynamic start_time 1609889695
www dynamic slow_requests 0
www dynamic max_active_processes 2
www dynamic max_children_reached 0
www dynamic max_listen_queue 0
www dynamic total_processes 2
www dynamic listen_queue_len 0

curl http://localhost:9000/fpm_status returns a connection refused message.

I removed {“socket”: (“localhost”, 9000)} in my php_fpm_pools.cfg

But I get the same error as before when I try to execute: ./php-fpm-check

Could it be because the path “/fpm_status” is not correct? How can I find out the correct path?

I also got 2 .sock files. Which should I add to the .cfg?

image

And then what do you get with
curl http://localhost/status ?

You first need to fix both of these URL’s and then use the config accordingly.

I get this:

root@SWEBKO24:~# curl http://localhost/status
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://stats.mgc.ag/status">here</a>.</p>
<hr>
<address>Apache/2.4.46 (Ubuntu) Server at localhost Port 80</address>
</body></html>

I’m not sure how to fix it… :confused:

This is how I set it up. Just refer this https://www.iditect.com/how-to/58417074.html and figure it out. It works for me on my Ubuntu 20.04 and 18.04

  1. Within /etc/php-fpm.d/www.conf, I have the following config options set for listen sock below and uncommented out:

listen = /var/run/php-fpm.sock

pm.status_path = /fpm-status

  1. With my apache config php-latest.conf (or similar) I added a match that looked for fpm-status and set it to proxypass to the unix socket and run the fpm-status from fcgi. It also restricts it so only localhost can call it:

<LocationMatch “/fpm-status”>
Order Allow,Deny
Allow from 127.0.0.1
ProxyPass unix:/var/run/php-fpm.sock|fcgi://localhost/fpm-status

  1. Just simply run the curl command locally:

    $ curl http://localhost/fpm-status
    pool: www
    process manager: dynamic
    start time: 16/Oct/2019:11:33:25 -0400
    start since: 14
    accepted conn: 12
    listen queue: 0
    max listen queue: 0
    listen queue len: 0
    idle processes: 38
    active processes: 2
    total processes: 40
    max active processes: 5
    max children reached: 0
    slow requests: 0

1 Like

OK thanks for your help and the link to the how to. I will try tomorrow and keep this thread updated

Hey Tim197
Have you fixed this? For me it’s working with this:

php_fpm = [
{“socket”: “/var/run/php/php7.4-fpm.sock”, “path”: “/fpmstatus”},
{“socket”: “/var/run/php/php-fpm-ftp-host.sock”, “path”: “/fpmstatus”},
]

Greetz

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.