PDA

View Full Version : BUG: Arithmetic Minus Not Supported In Triggers


James Wells
18-01-2007, 03:35
Greetings,

We are attempting to create a couple of complex triggers and have found that the arithmetic minus (-) is not supported, though the documentation clearly shows it as supported. An example trigger;

({HOSTNAME:system.uptime.prev()}-{HOSTNAME:system.uptime.last()})<86400

This trigger will fail at creation time with an error showing (0-0)<86400 is an invalid expression, where as the following will work;

({HOSTNAME:system.uptime.prev()}+{HOSTNAME:system. uptime.last()})<86400


This is on Zabbix-1.1.4, and it is a blocking issue that needs to get resolved soon.

James Wells
28-01-2007, 00:40
Well, I found that 1.1.5 still has the problem. I did a bit of digging and found that it has the same problem that Palmertree found two different threads;
Zabbix Version 1.1.5 - Can not add host names with a dash (http://www.zabbix.com/forum/showthread.php?t=5059)
Zabbix 1.1.5 - Triggers with dashes (http://www.zabbix.com/forum/showthread.php?t=5063)

In this case the problem is in triggers.inc.php, on or about line 196;

$arr="";
if (eregi('^((.)*)([0-9\.]+[A-Z]{0,1})[ ]*([\&\|\>\<\=\+\-\*\/\#]{1})[ ]*([0-9\.]+[A-Z]{0,1})((.)*)$', $expression, $arr))
{
// echo "OK<br>";
// for($i=0;$i<50;$i++)
// {
// if($arr[$i]!="")
// echo " $i: ",$arr[$i],"<br>";
// }

This should instead look like;

$arr="";
if (eregi('^((.)*)([0-9\.]+[A-Z]{0,1})[ ]*([\&\|\>\<\=\+\*\/\#-]{1})[ ]*([0-9\.]+[A-Z]{0,1})((.)*)$', $expression, $arr))
{
// echo "OK<br>";
// for($i=0;$i<50;$i++)
// {
// if($arr[$i]!="")
// echo " $i: ",$arr[$i],"<br>";
// }

Palmertree
28-01-2007, 07:08
Thanks James for the information. :) That correction did the trick.

Alexei
28-01-2007, 11:25
Sorry we didn't include the fix into 1.1.5. Perhaps we will release 1.1.6 earlier to get rid of the unfortunate problems.

Alexei
28-01-2007, 11:26
Please see http://www.zabbix.com/forum/showthread.php?t=4989