1 Reply Latest reply on Dec 20, 2016 5:30 PM by akhasheni

    Monitor a linux service  and respond to output of a command

    robinsons05661

      I have a service, sssd, that keeps dying on two  Linux servers. While I am waiting to resolve that, I would like to be able to monitor the output of the command:

       

      service sssd status

       

      With the following actions

       

      1) if the word "running" is in the result, set condition up

      2) if the word "down" is in the result, set condition down

      3) if the word "dead" is in the result, run the command "service sssd restart"

       

      When the service dies, if I login and run the above command, I get the result:

       

      [root@dwdataaccm1 ~]# service sssd status

      sssd dead but subsys locked

      [root@dwdataaccm1 ~]# service sssd restart

      Stopping sssd: cat: /var/run/sssd.pid: No such file or directory

                                                                 [FAILED]

      Starting sssd:                                             [  OK  ]

      [root@dwdataaccm1 ~]#

       

      I would like to use Orion to manage this while we try to find the root cause. Can anyone help? I have searched already and find lots of posts, but none that seem to use the service command, and I don't know perl well enough to modify the existing samples.

       

      Thanks.

        • Re: Monitor a linux service  and respond to output of a command
          akhasheni

          I have a service, sssd, that keeps dying on two  Linux servers. While I am waiting to resolve that, I would like to be able to monitor the output of the command:

           

          service sssd status

           

          With the following actions

           

          1) if the word "running" is in the result, set condition up

          2) if the word "down" is in the result, set condition down

          3) if the word "dead" is in the result, run the command "service sssd restart"

           

          Same question here and this is what I understand thus far:

          1. the only way to do what you need is to use a "Linux/Unix Script Monitor" available via "Server and Application Monitor" (SAM) product - which is separate from NPM.
          2. this would involve writing a short script that runs a "service status" status command and captures the output
          3. restarting a service would involve creating an alert where a "trigger" action is a script

          (I wish this was as simple as with Windows services)