Zabbix 2.0: Regular Expression to extract value from a String for a trigger

jmxregexregular expressionszabbix

I am using Zabbix 2.0.4 to monitor several Java applications. Most values are exported via JMX. One of those exported attributes is a string that is constructed like this:
[IP_1],[port_1],[ms_time_1];[IP_2],[port_2],[ms_time_2];
eg:

192.168.105.20,5060,15638;192.168.105.30,5060,9753;

I want to construct a trigger based on the ms_time value for a given IP address. My first problem is: how do I get this value from the string? I have this regexp, which captures the correct number when I test it in several regular expression test tools:

192\.168\.105\.20,[\d]+,([\d]+)

But somehow, this doesn't seem to work in Zabbix. I have tried different versions of the regexp, e.g. using [0-9] or [:digit:] instead of [\d], but to no avail.

My trigger should get active when the ms_time value exceeds 15000, so my whole trigger definition currently looks like this:

{MY_HOST:jmx["com.example:type=Attributes",StringValue].regexp("192\.168\.105\.20,[\d]+,([\d]+)")}>15000

I couldn't find any examples where a regexp was used to extract a value from a string and use that value for further processing.

Best Answer

Function regexp returns 1 if the item's value matches the regular expression provided as the argument, and returns 0 otherwise. It does not return the extracted value.

In general, what you are trying to do is currently not possible, but there are two feature requests that may make it possible in the future: ZBXNEXT-1638 (store the whole value, but extract a piece of information later) and ZBXNEXT-1427 (extract a piece of information upon receival).

As a workaround, if the threshold value for ms_time would be a round value (say, 10000), it would be possible to trigger based on ms_time length:

192\.168\.105\.20,[\d]+,([\d]{5,})