6 Replies Latest reply on May 6, 2013 10:17 AM by mitch_reid

    Client Task

    mitch_reid

      I see to use the API to run a client task I use: clienttask.run names productId taskId

       

      I need a script to run on multiple servers. And it's my understanding productid and taskid will be unique per server?

       

      How do I query the productid and taskid to be able to use a single script across many servers? Always same product and client task name.

       

      Thanks

        • 1. Re: Client Task
          jking

          Mitch I think you'll have to use clienttask.find first.  Ie something like this:

           

          https://epodemo:8443/remote/clienttask.find?searchText=<Task Name>&:output=terse

           

          The output should have a object ID column; in your script find the id first, and then use it in the subsequent call to run the task. On my demo server I did:

           

          https://epodemo:8443/remote/clienttask.find?searchText=Collect&:output=terse

           

          and got:

           

          OK:

          objectId objectName               productId    productName   typeId typeName                            

          -------- ------------------------ ------------ ------------- ------ -------------------------------------

          6        Collect All              EPOAGENTMETA McAfee Agent  4      McAfee Agent: McAfee Agent Statistics

          7        Collect only RelayServer EPOAGENTMETA McAfee Agent  4      McAfee Agent: McAfee Agent Statistics

           

          Presumably you'd have a search string that returned only the single task you expected to find.  Hope that's useful.

           

          Jon

          • 2. Re: Client Task
            mitch_reid

            Thanks Jon.  The clienttask.run command also seems to require productId and taskIk.  What would the commands be to get those?

             

            Thanks

            • 3. Re: Client Task
              jking

              The 'task ID' is the 'object Id' in the table returned above for clienttask.find.  The productId is the third column, EPOAGENTMETA in my example.  I should also note that the product ID won't ever change; if you're using this script to kick off a particular task, you can probably just find out what it is and hard code it.

               

              However, I know you haven't asked but I wanted to make a comment ... attempting to run a client task from the server on demand tends to not be the most reliable way to ensure something happens -- it only works on windows agents at the moment, and it only works if we can send a wakeup to the agents -- which means it has to be enabled in policy, the computer has to be turned on, and it can't be behind a NAT and reachable from the server.

               

              That web API command is the equivalent of doing 'run client task now' from the system tree page.

               

              I would expect you'd have better sustained luck having a tag-based client task assigment, with periodic queries to determine applicability for whatever it is you're automating, and applying or removing the tags that will result in client tasks being assigned to machines the next time they check in.

               

              Anyway thought I'd throw two cents in the ring. 

               

              Jon

              • 4. Re: Client Task
                mitch_reid

                Thanks Jon. I have thought about both of those options and may use both.  Final question. My command I tried is:

                 

                https://eposerver/remote/clienttask.run?TESTPC&EPOAGENTMETA&255

                 

                Where the host name is TESTPC, the product ID is EPOAGENTMETA and the object ID is 255.

                 

                And I get:

                 

                Error 0 :

                Error setting parameters for command: clienttask.run

                 

                Syntax error ?

                • 5. Re: Client Task
                  jking

                  Mitch,

                   

                  I can't test directly at the moment but you need to add the parameter name in front of the values:

                   

                  clienttask.run?names=testpc&amp;productId=EPOAGENTMETA&amp;taskId=255

                   

                  Give that a shot.  I might have the parameter names slightly wrong.

                   

                  Jon