Relevance for Server Automation

Hello,

I’ve Created an Automation plan , I would like to get the action that I planed In that plan in relevance, like Bes Actions of…

Is it possible?
I’ve looked already on the rest api, but I didn’t understand how to get that…

Thanks,
Ortal

Hey @ortal - is this what you mean?

Yes , that what I meant.

what is the difference between Plan Actions and Plan definitions?

thanks,
Ortal

Hi @ortal,

So a plan definition is what you see in the “Automation Plans” dashboard - these are basically the structure of the work to be performed, but without the runtime information such as targets and parameter values (even though these can actually be set by clicking on the ‘Default Settings’ icon on a per step basis). Plan definitions are essentially an XML document contained within the body of a fixlet.

A plan action on the other hand is a running instance of a plan definition: when you take action on a plan (definition), a plan action is the resulting ‘object’ that is generated. So there can be a single plan definition, but any number of running instances of that plan definition (each instance potentially targeted at different machines and using different parameter values). Plan actions can be seen on the “Automation Plan Actions Status” dashboard.

Cheers,
Paul.

1 Like

Thanks,

I’ve tried the query, by I got this error:

iem GET query --relevance “(id of it, name of it, start date of it,end date of it) of bes actions whose (action script of it starts with “#!/plan/xml”)”

API Request Failed: Requested resource does not exist.

I think there’s some problem with the “”, can you help me fixe it please?

Thanks,
Ortal

HI @ortal

Try this - it’s a two-stage input:

iem POST query

then you’ll get prompted by:

Warning: Current console font may not display locale characters correctly.
Input: 

then just input your query:

Input: relevance=(id of it, name of it) of bes actions whose( action script of it starts with "#!/plan/xml")

Cheers,
Paul.

Hi,

Thank you for the replay, but I need to run it in a batch file automatically.
is there a way to do it in the format I sent?

Thanks,
Ortal

Hi @ortal

Okay, so after a bit of playing around, I’ve arrived at this:

iem GET query --relevance="(id of it, name of it) of bes actions whose( action script of it starts with %22%23%21%2Fplan%2Fxml%22)"

It was actually interpreting the “/” characters as part of the URL it looks like.
So, I’ve escaped all non-standard characters according to:

Basically:

" = %22
# = %23
! = %21
/ = %2F

Hope this helps.

Cheers,
Paul.

Wow!
thanks! that works perfectly!

:slight_smile:

Hello again,

I have more question. I have plan with several tasks, and every task target different computers,
how can I get the id of those actions (when it starts) and there target computers?

thanks,
Ortal

Hi @ortal,

So given that you know the plan action ID, you can check what step actions exist for that running (or completed) plan instance. For example, let’s say my plan action id was 12345:

ids of bes actions 
whose
(
  exists 
  (
    parenthesized part 1 of 
    (
      matches 
      (
        regex "^#\{IEMPlan 12345,([0-9]+),[OXD]\} .*$"
      )
      of 
      (
        name of it
      )
    )
  )
)

NOTE: This expression assumes you want to know about ALL steps (standard, failure and download type steps) for the plan. To adjust that, you’d need to modify the [OXD] part of the regex:

O = ordinary (standard) type steps
X = failure type steps
D = download type steps

So if I only wanted to be shown the standard and failure steps for the plan, and I didn’t care about download type steps, I’d use the regex value:

regex "^#\{IEMPlan 12345,([0-9]+),[OX]\} .*$"

So, once you have the IDs of the individual step actions you can find out what their targets were.
If you’ve targeted your steps by ID (i.e. you go into the list of computers and select them individually), you can use the following (let’s assume here that the ID of our first step action is 123):

(name of it, id of it) of targeted computers of bes action whose( id of it  = 123 )

Then you would repeat this for each step action ID returned by the first relevance expression above.

OR, if you wanted to try to do all of that in one shot, you could probably use something like this:

(
  id of it, 
  "[" & 
     concatenation "," of 
     (
       name of it & "::" & id of it as string
     )
     of targeted computers of it 
  & "]"
)
of bes actions 
whose
(
  exists 
  (
    parenthesized part 1 of 
    (
      matches 
      (
        regex "^#\{IEMPlan 12345,([0-9]+),[OXD]\} .*$"
      )
      of 
      (
        name of it
      )
    )
  )
)

This would return you the ID of the step actions and well as a comma-separated list of targeted computers, e.g.

(ID), (TARGETS)

123, [MyComp1::1001,MyComp2::1002,MyComp3::1003]
456, [MyComp4::2001,MyComp5::2002,MyComp6::2003]
789, [MyComp7::3001,MyComp8::3002,MyComp9::3003]
etc.

I’m not sure what way you’d like to format or arrange this information, but this example should hopefully give you the building blocks you need to format it however you’d like.

Cheers,
Paul.

Hi :smile:

That’s great, thanks!

but how I get the last reported status of the computer of this action?

and if I don’t know the actions ids of this plan, how can I get that?

Thanks,
Ortal

So there’s almost certainly a nicer way to do this - suggestions welcome - but this should give you what you need:

(
  id of it, 
  "[" & 
     concatenation "," of 
     (
       name of it & "::" & id of it as string
     )
     of targeted computers of it 
  & "]",
  "[" & 
     concatenation "," of 
     (
       name of computer of it & "::" & id of computer of it as string & "::" & status of it as string
     )
     of results of it 
  & "]"
)
of bes actions 
whose
(
  exists 
  (
    parenthesized part 1 of 
    (
      matches 
      (
        regex "^#\{IEMPlan 12345,([0-9]+),[OXD]\} .*$"
      )
      of 
      (
        name of it
      )
    )
  )
)

The thing that makes it a little tricky is that not all targeted computers may actually return a result, and trying to match on “sibling” properties (like id of computer of it (results) = id of it (targeted computer)) is pretty annoying. Not saying it can’t be done, but would probably end up making your expression pretty gnarly.

To get the ID of your plan action, follow the link in my very first comment on this post.

Cheers,
Paul.

Hi,
Thank you very much.

About the Id - I didn’t meant the id of the plan, I meant the id of all the action that will create after the plan is starting.

Thanks,
Ortal

Hi @ortal,

So all you need to do is replace is the plan action ID (the examples above use 12345), and it will automatically identify those for you.

It can do this because the name given to the step action includes the ID of the plan action that created them, which is why we can use this part of the expression to identify (child) step actions:

regex "^#\{IEMPlan 12345,([0-9]+),[OXD]\} .*$"

If you want to know the IDs of the step actions for a given plan action though (separate from the above), you could use this:

(id of it, name of it) 
of bes actions 
whose
(
  exists 
  (
    parenthesized part 1 of 
    (
      matches 
      (
        regex "^#\{IEMPlan 12345,([0-9]+),[OXD]\} .*$"
      )
      of 
      (
        name of it
      )
    )
  )
)

Hello again,

I need to add to the query a variable, something like that:

(ids of it) of bes actions whose (Time issued of it as string contains “%Hour%”)

I’ve tried with %5C%22%25Hour%25%5C%22, but I get an error:
This expression contained a character which is not allowed

can you help me please?

Thanks,
Ortal

Hmm… not sure, but I think you might have found some kind of variation of this:
https://bigfix.me/relevance/details/2997196

Was not able to evaluate that expression. This should have done it in my opinion:

>iem.exe GET query --relevance="(ids of it) of bes actions whose (Time issued of it as string contains %22%2525Hour%2525%22)

<?xml version="1.0" encoding="UTF-8"?>
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
        <Query Resource="(ids of it) of bes actions whose (Time issued of it as string contains &quot;%Hour%&quot;)">
                <Result></Result>
                <Error>A string constant had an improper %-sequence.</Error>
        </Query>
</BESAPI>

The %2525 probably should have been translated to %25, which would have been interpreted as the % character.

But as you can see, %2525 looks to have been interpreted simply as %

... &quot;%Hour%&quot; ...

Also tried this to no avail:

>iem.exe GET query --relevance="(ids of it) of bes actions whose (Time issued of it as string contains %22%25%32%35Hour%25%32%35%22)

<?xml version="1.0" encoding="UTF-8"?>
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
        <Query Resource="(ids of it) of bes actions whose (Time issued of it as string contains &quot;%Hour%&quot;)">
                <Result></Result>
                <Error>A string constant had an improper %-sequence.</Error>
        </Query>
</BESAPI>

Again, as you can see, %25%32%35 looks to have been interpreted simply as %.

(%25 = %, %32 = 2, %35 = 5)

So, throwing this open to anyone else who has any ideas?

anyone please? still don’t have solution