Ad Widget

Collapse

Macros examples

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arikin
    Junior Member
    • Aug 2011
    • 27

    #1

    Macros examples

    Any real life examples of macros used in Items?

    The online manual actually just a reference. Lots of facts but examples are slim. Even the macro examples in the forums come up as errors.

    For example trying to make an item where the port is an user macro.

    Description: TCP PORT
    Type: Simple check
    Key: tcp_perf,{TCP.PORT}

    --> That gives the lovely error msg:
    Error in item key: invalid character '{' at position 9

    --> Same for : Key: tcp_perf,{$TCP.PORT}

    Yes the answer may make me look like a fool. But real working... examples would help prevent stupid questions like mine. (Yes I have spent hours on the inadequate search function of this forum. By the way google finds phrases on this forum better).
  • hirschnf
    Member
    • Jan 2010
    • 56

    #2
    Good Morning,

    as you can see, you can define macros in Templates and on the host itself.
    If the macros have the same name in the template and the host, the value from the host will be use.

    Here is an example for an item:
    Code:
    Host:        Template_xy
    Description: Application Availability on Port {$PORT}
    Type:        simple check
    Key:         tcp,[{$PORT}]
    Type info..: Numeric (unsigned)
    Data type:   Decimal
    In the template I have defined the macro $PORT with a standard value 3181. And on the hosts where I use this template I define the correct port if it's not the same.

    Additionaly under Administration you can define global macros for the whole zabbix environment. I use these for date and time macros and update them every minute with a little PHP script.

    Hope this will help you.

    Comment

    • arikin
      Junior Member
      • Aug 2011
      • 27

      #3
      Thank you

      Ah! Thank you.

      So the square brackets are actually required.........
      tcp,[{$PORT}]

      Please forgive me. When a unix man page uses square brackets it means a range of values that can be used for that parameter. That is why I tried these:
      tcp,{$PORT}
      tcp,$PORT

      Comment

      Working...