{"id":6119,"date":"2016-07-31T17:43:04","date_gmt":"2016-07-31T09:43:04","guid":{"rendered":"http:\/\/rmohan.com\/?p=6119"},"modified":"2016-07-31T17:43:04","modified_gmt":"2016-07-31T09:43:04","slug":"monit-and-centos-solving-the-error-could-not-execute-systemctl","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6119","title":{"rendered":"Monit and CentOS \u2013 Solving the Error \u201cCould not execute systemctl\u201d"},"content":{"rendered":"<p>Monit and CentOS \u2013 Solving the Error \u201cCould not execute systemctl\u201d<\/p>\n<p>My Problem \u2013 \u201cError: Could not execute systemctl\u201d<\/p>\n<p>I\u2019m using Monit 5.16 on a CentOS 7 server. Monit is monitoring some crucial services like Apache and MySQL (okay, okay, it\u2019s MariaDB). I have a very simple service check to start with:<br \/>\ncheck process apache pidfile \/var\/run\/httpd\/httpd.pid<br \/>\n  start = &#8220;systemctl start httpd.service&#8221;<br \/>\n  stop = &#8220;systemctl stop httpd.service&#8221;<br \/>\n  restart = &#8220;systemctl restart httpd.service&#8221;<\/p>\n<p>However, when the service stops, I receive the following error in monit\u2019s log file:<br \/>\n&#8220;Error: Could not execute systemctl&#8221;<\/p>\n<p>My Solution:<\/p>\n<p>Super simple. So simple it\u2019s derpy. Use an absolute path to systemctl in the service check action. So it should look like this:<br \/>\ncheck process apache pidfile \/var\/run\/httpd\/httpd.pid<br \/>\n  start = &#8220;\/usr\/bin\/systemctl start httpd.service&#8221;<br \/>\n  stop = &#8220;\/usr\/bin\/systemctl stop httpd.service&#8221;<br \/>\n  restart = &#8220;\/usr\/bin\/systemctl restart httpd.service&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Monit and CentOS \u2013 Solving the Error \u201cCould not execute systemctl\u201d<\/p>\n<p>My Problem \u2013 \u201cError: Could not execute systemctl\u201d<\/p>\n<p>I\u2019m using Monit 5.16 on a CentOS 7 server. Monit is monitoring some crucial services like Apache and MySQL (okay, okay, it\u2019s MariaDB). I have a very simple service check to start with: check process apache [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6119"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6119"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6119\/revisions"}],"predecessor-version":[{"id":6120,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6119\/revisions\/6120"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}