Monit and CentOS – Solving the Error “Could not execute systemctl”
My Problem – “Error: Could not execute systemctl”
I’m using Monit 5.16 on a CentOS 7 server. Monit is monitoring some crucial services like Apache and MySQL (okay, okay, it’s MariaDB). I have a very simple service check to start with:
check process apache pidfile /var/run/httpd/httpd.pid
start = “systemctl start httpd.service”
stop = “systemctl stop httpd.service”
restart = “systemctl restart httpd.service”
However, when the service stops, I receive the following error in monit’s log file:
“Error: Could not execute systemctl”
My Solution:
Super simple. So simple it’s derpy. Use an absolute path to systemctl in the service check action. So it should look like this:
check process apache pidfile /var/run/httpd/httpd.pid
start = “/usr/bin/systemctl start httpd.service”
stop = “/usr/bin/systemctl stop httpd.service”
restart = “/usr/bin/systemctl restart httpd.service”
Recent Comments