April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Monit and CentOS – Solving the Error “Could not execute systemctl”

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”

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>