Ad Widget

Collapse

Dynamic Template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Liran
    Junior Member
    • Apr 2015
    • 13

    #1

    Dynamic Template

    Hi all,

    Im trying to create a template for windows services. my idea was to crate a template that have 8 iteams that ready to receive MACRO from the host.
    for exemple:
    in the host macros : {$service1} = DNS
    in the tempalte: service_state[{$SERVICE1}]
    but the problem that if i dont have a marcos for the service it's just run <service2,3,4,5,6,7,8> and then give me some error.
    i know i can disable the item. but i don't want to this all the time.
    Is it possible that the template will know when there is no service# in the macros to disable automatically the item?

    I hope it was clear enough

    Thanks
  • jamesNJ
    Senior Member
    • Jun 2015
    • 103

    #2
    One idea:
    Set a system wide marco {$service}=BAD
    Then in your template trigger use a formula like this to suppress error triggers
    {$service}<>"BAD" AND service_state[${service}]=0
    Trigger should only fire if the expression is true, and it won't be true if the item is inheriting the default system-wide macro setting instead of your host specific setting.

    Just a suggestion ... I haven't tried this myself ...

    Comment

    • Liran
      Junior Member
      • Apr 2015
      • 13

      #3
      Hi james,
      It sounds like a great idea,
      But I can not create the trigger

      i tryid:
      {Windows Services:service_state[{$SERVICE8}].last(0)}>0 and
      {Windows Services:{$SERVICE8}}<>"NotActive"

      Comment

      • jamesNJ
        Senior Member
        • Jun 2015
        • 103

        #4
        I think my error there is that trigger expressions must evaluate to numbers, not stings.

        So given that, make your global macro be a number like 1991 and then compare directly against that value. I tested something similar and this worked for me. I set a global {$TEST} macro to be 1991 and then a host macro {$TEST} to be "firefox" and then used an expression to look for my agent ping: "firefox" doesn't evaluate to 1991. So given your example try something like:
        global macro {$SERVICE8} = 1991
        host macro {$SERVICE8}="process-name"

        {$SERVICE8}<>1991 and {Windows Services:service_state[{$SERVICE8}].last(0)}=0

        So that reads, trigger if $SERVICE8 is not 1991 (hence a host-based macro with process name is set) and if the desired windows service is not running.

        Comment

        Working...