summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-12-15 18:04:42 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-12-15 18:04:42 +0000
commite7c29909dff6f936e220bc2b05eb7a3e6776dec1 (patch)
tree8b2534dd6a5efc3936d504f7de27249a321242a3
parent1f8cfaaeb9f90817933674ae9b56ae4398455911 (diff)
- in case of network error, zabbix_suckerd will not try to request any parameters
from the host during next 120 seconds (Alexei) - added directory upgrades/dbpatches/1.0alpha12_to_1.0beta1 (Alexei) - added column disabled_until to table hosts (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@264 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog5
-rw-r--r--create/mysql/schema.sql2
-rw-r--r--create/postgresql/schema.sql1
-rw-r--r--doc/manual.lyx55
-rw-r--r--frontends/php/graph.html2
-rw-r--r--frontends/php/hosts.html2
-rw-r--r--frontends/php/include/config.inc2
-rw-r--r--frontends/php/latest.html4
-rw-r--r--frontends/php/map.html4
-rw-r--r--frontends/php/queue.html2
-rw-r--r--frontends/php/report2.html2
-rw-r--r--frontends/php/tr_status.html2
-rw-r--r--include/db.h1
-rw-r--r--src/zabbix_sucker/zabbix_sucker.c37
-rw-r--r--upgrades/dbpatches/1.0alpha12_to_1.0beta1/mysql/patch.sql1
-rw-r--r--upgrades/dbpatches/1.0alpha12_to_1.0beta1/postgresql/patch.sql1
16 files changed, 102 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e7e86e8..12761479 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
Changes for 1.0beta1:
+ - in case of network error, zabbix_suckerd will not try to request any parameters
+ from the host during next 120 seconds (Alexei)
+ - added directory upgrades/dbpatches/1.0alpha12_to_1.0beta1 (Alexei)
+ - added column disabled_until to table hosts (Alexei)
+
- modified SQL statements in both report2.html and graph2.html. Thanks
to Oliver Siegmar. (Alexei)
- added support of audible notification (Alexei)
diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql
index 926e93c1..59f20d16 100644
--- a/create/mysql/schema.sql
+++ b/create/mysql/schema.sql
@@ -175,6 +175,8 @@ CREATE TABLE hosts (
ip varchar(15) DEFAULT '127.0.0.1' NOT NULL,
port int(4) DEFAULT '0' NOT NULL,
status int(4) DEFAULT '0' NOT NULL,
+# If status=UNREACHABLE, host will not be checked until
+ disabled_until int(4) DEFAULT '0' NOT NULL,
PRIMARY KEY (hostid),
KEY (status)
);
diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql
index 504dac74..606dafd2 100644
--- a/create/postgresql/schema.sql
+++ b/create/postgresql/schema.sql
@@ -11,6 +11,7 @@ CREATE TABLE hosts (
ip varchar(15) DEFAULT '127.0.0.1' NOT NULL,
port int4 DEFAULT '0' NOT NULL,
status int4 DEFAULT '0' NOT NULL,
+ disabled_until int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (hostid)
);
diff --git a/doc/manual.lyx b/doc/manual.lyx
index 11dcf58a..5679ffee 100644
--- a/doc/manual.lyx
+++ b/doc/manual.lyx
@@ -1282,6 +1282,20 @@ Status of Triggers
\end_inset
+\layout Itemize
+
+Added audible notification to form
+\begin_inset Quotes eld
+\end_inset
+
+Status of Triggers
+\begin_inset Quotes erd
+\end_inset
+
+
+\layout Itemize
+
+?????
\layout Subsection
ChangeLog
@@ -1687,12 +1701,17 @@ The zabbix_suckerd process periodically connects to agents (either Zabbix
\layout Standard
If zabbix_suckerd is unable to get value from an agent because of network
- problems, the value will be checked next time only after DELAY_ON_NETWORK_ERROR
- (defined in
+ problems, the
+\shape italic
+host
+\shape default
+ will be checked next time only after DELAY_ON_NETWORK_ERROR (defined in
+
\shape italic
include/common.h
\shape default
, default value is 120) seconds.
+ Host status will be updated to UNREACHABLE.
\layout Standard
If an agent does not support requested parameter, zabbix_suckerd will change
@@ -9044,7 +9063,7 @@ HOSTS The table contains list of monitored Hosts
\begin_inset Tabular
-<lyxtabular version="2" rows="4" columns="3">
+<lyxtabular version="2" rows="5" columns="3">
<features rotate="false" islongtable="false" endhead="0" endfirsthead="0" endfoot="0" endlastfoot="0">
<column alignment="center" valignment="top" leftline="true" rightline="false" width="" special="">
<column alignment="center" valignment="top" leftline="true" rightline="false" width="" special="">
@@ -9141,7 +9160,33 @@ status
\layout Standard
-vint
+int
+\end_inset
+</cell>
+<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
+\begin_inset Text
+
+\layout Standard
+
+Host status: 0 - monitored, 1 - not monitored, 2 - unreachable
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true" newpage="false">
+<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+\begin_inset Text
+
+\layout Standard
+
+disabled_until
+\end_inset
+</cell>
+<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+\begin_inset Text
+
+\layout Standard
+
+int
\end_inset
</cell>
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
@@ -9149,7 +9194,7 @@ vint
\layout Standard
-Host status: 0 - monitored, 1 - not monitored
+In case if status is unreachabe, do not check host until this time
\end_inset
</cell>
</row>
diff --git a/frontends/php/graph.html b/frontends/php/graph.html
index 15d99787..97ba4ce5 100644
--- a/frontends/php/graph.html
+++ b/frontends/php/graph.html
@@ -94,7 +94,7 @@
echo "Parameter";
show_table2_h_delimiter();
- $result=DBselect("select h.host,i.description,i.itemid from hosts h,items i where h.hostid=i.hostid and h.status=0 and i.status in (0,2) order by h.host,i.description");
+ $result=DBselect("select h.host,i.description,i.itemid from hosts h,items i where h.hostid=i.hostid and h.status in (0,2) and i.status in (0,2) order by h.host,i.description");
echo "<select name=\"itemid\" size=1>";
for($i=0;$i<DBnum_rows($result);$i++)
{
diff --git a/frontends/php/hosts.html b/frontends/php/hosts.html
index f6c019cd..87ab8dcf 100644
--- a/frontends/php/hosts.html
+++ b/frontends/php/hosts.html
@@ -72,6 +72,8 @@
echo "<a href=\"hosts.html?hostid=$hostid_&register=changestatus&status=1\">Monitored</a>";
else if($status_ == 1)
echo "<a href=\"hosts.html?hostid=$hostid_&register=changestatus&status=0\">Not monitored</a>";
+ else if($status_ == 2)
+ echo "Unreachable";
else
echo "Unknown";
echo "</TD>";
diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc
index ff36111f..4586397b 100644
--- a/frontends/php/include/config.inc
+++ b/frontends/php/include/config.inc
@@ -1320,7 +1320,7 @@
{
$useip=0;
}
- $sql="insert into hosts (host,port,status,useip,ip) values ('$host',$port,$status,$useip,'$ip')";
+ $sql="insert into hosts (host,port,status,useip,ip,disable_until) values ('$host',$port,$status,$useip,'$ip',0)";
$result=DBexecute($sql);
if(!$result)
{
diff --git a/frontends/php/latest.html b/frontends/php/latest.html
index 067d1a91..10a32b43 100644
--- a/frontends/php/latest.html
+++ b/frontends/php/latest.html
@@ -13,7 +13,7 @@
echo "<font size=2>";
- $result=DBselect("select h.hostid,h.host from hosts h,items i where h.status=0 and h.hostid=i.hostid group by h.hostid,h.host order by h.host");
+ $result=DBselect("select h.hostid,h.host from hosts h,items i where h.status in (0,2) and h.hostid=i.hostid group by h.hostid,h.host order by h.host");
for($i=0;$i<DBnum_rows($result);$i++)
{
@@ -75,7 +75,7 @@
$col=0;
- $result=DBselect("select h.host,i.itemid,i.description,i.lastvalue,i.prevvalue,i.lastclock,i.status,h.hostid from items i,hosts h where h.hostid=i.hostid and h.status=0 and h.hostid=$hostid order by h.host,i.description");
+ $result=DBselect("select h.host,i.itemid,i.description,i.lastvalue,i.prevvalue,i.lastclock,i.status,h.hostid from items i,hosts h where h.hostid=i.hostid and h.status in (0,2) and h.hostid=$hostid order by h.host,i.description");
for($i=0;$i<DBnum_rows($result);$i++)
{
$host=DBget_field($result,$i,0);
diff --git a/frontends/php/map.html b/frontends/php/map.html
index 0a0511aa..dce478e0 100644
--- a/frontends/php/map.html
+++ b/frontends/php/map.html
@@ -111,12 +111,12 @@
}
else
{
- $result1=DBselect("select count(*) from items i,functions f,triggers t,hosts h where h.hostid=i.hostid and i.hostid=$hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.istrue=1 and h.status=0 and i.status=0");
+ $result1=DBselect("select count(*) from items i,functions f,triggers t,hosts h where h.hostid=i.hostid and i.hostid=$hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.istrue=1 and h.status in (0,2) and i.status=0");
$count=DBget_field($result1,0,0);
if($count==1)
{
$color=$red;
- $result1=DBselect("select t.description from items i,functions f,triggers t,hosts h where h.hostid=i.hostid and i.hostid=$hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.istrue=1 and h.status=0 and i.status=0");
+ $result1=DBselect("select t.description from items i,functions f,triggers t,hosts h where h.hostid=i.hostid and i.hostid=$hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.istrue=1 and h.status (0,2) and i.status=0");
$label=DBget_field($result1,0,0);
}
else if($count>1)
diff --git a/frontends/php/queue.html b/frontends/php/queue.html
index 9ce1a7ff..62b59da8 100644
--- a/frontends/php/queue.html
+++ b/frontends/php/queue.html
@@ -15,7 +15,7 @@
?>
<?
$now=time();
- $result=DBselect("select i.itemid, i.nextcheck, i.description, h.host from items i,hosts h where i.status=0 and h.status=0 and i.hostid=h.hostid and i.nextcheck<$now order by i.nextcheck");
+ $result=DBselect("select i.itemid, i.nextcheck, i.description, h.host from items i,hosts h where i.status in (0,2) and h.status=0 and i.hostid=h.hostid and i.nextcheck<$now order by i.nextcheck");
echo "<table border=0 width=100% bgcolor='#CCCCCC' cellspacing=1 cellpadding=3>";
echo "\n";
echo "<tr><td><b>Next time to check</b></td><td><b>Host</b></td><td><b>Description</b></td></tr>";
diff --git a/frontends/php/report2.html b/frontends/php/report2.html
index 22747483..18806ae1 100644
--- a/frontends/php/report2.html
+++ b/frontends/php/report2.html
@@ -26,7 +26,7 @@
<?
- $result=DBselect("select 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.istrue!=2 and t.triggerid=f.triggerid and h.status=0 and i.status=0 order by h.host,t.lastchange desc, t.description");
+ $result=DBselect("select 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.istrue!=2 and t.triggerid=f.triggerid and h.status in (0,2) and i.status=0 order by h.host,t.lastchange desc, t.description");
$lasthost="";
$col=0;
diff --git a/frontends/php/tr_status.html b/frontends/php/tr_status.html
index 3cf886ce..7b42a64f 100644
--- a/frontends/php/tr_status.html
+++ b/frontends/php/tr_status.html
@@ -68,7 +68,7 @@
echo "STATUS OF TRIGGERS";
show_table_v_delimiter();
- $result=DBselect("select hostid,host from hosts where status=0 order by host");
+ $result=DBselect("select hostid,host from hosts where status in (0,2) order by host");
if(isset($hostid))
{
echo "<A HREF=\"tr_status.html?onlytrue=$onlytrue&noactions=$noactions&compact=$compact\">all</A> ";
diff --git a/include/db.h b/include/db.h
index 5d0d56ce..2a71f2f2 100644
--- a/include/db.h
+++ b/include/db.h
@@ -35,6 +35,7 @@
DB_ITEM
{
int itemid;
+ int hostid;
int type;
char *description;
char *key;
diff --git a/src/zabbix_sucker/zabbix_sucker.c b/src/zabbix_sucker/zabbix_sucker.c
index fe64ab5f..cb7a4ba0 100644
--- a/src/zabbix_sucker/zabbix_sucker.c
+++ b/src/zabbix_sucker/zabbix_sucker.c
@@ -321,7 +321,7 @@ int get_value(double *result,DB_ITEM *item)
return res;
}
-int get_minnextcheck(void)
+int get_minnextcheck(int now)
{
char c[1024];
@@ -330,7 +330,7 @@ int get_minnextcheck(void)
int res;
int count;
- sprintf(c,"select count(*),min(nextcheck) from items i,hosts h where i.status=0 and h.status=0 and h.hostid=i.hostid and i.status=0 and i.itemid%%%d=%d",SUCKER_FORKS-1,sucker_num-1);
+ sprintf(c,"select count(*),min(nextcheck) from items i,hosts h where i.status=0 and (h.status=0 or (h.status=2 and h.disable_until<%d)) and h.hostid=i.hostid and i.status=0 and i.itemid%%%d=%d",now,SUCKER_FORKS-1,sucker_num-1);
result = DBselect(c);
if(result==NULL)
@@ -375,9 +375,11 @@ int get_values(void)
DB_ITEM item;
char *s;
+ int host_status;
+
now = time(NULL);
- sprintf(c,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue from items i,hosts h where i.nextcheck<=%d and i.status=0 and h.status=0 and h.hostid=i.hostid and i.itemid%%%d=%d order by i.nextcheck", now, SUCKER_FORKS-1,sucker_num-1);
+ sprintf(c,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status from items i,hosts h where i.nextcheck<=%d and i.status=0 and (h.status=0 or (h.status=2 and h.disable_until<%d)) and h.hostid=i.hostid and i.itemid%%%d=%d order by i.nextcheck", now, now, SUCKER_FORKS-1,sucker_num-1);
result = DBselect(c);
rows = DBnum_rows(result);
@@ -423,26 +425,47 @@ int get_values(void)
item.prevvalue_null=0;
item.prevvalue=atof(s);
}
-
+ item.hostid=atoi(DBget_field(result,i,15));
+ host_status=atoi(DBget_field(result,i,16));
res = get_value(&value,&item);
if(res == SUCCEED )
{
process_new_value(&item,value);
+ if(2 == host_status)
+ {
+ host_status=0;
+ syslog( LOG_WARNING, "Enabling host [%s]", item.host );
+ sprintf(c,"update hosts set status=0 where hostid=%d",item.hostid);
+ DBexecute(c);
+
+ break;
+ }
}
else if(res == NOTSUPPORTED)
{
syslog( LOG_WARNING, "Parameter [%s] is not supported by agent on host [%s]", item.key, item.host );
sprintf(c,"update items set status=3 where itemid=%d",item.itemid);
DBexecute(c);
+ if(2 == host_status)
+ {
+ host_status=0;
+ syslog( LOG_WARNING, "Enabling host [%s]", item.host );
+ sprintf(c,"update hosts set status=0 where hostid=%d",item.hostid);
+ DBexecute(c);
+
+ break;
+ }
}
else if(res == NETWORK_ERROR)
{
- syslog( LOG_WARNING, "Parameter [%s] will be checked after [%d] seconds", item.key, DELAY_ON_NETWORK_FAILURE );
+ syslog( LOG_WARNING, "Host [%s] will be checked after [%d] seconds", item.host, DELAY_ON_NETWORK_FAILURE );
now=time(NULL);
- sprintf(c,"update items set nextcheck=%d where itemid=%d",now+DELAY_ON_NETWORK_FAILURE,item.itemid);
+ sprintf(c,"update hosts set status=2,disable_until=%d where hostid=%d",now+DELAY_ON_NETWORK_FAILURE,item.hostid);
DBexecute(c);
+
+ break;
}
else
{
@@ -557,7 +580,7 @@ int main_sucker_loop()
syslog( LOG_DEBUG, "Spent %d seconds while updating values", (int)time(NULL)-now );
- nextcheck=get_minnextcheck();
+ nextcheck=get_minnextcheck(now);
syslog( LOG_DEBUG, "Nextcheck:%d Time:%d", nextcheck, (int)time(NULL) );
if( FAIL == nextcheck)
diff --git a/upgrades/dbpatches/1.0alpha12_to_1.0beta1/mysql/patch.sql b/upgrades/dbpatches/1.0alpha12_to_1.0beta1/mysql/patch.sql
new file mode 100644
index 00000000..bb5675f5
--- /dev/null
+++ b/upgrades/dbpatches/1.0alpha12_to_1.0beta1/mysql/patch.sql
@@ -0,0 +1 @@
+alter table hosts add disable_until int(4) default '0' not null;
diff --git a/upgrades/dbpatches/1.0alpha12_to_1.0beta1/postgresql/patch.sql b/upgrades/dbpatches/1.0alpha12_to_1.0beta1/postgresql/patch.sql
new file mode 100644
index 00000000..dae13e7d
--- /dev/null
+++ b/upgrades/dbpatches/1.0alpha12_to_1.0beta1/postgresql/patch.sql
@@ -0,0 +1 @@
+alter table hosts add disable_until int4 default '0' not null;