November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

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>