Closed 4oo4 closed 1 year ago
The plugin should parse includes correctly: https://github.com/elcamlost/checkmk-php-fpm-plugin/blob/0d51b85ad5b42c9dccde19fe2b2cf88fe4ee5613/php-fpm/agents/plugins/php_fpm_pools#L141-L152 In particular, the include line you posted is quite standard and works fine on many servers for me.
Can you maybe post you php-fpm.conf as well as www.conf here (redacting possibly identifying or sensitive information)?
Wow, I totally missed that when I read through the code before, sorry.
Before when I was testing, I modified the output like this to print the config files and settings it was finding:
sys.stdout.write('<<<php_fpm_pools>>>\n')
for configfile in discover_fpm():
print(configfile)
for fpm_status in parse_fpm_config(parse_includes(configfile)):
print(fpm_status)
if not fpm_status.get('path'):
continue
try:
fcgi_client = FCGIStatusClient( socket_path = fpm_status.get('socket'), status_path = fpm_status.get('path', '/status') )
fcgi_client.make_request()
fcgi_client.print_status()
except Exception as e:
sys.stderr.write('Exception (%s): %s\n' % (fpm_status.get('socket'), e))
And that output the following:
python3 /usr/lib/check_mk_agent/plugins/php_fpm_pools
<<<php_fpm_pools>>>
/etc/php8/php-fpm.conf
So, this would be what's getting parsed:
php-fpm
command line:
cat /proc/${PID}/cmdline
php-fpm: master process (/etc/php8/php-fpm.conf)
/etc/php8/php-fpm.conf
:
[global]
error_log = log/php8/error.log
include=/etc/php8/php-fpm.d/*.conf
/etc/php8/php-fpm.d/*.conf
ls /etc/php8/php-fpm.d/*.conf
/etc/php8/php-fpm.d/www.conf
./etc/php8/php-fpm.d/www.conf
:
[www]
user = www-data
group = www-data
listen = "/var/run/php-fpm8/php-fpm8.sock"
pm = dynamic
pm.max_children = 40
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 20
pm.status_path = /status
SCRIPT_NAME=/status SCRIPT_FILENAME=/status QUERY_STRING= REQUEST_METHOD=GET cgi-fcgi -bind -connect /var/run/php-fpm8/php-fpm8.sock
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Content-type: text/plain;charset=UTF-8
pool: www process manager: dynamic start time: 16/Nov/2022:04:01:07 -0600 start since: 55409 accepted conn: 19491 listen queue: 0 max listen queue: 0 listen queue len: 0 idle processes: 19 active processes: 1 total processes: 20 max active processes: 35 max children reached: 0 slow requests: 0
Thanks
**EDIT:** I think the culprit is this:
```python
if listen and not listen.startswith('/'):
if 'prefix' in section:
listen = os.path.join(section['prefix'], listen)
else:
# we cannot infer the relative listen anchor
print("we cannot infer the relative listen anchor")
continue
When I add that print statement, I can see it's hitting that else clause. If I'm reading that correctly it's looking for a prefix
setting in my fpm config?
I think the culprit is this:...
I agree.
If I'm reading that correctly it's looking for a prefix setting in my fpm config?
The problem more likely is that ConfigParser doesn't understand quotes (I guess). Try removing the quotes from the listen
path.
Removing the quotes for listen
fixed it, thanks!
I can't get the plugin discover my correct php-fpm config, I'm wondering if it's because the socket config it's looking for is within a second config file.
The plugin is reading the cmdline for the php-fpm process, which is
php-fpm: master process (/etc/php8/php-fpm.conf)
. Then it only seems to be looking within/etc/php8/php-fpm.conf
for thepm.status*
config. However, the actual config for the status monitoring is in/etc/php8/php-fpm.d/www.conf
and the plugin never picks it up.So I think it might just also have to look to see if that main config file has something like
include=/etc/php8/php-fpm.d/*.conf
, then also search within additional files for the necessary config settings. This might just be a quirk of how Alpine does their configs but I think the configs in deb.sury.org repos for other distros are similar.Cheers