summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--create/mysql/schema.sql2
-rw-r--r--create/postgresql/schema.sql4
-rw-r--r--frontends/php/alarms.php2
-rw-r--r--frontends/php/include/config.inc63
-rw-r--r--frontends/php/index.php2
-rw-r--r--frontends/php/latestalarms.php4
-rw-r--r--frontends/php/report2.php4
-rw-r--r--frontends/php/services.php37
-rw-r--r--frontends/php/tr_status.php6
-rw-r--r--frontends/php/triggers.php4
-rw-r--r--include/functions.c58
-rw-r--r--misc/conf/zabbix_trapperd.conf4
-rw-r--r--upgrades/dbpatches/1.0beta2_to_1.0beta3/mysql/patch.sql13
-rw-r--r--upgrades/dbpatches/1.0beta2_to_1.0beta3/postgresql/patch.sql10
15 files changed, 174 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c8fea8e..b5ff2efc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,6 @@ Not ready yet:
[ CORE. Support for automake ]
[ CORE. Support for Service Tree ]
-[ CORE. Support for flexible permissions ]
[ CORE. Make Zabbix compile by cc ]
@@ -16,6 +15,7 @@ Not ready yet:
Changes for 1.0beta3:
+ - support for new trigger status - UNKNOWN (Alexei)
- zabbix_suckerd housekeeping process to disconnect from
DB when unactive (Alexei)
- support for check_service[http] (Alexei)
diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql
index e76a11ce..3495d259 100644
--- a/create/mysql/schema.sql
+++ b/create/mysql/schema.sql
@@ -15,9 +15,11 @@ CREATE TABLE services (
--
CREATE TABLE services_links (
+ linkid int(4) NOT NULL auto_increment,
serviceupid int(4) DEFAULT '0' NOT NULL,
servicedownid int(4) DEFAULT '0' NOT NULL,
soft int(1) DEFAULT '0' NOT NULL,
+ PRIMARY KEY (linkid),
KEY (serviceupid),
KEY (servicedownid),
UNIQUE (serviceupid,servicedownid)
diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql
index ae0d476f..3c6195d4 100644
--- a/create/postgresql/schema.sql
+++ b/create/postgresql/schema.sql
@@ -349,9 +349,11 @@ CREATE TABLE services (
--
CREATE TABLE services_links (
+ linkid serial,
serviceupid int4 DEFAULT '0' NOT NULL,
servicedownid int4 DEFAULT '0' NOT NULL,
- soft int2 DEFAULT '0' NOT NULL
+ soft int2 DEFAULT '0' NOT NULL,
+ PRIMARY KEY (linkid)
);
CREATE INDEX services_links_serviceupid on services_links (serviceupid);
diff --git a/frontends/php/alarms.php b/frontends/php/alarms.php
index 181b8e46..22c45818 100644
--- a/frontends/php/alarms.php
+++ b/frontends/php/alarms.php
@@ -112,7 +112,7 @@
}
elseif($row["status"]==3)
{
- $istrue="MODIFIED";
+ $istrue="UNKNOWN";
$dissum=$dissum+$leng;
$sum=$dissum;
}
diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc
index fc13560c..e2676aa8 100644
--- a/frontends/php/include/config.inc
+++ b/frontends/php/include/config.inc
@@ -1099,6 +1099,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
function update_trigger_status($triggerid,$status)
{
+ add_alarm($triggerid,3);
$sql="update triggers set istrue=$status where triggerid=$triggerid";
return DBexecute($sql);
}
@@ -1494,6 +1495,22 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
function add_alarm($triggerid,$istrue)
{
+ $sql="select max(clock) from alarms";
+ $result=DBselect($sql);
+ if(DBnum_rows($result) == 1)
+ {
+ $row=DBfetch($result);
+ $sql="select istrue from alarms where clock=".$row[0];
+ $result=DBselect($sql);
+ if(DBnum_rows($result) == 1)
+ {
+ $row=DBfetch($result);
+ if($row["istrue"] == $istrue)
+ {
+ return 0;
+ }
+ }
+ }
$now=time();
$sql="insert into alarms(triggerid,clock,istrue) values($triggerid,$now,$istrue)";
return DBexecute($sql);
@@ -1505,11 +1522,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
{
global $ERROR_MSG;
- if(!check_right("Trigger","A",0))
- {
- $ERROR_MSG="Insufficient permissions";
- return 0;
- }
+// if(!check_right("Trigger","A",0))
+// {
+// $ERROR_MSG="Insufficient permissions";
+// return 0;
+// }
$description=addslashes($description);
$sql="insert into triggers (description,priority,istrue,comments,url) values ('$description',$priority,$istrue,'$comments','$url')";
@@ -1522,6 +1539,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);
$expression=implode_exp($expression,$triggerid);
$sql="update triggers set expression='$expression' where triggerid=$triggerid";
@@ -1575,7 +1593,14 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
}
$expression=implode_exp($expression,$triggerid);
- if($istrue != 2) $istrue="istrue";
+ 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";
return DBexecute($sql);
}
@@ -2612,7 +2637,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
$expression="";
$description="";
$priority=0;
- $istrue=0;
+ $istrue=3;
$comments="";
$url="";
}
@@ -2817,6 +2842,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
$state=-1;
$true_time=0;
$false_time=0;
+ $unknown_time=0;
$time=$min;
$max=time();
for($i=0;$i<DBnum_rows($result);$i++)
@@ -2839,6 +2865,10 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
{
$true_time+=$diff;
}
+ if($state == 3)
+ {
+ $unknown_time+=$diff;
+ }
}
else if($state==0)
{
@@ -2850,6 +2880,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
$true_time+=$diff;
$state=$istrue;
}
+ else if($state==3)
+ {
+ $unknown_time+=$diff;
+ $state=$istrue;
+ }
}
if(DBnum_rows($result)==0)
@@ -2862,16 +2897,24 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
{
$false_time=$false_time+$max-$time;
}
- else
+ elseif($state==1)
{
$true_time=$true_time+$max-$time;
}
+ elseif($state==3)
+ {
+ $unknown_time=$unknown_time+$max-$time;
+ }
+
}
+ $total_time=$true_time+$false_time+$unknown_time;
$ret["true_time"]=$true_time;
$ret["false_time"]=$false_time;
- $ret["true"]=(100*$true_time)/($true_time+$false_time);
- $ret["false"]=(100*$false_time)/($true_time+$false_time);
+ $ret["unknown_time"]=$unknown_time;
+ $ret["true"]=(100*$true_time)/$total_time;
+ $ret["false"]=(100*$false_time)/$total_time;
+ $ret["unknown"]=(100*$unknown_time)/$total_time;
return $ret;
}
diff --git a/frontends/php/index.php b/frontends/php/index.php
index 6e0916e3..b650668e 100644
--- a/frontends/php/index.php
+++ b/frontends/php/index.php
@@ -11,8 +11,6 @@
echo "<center>";
echo "<font face=\"arial,helvetica\" size=2>";
echo "Connected as ".$USER_DETAILS["alias"]."</b>";
- echo "<br>";
- echo "<a href=\"index.php?reconnect=1\">RECONNECT</a>";
echo "</font>";
echo "</center>";
?>
diff --git a/frontends/php/latestalarms.php b/frontends/php/latestalarms.php
index b779d3bc..751ecd2a 100644
--- a/frontends/php/latestalarms.php
+++ b/frontends/php/latestalarms.php
@@ -66,6 +66,10 @@
{
echo "<TD><font color=\"00AA00\">OFF</font></TD>";
}
+ elseif($row["istrue"] == 3)
+ {
+ echo "<TD><font color=\"AAAAAA\">UNKNOWN</font></TD>";
+ }
else
{
echo "<TD><font color=\"AA0000\">ON</font></TD>";
diff --git a/frontends/php/report2.php b/frontends/php/report2.php
index 5a785633..2a298568 100644
--- a/frontends/php/report2.php
+++ b/frontends/php/report2.php
@@ -45,6 +45,7 @@
echo "<TD><B>Expression</B></TD>";
echo "<TD WIDTH=\"5%\"><B>True (%)</B></TD>";
echo "<TD WIDTH=\"5%\"><B>False (%)</B></TD>";
+ echo "<TD WIDTH=\"5%\"><B>Unknown (%)</B></TD>";
echo "</TR>\n";
}
$lasthost=$row["host"];
@@ -63,6 +64,9 @@
echo "<TD>";
printf("%.4f%%",$availability["false"]);
echo "</TD>";
+ echo "<TD>";
+ printf("%.4f%%",$availability["unknown"]);
+ echo "</TD>";
echo "</TR>\n";
}
echo "</table>\n";
diff --git a/frontends/php/services.php b/frontends/php/services.php
index be2186f3..fe42e786 100644
--- a/frontends/php/services.php
+++ b/frontends/php/services.php
@@ -105,6 +105,43 @@
<?
if(isset($serviceid))
{
+ show_table_header("LINKS");
+ echo "<table border=0 width=100% bgcolor='#CCCCCC' cellspacing=1 cellpadding=3>";
+ echo "<tr>";
+ echo "<td><b>Service 1</b></td>";
+ echo "<td><b>Service 2</b></td>";
+ echo "<td><b>Soft/hard link</b></td>";
+ echo "<td><b>Actions</b></td>";
+ echo "</tr>";
+ $sql="select servicedownid,serviceupid,soft from services_links where serviceupid=$serviceid or servicedownid=$serviceid";
+ $result=DBselect($sql);
+ $col=0;
+ while($row=DBfetch($result))
+ {
+ if($col++%2==0) { echo "<tr bgcolor=#EEEEEE>"; }
+ else { echo "<tr bgcolor=#DDDDDD>"; }
+ $service=get_service_by_serviceid($row["serviceupid"]);
+ echo "<td>".$service["name"]."</td>";
+ $service=get_service_by_serviceid($row["servicedownid"]);
+ echo "<td>".$service["name"]."</td>";
+ if($row["soft"] == 0)
+ {
+ echo "<td>Hard</td>";
+ }
+ else
+ {
+ echo "<td>Soft</td>";
+ }
+ echo "<td><a href=\"services.php?register=delete_link?\">".$service["name"]."</td>";
+ echo "</tr>";
+ }
+ echo "</table>";
+ }
+?>
+
+<?
+ if(isset($serviceid))
+ {
$result=DBselect("select serviceid,triggerid,name from services where serviceid=$serviceid");
$triggerid=DBget_field($result,0,1);
$name=DBget_field($result,0,2);
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index 034e1a9f..bbd7a52e 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -383,8 +383,12 @@
{ echo "<TD ALIGN=CENTER><FONT COLOR=\"00AA00\">FALSE</FONT></TD>";}
elseif($row["istrue"]==2)
{ echo "<TD ALIGN=CENTER><FONT COLOR=\"777777\">DISABLED</FONT></TD>"; }
- else
+ 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>"; }
if($row["priority"]==0) echo "<TD ALIGN=CENTER>Not classified</TD>";
elseif($row["priority"]==1) echo "<TD ALIGN=CENTER>Just information</TD>";
diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php
index a6dbb036..4574ed83 100644
--- a/frontends/php/triggers.php
+++ b/frontends/php/triggers.php
@@ -58,7 +58,7 @@
if(validate_expression($expression)==0)
{
if(isset($disabled)) { $istrue=2; }
- else { $istrue=0; }
+ else { $istrue=3; }
$result=add_trigger($expression,$description,$priority,$istrue,$comments,$url);
show_messages($result,"Trigger added","Cannot add trigger");
@@ -146,7 +146,7 @@
echo "<TD>";
if($row["istrue"] == 2)
{
- echo "<a href=\"triggers.php?register=changestatus&triggerid=".$row["triggerid"]."&status=0&hostid=".$row["hostid"]."\">Disabled</a>";
+ echo "<a href=\"triggers.php?register=changestatus&triggerid=".$row["triggerid"]."&status=3&hostid=".$row["hostid"]."\">Disabled</a>";
}
else
{
diff --git a/include/functions.c b/include/functions.c
index 80d74212..0f6485eb 100644
--- a/include/functions.c
+++ b/include/functions.c
@@ -631,40 +631,52 @@ void update_triggers( int suckers, int flag, int sucker_num, int lastclock )
continue;
}
- if((b==1)&&(trigger.istrue==TRIGGER_STATUS_FALSE))
+ if(b==1)
{
- now = time(NULL);
- sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_TRUE,now,trigger.triggerid);
- DBexecute(sql);
-
- now = time(NULL);
- sprintf(sql,"insert into alarms(triggerid,clock,istrue) values(%d,%d,%d)",trigger.triggerid,now,TRIGGER_STATUS_TRUE);
- DBexecute(sql);
+ if(trigger.istrue!=TRIGGER_STATUS_TRUE)
+ {
+ now = time(NULL);
+ sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_TRUE,now,trigger.triggerid);
+ DBexecute(sql);
- apply_actions(trigger.triggerid,1);
+ now = time(NULL);
+ sprintf(sql,"insert into alarms(triggerid,clock,istrue) values(%d,%d,%d)",trigger.triggerid,now,TRIGGER_STATUS_TRUE);
+ DBexecute(sql);
+ }
+ if(trigger.istrue==TRIGGER_STATUS_FALSE)
+ {
+ now = time(NULL);
+ apply_actions(trigger.triggerid,1);
- sprintf(sql,"update actions set nextcheck=0 where triggerid=%d and good=0",trigger.triggerid);
- DBexecute(sql);
+ sprintf(sql,"update actions set nextcheck=0 where triggerid=%d and good=0",trigger.triggerid);
+ DBexecute(sql);
- update_services(trigger.triggerid, 1);
+ update_services(trigger.triggerid, 1);
+ }
}
- if((b==0)&&(trigger.istrue==TRIGGER_STATUS_TRUE))
+ if(b==0)
{
- now = time(NULL);
- sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_FALSE,now,trigger.triggerid);
- DBexecute(sql);
+ if(trigger.istrue!=TRIGGER_STATUS_FALSE)
+ {
+ now = time(NULL);
+ sprintf(sql,"update triggers set istrue=%d, lastchange=%d where triggerid=%d",TRIGGER_STATUS_FALSE,now,trigger.triggerid);
+ DBexecute(sql);
- now = time(NULL);
- sprintf(sql,"insert into alarms(triggerid,clock,istrue) values(%d,%d,%d)",trigger.triggerid,now,TRIGGER_STATUS_FALSE);
- DBexecute(sql);
+ now = time(NULL);
+ sprintf(sql,"insert into alarms(triggerid,clock,istrue) values(%d,%d,%d)",trigger.triggerid,now,TRIGGER_STATUS_FALSE);
+ DBexecute(sql);
+ }
- apply_actions(trigger.triggerid,0);
+ if(trigger.istrue==TRIGGER_STATUS_TRUE)
+ {
+ apply_actions(trigger.triggerid,0);
- sprintf(sql,"update actions set nextcheck=0 where triggerid=%d and good=1",trigger.triggerid);
- DBexecute(sql);
+ sprintf(sql,"update actions set nextcheck=0 where triggerid=%d and good=1",trigger.triggerid);
+ DBexecute(sql);
- update_services(trigger.triggerid, 0);
+ update_services(trigger.triggerid, 0);
+ }
}
}
DBfree_result(result);
diff --git a/misc/conf/zabbix_trapperd.conf b/misc/conf/zabbix_trapperd.conf
index e9fb8a09..9b5948f0 100644
--- a/misc/conf/zabbix_trapperd.conf
+++ b/misc/conf/zabbix_trapperd.conf
@@ -54,3 +54,7 @@ DBUser=zabbix
# Connect to MySQL using Unix socket?
#DBSocket=/tmp/mysql.sock
+
+# Reconnect to DB for each value received
+
+DBConnectOnEach=1
diff --git a/upgrades/dbpatches/1.0beta2_to_1.0beta3/mysql/patch.sql b/upgrades/dbpatches/1.0beta2_to_1.0beta3/mysql/patch.sql
index 7c41ce34..0397af49 100644
--- a/upgrades/dbpatches/1.0beta2_to_1.0beta3/mysql/patch.sql
+++ b/upgrades/dbpatches/1.0beta2_to_1.0beta3/mysql/patch.sql
@@ -14,6 +14,19 @@ CREATE TABLE history_str (
);
drop table groups;
+drop table services_links;
+
+CREATE TABLE services_links (
+ linkid int(4) NOT NULL auto_increment,
+ serviceupid int(4) DEFAULT '0' NOT NULL,
+ servicedownid int(4) DEFAULT '0' NOT NULL,
+ soft int(1) DEFAULT '0' NOT NULL,
+ PRIMARY KEY (linkid),
+ KEY (serviceupid),
+ KEY (servicedownid),
+ UNIQUE (serviceupid,servicedownid)
+);
+
alter table users drop groupid;
alter table config drop password_required;
diff --git a/upgrades/dbpatches/1.0beta2_to_1.0beta3/postgresql/patch.sql b/upgrades/dbpatches/1.0beta2_to_1.0beta3/postgresql/patch.sql
index 87453faa..ad06c137 100644
--- a/upgrades/dbpatches/1.0beta2_to_1.0beta3/postgresql/patch.sql
+++ b/upgrades/dbpatches/1.0beta2_to_1.0beta3/postgresql/patch.sql
@@ -15,6 +15,16 @@ CREATE TABLE history_str (
);
drop table groups;
+drop table services_links;
+
+CREATE TABLE services_links (
+ linkid serial,
+ serviceupid int4 DEFAULT '0' NOT NULL,
+ servicedownid int4 DEFAULT '0' NOT NULL,
+ soft int2 DEFAULT '0' NOT NULL,
+ PRIMARY KEY (linkid)
+);
+
alter table users drop groupid;
alter table config drop password_required;