Ad Widget

Collapse

Using {HOST.HOST} in item preprocessing regex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tikkami
    Member
    • May 2018
    • 71

    #1

    Using {HOST.HOST} in item preprocessing regex

    Hi

    Text file contains data from many hosts and I get a file to Zabbix with HTTP agent

    There is a string which contains hostname and value. I need to extract the value for the host.

    Let's say:
    name="HOST1:freemem" value="7164.998"

    If I put "HOST1" to preprocess regex
    name="HOST1:freemem" value="(.*)" that matches.
    If I put {HOST.HOST} to regex, that does not make a match. Should it?
    I also tried to make additional macro {$HOSTNAME} and put that to regex, that makes a match. But then I need some automation to set {$HOSTNAME} according to real hostname.

    Any ideas how to do this?

    I'm using Zabbix 4.0.0
    Last edited by tikkami; 11-10-2018, 19:37.
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    You are asking wrong questions.
    Please define what you are going to archive with you monitoring definition than it will be possible to say what needs to be done.
    In other words it is quite possible that you don't need o use {HOST.HOST},
    I'm 100% sure that you don't need to put this macro in any item name because all your items are part of the monitoring definition of exact host.
    http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
    https://kloczek.wordpress.com/
    zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
    My zabbix templates https://github.com/kloczek/zabbix-templates

    Comment

    • tikkami
      Member
      • May 2018
      • 71

      #3
      Thanks for your reply.

      Webserver provides one file which has data for multiple hosts. Those hosts cannot be monitored directly by Zabbix.

      name="HOST1:freemem" value="7000.998"
      name="HOST2:freemem" value="6000.998"
      name="HOST3:freemem" value="5000.998"

      I have a host template and item which reads the file via HTTP agent.
      I guess only way to get data for the specific host is using some kind of hostname macro in Preprocessor's regex rule...



      Comment

      • kloczek
        Senior Member
        • Jun 2006
        • 1771

        #4
        Originally posted by tikkami
        Thanks for your reply.

        Webserver provides one file which has data for multiple hosts. Those hosts cannot be monitored directly by Zabbix.

        name="HOST1:freemem" value="7000.998"
        name="HOST2:freemem" value="6000.998"
        name="HOST3:freemem" value="5000.998"

        I have a host template and item which reads the file via HTTP agent.
        I guess only way to get data for the specific host is using some kind of hostname macro in Preprocessor's regex rule...
        {HOST.HOST} macro provide hostname used in host zabbix interface.In those three lines you have implemented checking other three hosts and seems like you are not checking connectivity but some state of the remote systems.
        In other words .. none of the HOST{1..3} hosts are the host over which zabbix agent you are obtaining those free memory data.
        Item preprocessing is about processing raw data received over monitored item. Again ,, no what so ever connection with use {HOST.HOST} macro.

        Advice: instead asking about possible use macros (because this does not provide any valuable clues with what kind of issues you are dealing/trying to archive) try to describe what you are going to monitor over exact metrics.
        http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
        https://kloczek.wordpress.com/
        zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
        My zabbix templates https://github.com/kloczek/zabbix-templates

        Comment

        • tikkami
          Member
          • May 2018
          • 71

          #5
          I'm getting back to this question because I have found a new monitoring case where this function would be useful.

          I have a WSUS server which provides information about pending updates as XML-file.
          XML-file is published at some internal webserver.


          With test setup I have 3 hosts: host1, host2 and host3.
          There are 3 hotfixes waiting to be installed at host1.
          There are 2 hotfixes waiting to be installed at host2 and so on.


          Data would be something like this:

          <?xml version="1.0" encoding="UTF-8"?>
          <wsushosts>

          <host name="host1">
          <hotfix>kb001</hotfix>
          <addInfo>some additional information</addInfo>
          </host>

          <host name="host1">
          <hotfix>kb002</hotfix>
          <addInfo>some additional information</addInfo>
          </host>

          <host name="host1">
          <hotfix>kb004</hotfix>
          <addInfo>some additional information</addInfo>
          </host>

          <host name="host2">
          <hotfix>kb001</hotfix>
          <addInfo>some additional information</addInfo>
          </host>

          <host name="host2">
          <hotfix>kb002</hotfix>
          <addInfo>some additional information</addInfo>
          </host>

          <host name="host3">
          <hotfix>kb004</hotfix>
          <addInfo>some additional information</addInfo>
          </host>

          </wsushosts>


          I have configured host1, host2 and host3 to Zabbix.
          I have created html agent -item for all of them to get data from URL http://192.168.0.10/wsusdata.xml.

          Next I'm going to use preprocessing to get count of pending hotfix for host1.
          This preprocessing XML path definition is working:
          count(/wsushosts/host[@name="host1"]/hotfix)

          Neither of these does not work:
          count(/wsushosts/host[@name="{HOSTNAME}"]/hotfix)
          count(/wsushosts/host[@name="{HOST.HOST}"]/hotfix)
          count(/wsushosts/host[@name="{HOST.NAME}"]/hotfix)

          Below definition is working also, but I need to assing {$HOSTNAME} -macro manually for every host.
          count(/wsushosts/host[@name="{$HOSTNAME}"]/hotfix)

          Is there any way to use already defined hostname with XML-path preprocessing function?

          Comment

          Working...