Applicable to:
- Plesk for Linux
Question
How to monitor the additional Plesk PHP-FPM services in Watchdog?
Answer
Currently, the Watchdog extension only monitors the OS PHP-FPM service and it is not possible to manage the monitoring for the additional Plesk PHP-FPM services.
Vote and comment on this feature request from our Official Plesk UserVoice channel as top-voted suggestions are likely to be included in future Plesk versions.
As a workaround, enable the Watchdog monitoring for the additional Plesk PHP-FPM services manually:
Note: The monitoring configuration will be listed in Plesk GUI but it cannot be managed. Notice that the maximum number of items that are listed in Plesk GUI is 25.
-
Connect to the server via SSH
-
Retrieve the additional Plesk PHP-FPM handlers that are being used:
# plesk db -Ne "SELECT php_handler_id FROM hosting WHERE php = 'true'" | sort | uniq
plesk-php74-fpm -
Find the PID location for the service:
# grep pid /opt/plesk/php/7.4/etc/php-fpm.conf
pid = /run/plesk-php74-fpm.pid -
Create a Watchdog template file with all the parameters:
Warning: The bold values have to be updated with the respective Plesk PHP-FPM handler name and PID location
# cat /usr/local/psa/etc/modules/watchdog/service.tpl.d/plesk-php74-fpm
check process plesk-php74-fpm
with pidfile /run/plesk-php74-fpm.pid
start = "/usr/local/psa/admin/bin/phpinimng --type fpm --start --service-name plesk-php74-fpm"
stop = "/usr/local/psa/admin/bin/phpinimng --type fpm --stop --service-name plesk-php74-fpm"
if 5 restarts within 5 cycles then timeout
every 1 cycles
mode active -
Back up Plesk database:
# plesk db dump psa > psa.backup.sql
-
Create a record in the
module_watchdog_service
table:Warning: The bold values have to be updated with the respective Plesk PHP-FPM handler name
# plesk db "INSERT INTO psa.module_watchdog_service (name,label,sort_val,mon_status,start_cmd,stop_cmd) VALUES ('plesk-php74-fpm','Plesk PHP-FPM 7.4', 140, 'monitored', '/usr/local/psa/admin/bin/phpinimng --type fpm --start --service-name plesk-php74-fpm','/usr/local/psa/admin/bin/phpinimng --type fpm --stop --service-name plesk-php74-fpm')"
-
Recreate Watchdog configuration with a full restart to apply the changes:
# /usr/local/psa/admin/bin/modules/watchdog/wd --full-restart
-
Going to Plesk > Extensions > My Extensions > Watchdog, the additional Plesk PHP-FPM service will be listed, but mind that it cannot be disabled or enabled from Plesk GUI:
If it's required to rollback the changes, run the following comands:
Warning: The bold value is the parameter used in the article
# rm /usr/local/psa/etc/modules/watchdog/service.tpl.d/plesk-php74-fpm
# plesk db "DELETE FROM psa.module_watchdog_service WHERE name = 'plesk-php74-fpm'"
# /usr/local/psa/admin/bin/modules/watchdog/wd --full-restart
Comments
3 comments
Marc Vidal Honestly, this is a joke. Multiple PHP versions is a core feature of Plesk and as you already outline in this article, the problem can easily be fixed by Plesk. Is it really too much to expect, that other modules such as watchdog are properly updated when new features are introduced? Ridiculous that we should file a feature request. This is a sloppy implementation that needs to be fixed!
At least there is this easy workaround. Works like a charm! 👌
Marc Vidal so what are the differences between the start and stop commands given in the config file and that need to be entered in the database?
As /opt/psa/etc/modules/watchdog/monitrc contains the line
INCLUDE "/opt/psa/etc/modules/watchdog/services.d/*"
and as the template file gets copied into that location, I would assume that the start and stop commands for the database are not required? Or could they be used to replace parts in the template file? If so, how?
Also: As this is interesting to monitor additional services, it would really help (and solve vulnerabilities) if the outdated monit version 4.6 (from 2005!!) gets replace with a more recent one (e.g. 5.27). For instance, many new services in Ubuntu do not work with PID files any more (so you would need to check with 'check program <name> with path "/bin/systemctl --quiet is active servicename.service"' instead of "check process <name> with pidfile <filename>"). However, it seems that version 4.6 does not allow this.
Please sign in to leave a comment.