diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-06-03 21:04:18 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-06-03 21:04:18 +0000 |
commit | ca309d601413e7615cd322b235c41591e149dcb9 (patch) | |
tree | 62268cb37013566bd0a3b48ade94b1b3c18dc9ac | |
parent | 071a071414485ad4edb14e071ad141afadbfc9e9 (diff) | |
download | zabbix-ca309d601413e7615cd322b235c41591e149dcb9.tar.gz zabbix-ca309d601413e7615cd322b235c41591e149dcb9.tar.xz zabbix-ca309d601413e7615cd322b235c41591e149dcb9.zip |
- added column alarms.value (Alexei)
- removed column alarms.istrue (Alexei)
- added columns triggers.status (Alexei)
- added columns triggers.value (Alexei)
- removed column triggers.istrue (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@401 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | create/mysql/schema.sql | 6 | ||||
-rw-r--r-- | frontends/php/alarms.php | 15 | ||||
-rw-r--r-- | frontends/php/include/config.inc | 61 | ||||
-rw-r--r-- | frontends/php/include/db.inc | 2 | ||||
-rw-r--r-- | frontends/php/latestalarms.php | 14 | ||||
-rw-r--r-- | frontends/php/tr_status.php | 20 | ||||
-rw-r--r-- | frontends/php/triggers.php | 20 | ||||
-rw-r--r-- | include/common.h | 13 | ||||
-rw-r--r-- | include/db.c | 16 | ||||
-rw-r--r-- | include/db.h | 3 | ||||
-rw-r--r-- | include/functions.c | 26 | ||||
-rw-r--r-- | upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql | 18 |
13 files changed, 120 insertions, 99 deletions
@@ -26,6 +26,11 @@ snmpget -On localhost public enterprises.ucdavis.memory.memTotalSwap.0] Changes for 1.0beta4: + - added column alarms.value (Alexei) + - removed column alarms.istrue (Alexei) + - added columns triggers.status (Alexei) + - added columns triggers.value (Alexei) + - removed column triggers.istrue (Alexei) - support for --enable-static for ./configure (Alexei) - housekeeping period for alarms and alerts to be set in days (Alexei) - created directory upgrades/dbpatches/1.0beta3_to_1.0beta4 (Alexei) diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql index 3495d259..d775da16 100644 --- a/create/mysql/schema.sql +++ b/create/mysql/schema.sql @@ -156,7 +156,7 @@ CREATE TABLE alarms ( alarmid int(4) NOT NULL auto_increment, triggerid int(4) DEFAULT '0' NOT NULL, clock int(4) DEFAULT '0' NOT NULL, - istrue int(4) DEFAULT '0' NOT NULL, + value int(4) DEFAULT '0' NOT NULL, PRIMARY KEY (alarmid), KEY (triggerid,clock), KEY (clock) @@ -295,7 +295,9 @@ CREATE TABLE triggers ( expression varchar(255) DEFAULT '' NOT NULL, description varchar(255) DEFAULT '' NOT NULL, url varchar(255) DEFAULT '' NOT NULL, - istrue int(4) DEFAULT '0' NOT NULL, +-- istrue int(4) DEFAULT '0' NOT NULL, + status int(4) DEFAULT '0' NOT NULL, + value int(4) DEFAULT '0' NOT NULL, priority int(2) DEFAULT '0' NOT NULL, lastchange int(4) DEFAULT '0' NOT NULL, dep_level int(2) DEFAULT '0' NOT NULL, diff --git a/frontends/php/alarms.php b/frontends/php/alarms.php index 22c45818..6160ef14 100644 --- a/frontends/php/alarms.php +++ b/frontends/php/alarms.php @@ -64,7 +64,7 @@ <FONT COLOR="#000000"> <? - $sql="select clock,istrue as status,triggerid from alarms where triggerid=$triggerid order by clock desc $limit"; + $sql="select clock,value,triggerid from alarms where triggerid=$triggerid order by clock desc $limit"; $result=DBselect($sql); echo "<CENTER>"; @@ -86,31 +86,30 @@ $clock=$row["clock"]; $leng=$lclock-$row["clock"]; - if($row["status"]==0) { echo "<TR BGCOLOR=#EEFFEE>"; } - elseif($row["status"]==2) { echo "<TR BGCOLOR=#DDDDDD>"; } - elseif($row["status"]==3) { echo "<TR BGCOLOR=#EEEEEE>"; } + if($row["value"]==0) { echo "<TR BGCOLOR=#EEFFEE>"; } + elseif($row["status"]==1) { echo "<TR BGCOLOR=#EEEEEE>"; } else { echo "<TR BGCOLOR=#FFDDDD>"; } echo "<TD>",date("Y.M.d H:i:s",$row["clock"]),"</TD>"; - if($row["status"]==1) + if($row["value"]==1) { $istrue="TRUE"; $truesum=$truesum+$leng; $sum=$truesum; } - elseif($row["status"]==0) + elseif($row["value"]==0) { $istrue="FALSE"; $falsesum=$falsesum+$leng; $sum=$falsesum; } - elseif($row["status"]==2) + elseif($row["value"]==3) { $istrue="DISABLED"; $dissum=$dissum+$leng; $sum=$dissum; } - elseif($row["status"]==3) + elseif($row["value"]==2) { $istrue="UNKNOWN"; $dissum=$dissum+$leng; diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc index a668b952..8799b623 100644 --- a/frontends/php/include/config.inc +++ b/frontends/php/include/config.inc @@ -94,11 +94,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $priorities=0; for($i=0;$i<=5;$i++) { - $result=DBselect("select count(*) from triggers t,hosts h,items i,functions f where t.istrue=1 and f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and i.status in (0,2) and t.priority=$i"); + $result=DBselect("select count(*) from triggers t,hosts h,items i,functions f where t.value=1 and f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and i.status in (0,2) and t.priority=$i"); $priorities+=(1000^$i)*DBget_field($result,0,0); } $triggerids=""; - $result=DBselect("select t.triggerid from triggers t,hosts h,items i,functions f where t.istrue=1 and f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and i.status in (0,2)"); + $result=DBselect("select t.triggerid from triggers t,hosts h,items i,functions f where t.value=1 and f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and i.status in (0,2)"); for($i=0;$i<DBnum_rows($result);$i++) { $triggerids="$triggerids,".DBget_field($result,$i,0); @@ -199,7 +199,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; { global $ERROR_MSG; - $sql="select triggerid,expression,description,istrue,priority,lastchange,dep_level,comments,url from triggers where triggerid=$triggerid"; + $sql="select triggerid,expression,description,status,priority,lastchange,dep_level,comments,url,value from triggers where triggerid=$triggerid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) { @@ -1113,8 +1113,8 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $ERROR_MSG="Insufficient permissions"; return 0; } - add_alarm($triggerid,3); - $sql="update triggers set istrue=$status where triggerid=$triggerid"; + add_alarm($triggerid,2); + $sql="update triggers set status=$status where triggerid=$triggerid"; return DBexecute($sql); } @@ -1546,19 +1546,19 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; # Add alarm - function add_alarm($triggerid,$istrue) + function add_alarm($triggerid,$value) { $sql="select max(clock) from alarms where triggerid=$triggerid"; $result=DBselect($sql); $row=DBfetch($result); if($row[0]!="") { - $sql="select istrue from alarms where triggerid=$triggerid and clock=".$row[0]; + $sql="select value from alarms where triggerid=$triggerid and clock=".$row[0]; $result=DBselect($sql); if(DBnum_rows($result) == 1) { $row=DBfetch($result); - if($row["istrue"] == $istrue) + if($row["value"] == $value) { return 0; } @@ -1566,13 +1566,13 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } $now=time(); - $sql="insert into alarms(triggerid,clock,istrue) values($triggerid,$now,$istrue)"; + $sql="insert into alarms(triggerid,clock,value) values($triggerid,$now,$value)"; return DBexecute($sql); } # Add Trigger definition - function add_trigger($expression,$description,$priority,$istrue,$comments,$url) + function add_trigger($expression,$description,$priority,$status,$comments,$url) { global $ERROR_MSG; @@ -1583,7 +1583,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; // } $description=addslashes($description); - $sql="insert into triggers (description,priority,istrue,comments,url) values ('$description',$priority,$istrue,'$comments','$url')"; + $sql="insert into triggers (description,priority,status,comments,url,value) values ('$description',$priority,$status,'$comments','$url',2)"; # echo $sql,"<br>"; $result=DBexecute($sql); if(!$result) @@ -1593,7 +1593,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $triggerid=DBinsert_id($result,"triggers","triggerid"); # echo $triggerid,"<br>"; - add_alarm($triggerid,3); + add_alarm($triggerid,2); $expression=implode_exp($expression,$triggerid); $sql="update triggers set expression='$expression' where triggerid=$triggerid"; @@ -1637,7 +1637,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; # Update Trigger definition - function update_trigger($triggerid,$expression,$description,$priority,$istrue,$comments,$url) + function update_trigger($triggerid,$expression,$description,$priority,$status,$comments,$url) { global $ERROR_MSG; @@ -1654,15 +1654,8 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } $expression=implode_exp($expression,$triggerid); - if($istrue != 2) - { - $istrue="istrue"; - } - else - { - add_alarm($triggerid,3); - } - $sql="update triggers set expression='$expression',description='$description',priority=$priority,istrue=$istrue,comments='$comments',url='$url' where triggerid=$triggerid"; + add_alarm($triggerid,2); + $sql="update triggers set expression='$expression',description='$description',priority=$priority,status=$status,comments='$comments',url='$url' where triggerid=$triggerid"; return DBexecute($sql); } @@ -1867,7 +1860,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; { $trigger=get_trigger_by_triggerid($row2["triggerid"]); // Cannot use add_trigger here - $sql="insert into triggers (description,priority,istrue,comments,url) values ('".$trigger["description"]."',".$trigger["priority"].",".$trigger["istrue"].",'".$trigger["comments"]."','".$trigger["url"]."')"; + $sql="insert into triggers (description,priority,status,comments,url,value) values ('".$trigger["description"]."',".$trigger["priority"].",".$trigger["status"].",'".$trigger["comments"]."','".$trigger["url"]."',2)"; $result4=DBexecute($sql); $triggerid=DBinsert_id($result4,"triggers","triggerid"); @@ -2768,7 +2761,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $expression=explode_exp($trigger["expression"],0); $description=$trigger["description"]; $priority=$trigger["priority"]; - $istrue=$trigger["istrue"]; + $status=$trigger["status"]; $comments=$trigger["comments"]; $url=$trigger["url"]; } @@ -2777,7 +2770,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $expression=""; $description=""; $priority=0; - $istrue=3; + $status=0; $comments=""; $url=""; } @@ -2832,7 +2825,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; echo "Disabled"; show_table2_h_delimiter(); echo "<INPUT TYPE=\"CHECKBOX\" "; - if($istrue==2) { echo " CHECKED "; } + if($status==1) { echo " CHECKED "; } echo "NAME=\"disabled\" VALUE=\"true\">"; @@ -2924,10 +2917,10 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $result=DBselect("select count(*) from triggers"); $stat["triggers_count"]=DBget_field($result,0,0); - $result=DBselect("select count(*) from triggers where istrue!=2"); + $result=DBselect("select count(*) from triggers where status=0"); $stat["triggers_count_enabled"]=DBget_field($result,0,0); - $result=DBselect("select count(*) from triggers where istrue=2"); + $result=DBselect("select count(*) from triggers where status=1"); $stat["triggers_count_disabled"]=DBget_field($result,0,0); $result=DBselect("select count(*) from items"); @@ -2975,7 +2968,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $min=$max-24*3600; } - $sql="select clock,istrue from alarms where triggerid=$triggerid and clock>=$min and clock<=$max"; + $sql="select clock,value from alarms where triggerid=$triggerid and clock>=$min and clock<=$max"; $result=DBselect($sql); // -1,0,1 @@ -2988,7 +2981,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; for($i=0;$i<DBnum_rows($result);$i++) { $clock=DBget_field($result,$i,0); - $istrue=DBget_field($result,$i,1); + $value=DBget_field($result,$i,1); $diff=$clock-$time; @@ -2996,7 +2989,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; if($state==-1) { - $state=$istrue; + $state=$value; if($state == 0) { $false_time+=$diff; @@ -3013,17 +3006,17 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; else if($state==0) { $false_time+=$diff; - $state=$istrue; + $state=$value; } else if($state==1) { $true_time+=$diff; - $state=$istrue; + $state=$value; } else if($state==3) { $unknown_time+=$diff; - $state=$istrue; + $state=$value; } } diff --git a/frontends/php/include/db.inc b/frontends/php/include/db.inc index 2de3acce..a140b2fc 100644 --- a/frontends/php/include/db.inc +++ b/frontends/php/include/db.inc @@ -47,7 +47,7 @@ { global $DB,$DB_TYPE; -// echo $query,"<br>"; + echo $query,"<br>"; if($DB_TYPE == "MYSQL") { diff --git a/frontends/php/latestalarms.php b/frontends/php/latestalarms.php index 751ecd2a..2712063e 100644 --- a/frontends/php/latestalarms.php +++ b/frontends/php/latestalarms.php @@ -35,11 +35,11 @@ <? if(isset($limit)) { - $sql="select t.description,a.clock,a.istrue,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit $limit"; + $sql="select t.description,a.clock,a.value,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit $limit"; } else { - $sql="select t.description,a.clock,a.istrue,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit 50"; + $sql="select t.description,a.clock,a.value,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit 50"; } $result=DBselect($sql); @@ -48,7 +48,7 @@ echo "<TR>"; echo "<TD width=\"20%\"><b>Time</b></TD>"; echo "<TD><b>Description</b></TD>"; - echo "<TD width=\"10%\"><b>Status</b></TD>"; + echo "<TD width=\"10%\"><b>Value</b></TD>"; echo "</TR>"; $col=0; while($row=DBfetch($result)) @@ -62,17 +62,17 @@ echo "<TD>",date("Y.M.d H:i:s",$row["clock"]),"</TD>"; echo "<TD><a href=\"alarms.php?triggerid=".$row["triggerid"]."\">".$row["description"]."</a></TD>"; - if($row["istrue"] == 0) + if($row["value"] == 0) { echo "<TD><font color=\"00AA00\">OFF</font></TD>"; } - elseif($row["istrue"] == 3) + elseif($row["value"] == 1) { - echo "<TD><font color=\"AAAAAA\">UNKNOWN</font></TD>"; + echo "<TD><font color=\"AAAAAA\">ON</font></TD>"; } else { - echo "<TD><font color=\"AA0000\">ON</font></TD>"; + echo "<TD><font color=\"AA0000\">UNKNOWN</font></TD>"; } echo "</TR>"; } diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php index bbd7a52e..46e4c366 100644 --- a/frontends/php/tr_status.php +++ b/frontends/php/tr_status.php @@ -215,7 +215,7 @@ if($onlytrue=='true') { - $sql="select t.priority,count(*) from triggers t,hosts h,items i,functions f where t.istrue=1 and f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.description $select_cond and i.status in (0,2) $cond group by 1"; + $sql="select t.priority,count(*) from triggers t,hosts h,items i,functions f where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.description $select_cond and i.status in (0,2) $cond group by 1"; } else { @@ -335,11 +335,11 @@ if($onlytrue=='true') { - $result=DBselect("select distinct t.triggerid,t.istrue,t.description,t.expression,t.priority,t.lastchange,t.comments,t.url from triggers t,hosts h,items i,functions f where t.istrue=1 and f.itemid=i.itemid and h.hostid=i.hostid and t.description $select_cond and t.triggerid=f.triggerid and i.status in (0,2) $cond $sort"); + $result=DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid and t.description $select_cond and t.triggerid=f.triggerid and i.status in (0,2) $cond $sort"); } else { - $result=DBselect("select distinct t.triggerid,t.istrue,t.description,t.expression,t.priority,t.lastchange,t.comments,t.url from triggers t,hosts h,items i,functions f where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.description $select_cond and i.status in (0,2) $cond $sort"); + $result=DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.description $select_cond and i.status in (0,2) $cond $sort"); } $col=0; while($row=DBfetch($result)) @@ -351,7 +351,7 @@ // Check for dependencies - $sql="select count(*) from trigger_depends d, triggers t where d.triggerid_down=".$row["triggerid"]." and d.triggerid_up=t.triggerid and t.istrue=1"; + $sql="select count(*) from trigger_depends d, triggers t where d.triggerid_down=".$row["triggerid"]." and d.triggerid_up=t.triggerid and t.value=1"; $result2=DBselect($sql); if(DBget_field($result2,0,0)>0) @@ -379,16 +379,10 @@ echo "<BR><FONT COLOR=\"#000000\" SIZE=-2>".explode_exp($row["expression"],1)."</FONT>"; } echo "</TD>"; - if($row["istrue"]==0) + if($row["value"]==0) { echo "<TD ALIGN=CENTER><FONT COLOR=\"00AA00\">FALSE</FONT></TD>";} - elseif($row["istrue"]==2) - { echo "<TD ALIGN=CENTER><FONT COLOR=\"777777\">DISABLED</FONT></TD>"; } - elseif($row["istrue"]==1) - { echo "<TD ALIGN=CENTER><FONT COLOR=\"AA0000\">TRUE</FONT></TD>"; } - elseif($row["istrue"]==3) - { echo "<TD ALIGN=CENTER><FONT COLOR=\"AA0000\">UNKNOWN</FONT></TD>"; } else - { echo "<TD ALIGN=CENTER><FONT COLOR=\"AA0000\">Error !</FONT></TD>"; } + { echo "<TD ALIGN=CENTER><FONT COLOR=\"AA0000\">TRUE</FONT></TD>"; } if($row["priority"]==0) echo "<TD ALIGN=CENTER>Not classified</TD>"; elseif($row["priority"]==1) echo "<TD ALIGN=CENTER>Just information</TD>"; @@ -424,7 +418,7 @@ { echo "<TD ALIGN=CENTER><A HREF=\"tr_comments.php?triggerid=".$row["triggerid"]."\">Add</a></TD>"; } - if($row["istrue"] == 0) echo "</TR>\n"; + if($row["value"] == 0) echo "</TR>\n"; } echo "</TABLE>"; diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php index 4574ed83..c322cf92 100644 --- a/frontends/php/triggers.php +++ b/frontends/php/triggers.php @@ -41,10 +41,10 @@ if(validate_expression($expression)==0) { $now=mktime(); - if(isset($disabled)) { $istrue=2; } - else { $istrue=0; } + if(isset($disabled)) { $status=1; } + else { $status=0; } - $result=update_trigger($triggerid,$expression,$description,$priority,$istrue,$comments,$url); + $result=update_trigger($triggerid,$expression,$description,$priority,$status,$comments,$url); show_messages($result,"Trigger updated","Cannot update trigger"); } else @@ -57,10 +57,10 @@ { if(validate_expression($expression)==0) { - if(isset($disabled)) { $istrue=2; } - else { $istrue=3; } + if(isset($disabled)) { $status=1; } + else { $status=0; } - $result=add_trigger($expression,$description,$priority,$istrue,$comments,$url); + $result=add_trigger($expression,$description,$priority,$status,$comments,$url); show_messages($result,"Trigger added","Cannot add trigger"); } else @@ -110,7 +110,7 @@ if(isset($hostid)&&!isset($triggerid)) { - $result=DBselect("select distinct h.hostid,h.host,t.triggerid,t.expression,t.description,t.istrue from triggers t,hosts h,items i,functions f where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and h.hostid=$hostid order by h.host,t.description"); + $result=DBselect("select distinct h.hostid,h.host,t.triggerid,t.expression,t.description,t.status,t.value from triggers t,hosts h,items i,functions f where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and h.hostid=$hostid order by h.host,t.description"); $lasthost=""; $col=0; while($row=DBfetch($result)) @@ -144,13 +144,13 @@ echo "<TD>".explode_exp($row["expression"],1)."</TD>"; echo "<TD>"; - if($row["istrue"] == 2) + if($row["status"] == 1) { - echo "<a href=\"triggers.php?register=changestatus&triggerid=".$row["triggerid"]."&status=3&hostid=".$row["hostid"]."\">Disabled</a>"; + echo "<a href=\"triggers.php?register=changestatus&triggerid=".$row["triggerid"]."&status=0&hostid=".$row["hostid"]."\">Disabled</a>"; } else { - echo "<a href=\"triggers.php?register=changestatus&triggerid=".$row["triggerid"]."&status=2&hostid=".$row["hostid"]."\">Enabled</a>"; + echo "<a href=\"triggers.php?register=changestatus&triggerid=".$row["triggerid"]."&status=1&hostid=".$row["hostid"]."\">Enabled</a>"; } $expression=rawurlencode($row["expression"]); echo "</TD>"; diff --git a/include/common.h b/include/common.h index f2e8745b..fc934949 100644 --- a/include/common.h +++ b/include/common.h @@ -27,11 +27,20 @@ #define HOST_STATUS_UNREACHABLE 2 /* Trigger statuses */ -#define TRIGGER_STATUS_FALSE 0 +/*#define TRIGGER_STATUS_FALSE 0 #define TRIGGER_STATUS_TRUE 1 #define TRIGGER_STATUS_DISABLED 2 #define TRIGGER_STATUS_UNKNOWN 3 -#define TRIGGER_STATUS_NOTSUPPORTED 4 +#define TRIGGER_STATUS_NOTSUPPORTED 4*/ + +/* Trigger statuses */ +#define TRIGGER_STATUS_ENABLED 0 +#define TRIGGER_STATUS_DISABLED 1 + +/* Trigger values */ +#define TRIGGER_VALUE_FALSE 0 +#define TRIGGER_VALUE_TRUE 1 +#define TRIGGER_VALUE_UNKNOWN 2 /* Media statuses */ #define MEDIA_STATUS_ACTIVE 0 diff --git a/include/db.c b/include/db.c index 95d4b2e2..2e75c08b 100644 --- a/include/db.c +++ b/include/db.c @@ -250,7 +250,7 @@ int latest_alarm(int triggerid, int status) zabbix_log(LOG_LEVEL_DEBUG,"In latest_alarm(1)"); DBfree_result(result); - sprintf(sql,"select istrue from alarms where triggerid=%d and clock=%d",triggerid,clock); + sprintf(sql,"select value from alarms where triggerid=%d and clock=%d",triggerid,clock); zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql); result = DBselect(sql); if(DBnum_rows(result)==1) @@ -280,7 +280,7 @@ int DBadd_alarm(int triggerid, int status) } now=time(NULL); - sprintf(sql,"insert into alarms(triggerid,clock,istrue) values(%d,%d,%d)",triggerid,now,status); + sprintf(sql,"insert into alarms(triggerid,clock,value) values(%d,%d,%d)",triggerid,now,status); zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql); DBexecute(sql); @@ -289,18 +289,18 @@ int DBadd_alarm(int triggerid, int status) return SUCCEED; } -int update_trigger_status(int triggerid,int status) +int update_trigger_value(int triggerid,int value) { char sql[MAX_STRING_LEN+1]; - zabbix_log(LOG_LEVEL_DEBUG,"In update_trigger_status()"); - DBadd_alarm(triggerid,status); + zabbix_log(LOG_LEVEL_DEBUG,"In update_trigger_value()"); + DBadd_alarm(triggerid,value); - sprintf(sql,"update triggers set istrue=%d where triggerid=%d",status,triggerid); + sprintf(sql,"update triggers set value=%d where triggerid=%d",value,triggerid); zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql); DBexecute(sql); - zabbix_log(LOG_LEVEL_DEBUG,"End of update_trigger_status()"); + zabbix_log(LOG_LEVEL_DEBUG,"End of update_trigger_value()"); return SUCCEED; } @@ -328,7 +328,7 @@ int update_triggers_status_to_unknown(int hostid) for(i=0;i<DBnum_rows(result);i++) { triggerid=atoi(DBget_field(result,i,0)); - update_trigger_status(triggerid,TRIGGER_STATUS_UNKNOWN); + update_trigger_value(triggerid,TRIGGER_VALUE_UNKNOWN); } DBfree_result(result); diff --git a/include/db.h b/include/db.h index 72fbb329..440f9eb7 100644 --- a/include/db.h +++ b/include/db.h @@ -82,7 +82,8 @@ DB_TRIGGER int triggerid; char *expression; char *description; - int istrue; + int status; + int value; int priority; }; diff --git a/include/functions.c b/include/functions.c index b78a8718..7599b3f2 100644 --- a/include/functions.c +++ b/include/functions.c @@ -476,7 +476,7 @@ void apply_actions(int triggerid,int good) { zabbix_log( LOG_LEVEL_DEBUG, "Check dependencies"); - sprintf(sql,"select count(*) from trigger_depends d,triggers t where d.triggerid_down=%d and d.triggerid_up=t.triggerid and t.istrue=%d",triggerid, TRIGGER_STATUS_TRUE); + sprintf(sql,"select count(*) from trigger_depends d,triggers t where d.triggerid_down=%d and d.triggerid_up=t.triggerid and t.value=%d",triggerid, TRIGGER_VALUE_TRUE); result = DBselect(sql); if(DBis_empty(result) == FAIL) { @@ -620,11 +620,11 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock ) { now=time(NULL); /* Added table hosts to eliminate unnecessary update of triggers */ - sprintf(sql,"select t.triggerid,t.expression,t.istrue,t.dep_level,t.priority from triggers t,functions f,items i,hosts h where i.hostid=h.hostid and i.status<>3 and i.itemid=f.itemid and i.lastclock<=%d and t.istrue!=2 and f.triggerid=t.triggerid and f.itemid%%%d=%d and (h.status=0 or (h.status=2 and h.disable_until<%d)) group by t.triggerid,t.expression,t.istrue,t.dep_level",lastclock,suckers-1,sucker_num-1,now); + sprintf(sql,"select t.triggerid,t.expression,t.status,t.dep_level,t.priority,t.value from triggers t,functions f,items i,hosts h where i.hostid=h.hostid and i.status<>3 and i.itemid=f.itemid and i.lastclock<=%d and t.status=%d and f.triggerid=t.triggerid and f.itemid%%%d=%d and (h.status=0 or (h.status=2 and h.disable_until<%d)) group by t.triggerid,t.expression,t.dep_level",lastclock,TRIGGER_STATUS_ENABLED,suckers-1,sucker_num-1,now); } else { - sprintf(sql,"select t.triggerid,t.expression,t.istrue,t.dep_level,t.priority from triggers t,functions f,items i where i.status<>3 and i.itemid=f.itemid and t.istrue!=2 and f.triggerid=t.triggerid and f.itemid=%d group by t.triggerid,t.expression,t.istrue,t.dep_level",sucker_num); + sprintf(sql,"select t.triggerid,t.expression,t.status,t.dep_level,t.priority,t.value from triggers t,functions f,items i where i.status<>3 and i.itemid=f.itemid and t.status=%d and f.triggerid=t.triggerid and f.itemid=%d group by t.triggerid,t.expression,t.dep_level",TRIGGER_STATUS_ENABLED,sucker_num); } result = DBselect(sql); @@ -638,11 +638,11 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock ) for(i=0;i<DBnum_rows(result);i++) { - zabbix_log( LOG_LEVEL_DEBUG, "Fetched: TrId[%s] Exp[%s] IsTrue[%s]\n", DBget_field(result,i,0),DBget_field(result,i,1),DBget_field(result,i,2)); trigger.triggerid=atoi(DBget_field(result,i,0)); trigger.expression=DBget_field(result,i,1); - trigger.istrue=atoi(DBget_field(result,i,2)); + trigger.status=atoi(DBget_field(result,i,2)); trigger.priority=atoi(DBget_field(result,i,4)); + trigger.value=atoi(DBget_field(result,i,5)); strncpy(exp, trigger.expression, MAX_STRING_LEN); if( evaluate_expression(&b, exp) != 0 ) { @@ -652,15 +652,15 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock ) if(b==1) { - if(trigger.istrue!=TRIGGER_STATUS_TRUE) + if(trigger.value != TRIGGER_VALUE_TRUE) { now = time(NULL); - sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_TRUE,now,trigger.triggerid); + sprintf(sql,"update triggers set value=%d, lastchange=%d where triggerid=%d",TRIGGER_VALUE_TRUE,now,trigger.triggerid); DBexecute(sql); - DBadd_alarm(trigger.triggerid, TRIGGER_STATUS_FALSE); + DBadd_alarm(trigger.triggerid, TRIGGER_VALUE_FALSE); } - if(trigger.istrue==TRIGGER_STATUS_FALSE) + if(trigger.value == TRIGGER_VALUE_FALSE) { now = time(NULL); apply_actions(trigger.triggerid,1); @@ -674,16 +674,16 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock ) if(b==0) { - if(trigger.istrue!=TRIGGER_STATUS_FALSE) + if(trigger.value != TRIGGER_VALUE_FALSE) { now = time(NULL); - sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_FALSE,now,trigger.triggerid); + sprintf(sql,"update triggers set value=%d, lastchange=%d where triggerid=%d",TRIGGER_VALUE_FALSE,now,trigger.triggerid); DBexecute(sql); - DBadd_alarm(trigger.triggerid, TRIGGER_STATUS_FALSE); + DBadd_alarm(trigger.triggerid, TRIGGER_VALUE_FALSE); } - if(trigger.istrue==TRIGGER_STATUS_TRUE) + if(trigger.value == TRIGGER_VALUE_TRUE) { apply_actions(trigger.triggerid,0); diff --git a/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql b/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql index eb81b048..4c2824c1 100644 --- a/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql +++ b/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql @@ -1,2 +1,20 @@ update config set alert_history=alert_history/(24*3600); update config set alarm_history=alarm_history/(24*3600); + +alter table triggers add status int(4) DEFAULT '0' NOT NULL; +alter table triggers add value int(4) DEFAULT '0' NOT NULL; + +update triggers set status=0 where istrue in (0,1,3); +update triggers set status=1 where istrue in (2); +update triggers set status=2 where istrue in (4); + +update triggers set value=0 where istrue in (0); +update triggers set value=1 where istrue in (1); +update triggers set value=2 where istrue in (2,3,4); + +alter table triggers drop istrue; + +alter table alarms add value int(4) DEFAULT '0' NOT NULL; +update alarms set value=0 where istrue in (0); +update alarms set value=1 where istrue in (1); +update alarms set value=2 where istrue not in (0,1); |