2 Replies Latest reply on Dec 17, 2014 7:21 AM by Sae Park

    Create a smart group based on a running process

    Sae Park

      Hi,

      I'm trying to create a smart groups based on a running process.

      For example, I want to create a smart group called "Web Servers" that contains all the servers that's running httpd process.

      What is the best way to go about it?

      Thanks in advance.

        • 1. Re: Create a smart group based on a running process
          Monoj Padhy

          This could be done in multiple ways. Since your are looking for if httpd is running, service httpd status must do for you.

           

          Approach1:

          1. create a NSH script and see if the httpd service is running and then accordingly update a specific server property say httpd_status(Use an existing one or create a new property from property dictionary view)

          2. create a server smart group w/ matching criteria like SERVER  httpd_status equals running.

           

          Approach2:

          1 Create an extended object.

          2. Now create an component template and validate httpd status in discovery condition.

          3. Create smart group based on the basis of components created.

           

          Below sample code(NSH script) that may help you.

           

          #!/bin/nsh

          # ####################################################################

          #

          # Use the – “name=value(nsvp.gm)” grammar when displaying results

           

          cd //$1

          httpd_stat=`nexec -i -e service httpd status`

           

          if [[ $httpd_stat != '' ]]

          then

          echo httpd_Status=$httpd_stat

          fi

          exit 0

           

          HTH

          • 2. Re: Create a smart group based on a running process
            Sae Park

            Thanks, Monoj!

             

            I decided to go with approach #2.

             

            I created a component that looks for httpd processes (to catch Apache and any other type of web servers) and created a smart group based on that.

            For other people who might have similar question, I created a smart group then I picked TEMPLATES.* contains component I created.

             

            Thanks again!