Ad Widget


Getting numeric data from the item value string

  • Filter
  • Time
  • Show
Clear All
new posts

    Getting numeric data from the item value string


    I'm having hard time figuring out the problem that I'm trying to solve.

    The goal that I want to achieve is to monitor master and slave DNS servers to see if DNS zones on them are in sync. That can be easily done by monitoring zone SOA record and using net.dns.record item key as every time zone is updated it's serial number changes and it is easy to notice mismatch. I get items with string values like this from each DNS server:
    " SOA 2016060600 300 120 2419200 7200"
    So far so good.

    Unfortunately trigger function documentation page says that "All functions return numeric values only. Comparison to strings is not supported" so I'm out of luck comparing values of these items directly.

    What I would like to achieve is to extract numeric serial number value ("2016060600" in the example above) from the SOA record item string. Is it possible at all or should I give up and use external scripts to achieve my goal?


    Hello karlism!

    As i see, unfortunately there are no built in possibility to convert string to number, or extract numbers from strings in zabbix.
    You can find Feature Request that should help in your case.

    As for now i would recommend using external scripts. There are very common functions to solve your problem.

    Best regards,


      I came here looking for an answer at one point and then found out that as of Zabbix 3.4 (I believe) you can use item preprocessing to convert string values to integers with regex. So I thought i'd share my experience with it.

      I'll use an example of converting MySQL "Slave_io_running" string states to numeric metrics....

      In the item preprocessing tab i used two steps to convert string values into integers using match and replace functionality like this...

      Name Parameters Output

      Regular expression (.*) \1:No=0:Yes=1:Connecting=2
      Regular expression (No|Yes|Connecting)(?=.*:\1=(\d)) \2


        Hello sudo092,

        Your solution is absolutely brilliant.


          Personaly I used Javascript to convert my Zabbix string value to int in a preprocessing step : parseInt(value)



          No announcement yet.