Ad Widget

Collapse

How to create items for every Macro?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tenou
    Junior Member
    • Feb 2020
    • 17

    #1

    How to create items for every Macro?

    Hey there,

    I'm rather new to Zabbix, so this may be a pretty basic question. If so, I'm sorry - but please bare with me!

    I'm currently working on monitoring my webpages status and performance data.
    For that I have six items per URL:
    • Check HTTP Response code
    • Check TCP Service state
    • Check TCP performance
    Everyone is doubled, one for HTTP and one for HTTPS.

    They're getting their URL from a macro configured on the Host, named "{$SITE_1}" - the number increasing with every site, of course.

    Is there a way to automatically create those items for every newly added Macro?It'd be a real hassle to manually add them.
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    If I'm understanding the question, then the answer is "yes", but in a slightly different way.

    You probably want to read up on templates. You've grasped the usefulness of macros, but haven't yet applied them to one of the places that macros are most useful: within a template.

    The basic idea is that you create a template, something like "Standard Web Site Monitors" or whatever you want to call it.

    Then, you consider all of the things that that might vary between hosts where you would apply this template. The URL is one, perhaps the item check frequency is another. How many subsequent checks need to fail before you alert might be a third. You make each of those things macros, with default values for each thing that might vary specified at the template level, e.g. something like {$STANDARD_WEB_SITE_URL}, {$STANDARD_WEB_SITE_CHECK_FREQUENCY}, {$STANDARD_WEB_SITE_ALERT_AFTER}, etc. Use whatever macro names make sense to you.

    Then you copy your existing items and triggers to the template and change the items and triggers to use the macros you've specified.

    Now you can apply that template to any # of hosts. At the host level, you override any of the macros (like the URL) that needs to be different. If most of your sites can use the default item check frequency or trigger alert after # of failures setting, you don't need to override those, you just use the defaults from the template.

    Comment

    • Tenou
      Junior Member
      • Feb 2020
      • 17

      #3
      Hey tim.mooney, whilst all of your information is correct, it's not applicable for my usecase, unfortunately. Not every host monitors the website it serves, but rather a single, external host monitors all at once. This is to assure not only that stuff works from the inside, but also from the outside.
      So there's not one website monitored per host (which would be pretty simple to do, yep), but a single host monitoring dozens of websites.
      That's why I was asking this in the first place - if there's a way to just add a new macro for a new web page containing the URL and then a LLD or something creating the checks for it automatically.
      When only having two or three pages it might be fine to just copy and paste items, changing their macro name - but with that many pages it's just such a waste of time...

      I hope I could clarify what I'm trying to do better this time. If there are still any questions left, please feel free to ask!

      Comment

      • tim.mooney
        Senior Member
        • Dec 2012
        • 1427

        #4
        Ok, understood. Sorry for not getting what you were asking, originally.

        You mentioned LLD, so I can assume that you've looked at the docs for low level discovery. I haven't (yet) had to write my own LLD discovery scripts, so although I know that a macro can be used to influence LLD (the official templates use macros to influence their behavior, for example what Windows services they ignore for service discovery), I don't know if there's a way to have an LLD script look for a potentially large number of similarly named macros. It may be possible, I just don't know because I've never tried to do that specific thing.

        I can think of ways to do this that involve having the LLD script connect up to a URL to download the list of URLs to check for discovery, but that potentially moves your list of "what to discover" outside of Zabbix. It could be as simple as a text file, but it still ends up external to Zabbix. Not ideal.

        Comment

        Working...