How to run a shell script before restarting a service in Monit in case of a crashMonit doesn't pick up httpd...

Are paving bricks differently sized for sand bedding vs mortar bedding?

Why is it that I can sometimes guess the next note?

What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?

What does routing an IP address mean?

Non-trope happy ending?

The screen of my macbook suddenly broken down how can I do to recover

A social experiment. What is the worst that can happen?

Has any country ever had 2 former presidents in jail simultaneously?

Can I sign legal documents with a smiley face?

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

What does chmod -u do?

Symbol used to indicate indivisibility

If magnesium reacts with oxygen to produce magnesium oxide only on the application of heat, then why isn't it categorised as an endothermic reaction?

Closed-form expression for certain product

It grows, but water kills it

Loading commands from file

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

Pre-modern battle - command it, or fight in it?

Why does the Sun have different day lengths, but not the gas giants?

Did Swami Prabhupada reject Advaita?

What are the purposes of autoencoders?

dpdt switch to spst switch

How do I color the graph in datavisualization?

Is it improper etiquette to ask your opponent what his/her rating is before the game?



How to run a shell script before restarting a service in Monit in case of a crash


Monit doesn't pick up httpd process after resetmysql monitoring with monitMonit not restarting serviceMonit runs exec action too oftenRestarting shell script with &disown using MonitMonit: How to optimally monitor an URLHow to watch a service with multiple processes with Monit?Awaken monit daemon every few hours for all monitored processesExecute custom monit script upon failure to restart the processMonit run script on restart













1















I am using Monit 5.3.2 in my Linux box. I am monitoring some services using Monit.
I want to run a script before the running the restart command.
I have used the below conditions for the same.



if does not exist for 2 times within 3 cycles then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser

if does not exist for 10 cycles then restart


Unfortunately only the restart action is getting executed.



Can anyone please help me to identify why the first rule is not executed ?
Is there are any other way to solve the problem ?










share|improve this question














bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1















    I am using Monit 5.3.2 in my Linux box. I am monitoring some services using Monit.
    I want to run a script before the running the restart command.
    I have used the below conditions for the same.



    if does not exist for 2 times within 3 cycles then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser

    if does not exist for 10 cycles then restart


    Unfortunately only the restart action is getting executed.



    Can anyone please help me to identify why the first rule is not executed ?
    Is there are any other way to solve the problem ?










    share|improve this question














    bumped to the homepage by Community 3 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      I am using Monit 5.3.2 in my Linux box. I am monitoring some services using Monit.
      I want to run a script before the running the restart command.
      I have used the below conditions for the same.



      if does not exist for 2 times within 3 cycles then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser

      if does not exist for 10 cycles then restart


      Unfortunately only the restart action is getting executed.



      Can anyone please help me to identify why the first rule is not executed ?
      Is there are any other way to solve the problem ?










      share|improve this question














      I am using Monit 5.3.2 in my Linux box. I am monitoring some services using Monit.
      I want to run a script before the running the restart command.
      I have used the below conditions for the same.



      if does not exist for 2 times within 3 cycles then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser

      if does not exist for 10 cycles then restart


      Unfortunately only the restart action is getting executed.



      Can anyone please help me to identify why the first rule is not executed ?
      Is there are any other way to solve the problem ?







      monit






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 23 '12 at 13:33









      SupratikSupratik

      99493259




      99493259





      bumped to the homepage by Community 3 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 3 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          This is not a definitive answer, as I am a newbie currently chasing down a similar problem.



          I currently have a suspicion that the last rule overrides all previous rules.



          If so, try:



          if does not exist for 2 times within 3 cycles 
          then exec "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser
          ELSE if does not exist for 10 cycles then restart





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "2"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f420425%2fhow-to-run-a-shell-script-before-restarting-a-service-in-monit-in-case-of-a-cras%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            This is not a definitive answer, as I am a newbie currently chasing down a similar problem.



            I currently have a suspicion that the last rule overrides all previous rules.



            If so, try:



            if does not exist for 2 times within 3 cycles 
            then exec "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser
            ELSE if does not exist for 10 cycles then restart





            share|improve this answer




























              0














              This is not a definitive answer, as I am a newbie currently chasing down a similar problem.



              I currently have a suspicion that the last rule overrides all previous rules.



              If so, try:



              if does not exist for 2 times within 3 cycles 
              then exec "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser
              ELSE if does not exist for 10 cycles then restart





              share|improve this answer


























                0












                0








                0







                This is not a definitive answer, as I am a newbie currently chasing down a similar problem.



                I currently have a suspicion that the last rule overrides all previous rules.



                If so, try:



                if does not exist for 2 times within 3 cycles 
                then exec "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser
                ELSE if does not exist for 10 cycles then restart





                share|improve this answer













                This is not a definitive answer, as I am a newbie currently chasing down a similar problem.



                I currently have a suspicion that the last rule overrides all previous rules.



                If so, try:



                if does not exist for 2 times within 3 cycles 
                then exec "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser
                ELSE if does not exist for 10 cycles then restart






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 30 '12 at 3:01









                OddthinkingOddthinking

                18215




                18215






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Server Fault!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f420425%2fhow-to-run-a-shell-script-before-restarting-a-service-in-monit-in-case-of-a-cras%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

                    117736 Шеррод Примітки | Див. також | Посилання | Навігаційне...

                    Маріан Котлеба Зміст Життєпис | Політичні погляди |...