diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | TODO | 8 | ||||
-rw-r--r-- | create/mysql/schema.sql | 2 | ||||
-rw-r--r-- | create/postgresql/schema.sql | 2 | ||||
-rw-r--r-- | frontends/php/latest.php | 2 | ||||
-rwxr-xr-x | go | 3 | ||||
-rw-r--r-- | include/common.h | 9 | ||||
-rw-r--r-- | include/db.h | 6 | ||||
-rwxr-xr-x | src/alphacode/poller/go | 3 | ||||
-rw-r--r-- | src/alphacode/poller/poller_epoll.c | 20 | ||||
-rw-r--r-- | src/libs/zbxdbhigh/db.c | 12 | ||||
-rw-r--r-- | src/libs/zbxdbhigh/host.c | 4 | ||||
-rw-r--r-- | src/zabbix_server/poller/poller.c | 51 | ||||
-rw-r--r-- | src/zabbix_server/poller/poller.h | 1 | ||||
-rw-r--r-- | src/zabbix_server/server.c | 4 | ||||
-rw-r--r-- | upgrades/dbpatches/1.1beta5_to_1.1beta6/mysql/patch.sql | 5 | ||||
-rw-r--r-- | upgrades/dbpatches/1.1beta5_to_1.1beta6/postgresql/patch.sql | 3 |
17 files changed, 81 insertions, 57 deletions
@@ -1,5 +1,8 @@ Changes for 1.1beta6: + - added new server parameter UnavailablePeriod (Alexei) + - dropped column hosts.network_errors (Alexei) + - added column hosts.errors_from (Alexei) - GUI made immune to SQL injection attacks (Alexei) - added Check All functionality (Eugene) - added support of icon label locations (Alexei) @@ -1,12 +1,5 @@ 1.1beta6: - http://www.zabbix.com/forum/showthread.php?t=2073 - - E: http://www.zabbix.com/forum/showthread.php?t=2074 - - E: http://www.zabbix.com/forum/showthread.php?t=2072 - - E: php: http://www.zabbix.com/forum/showthread.php?t=1825 - - E: http://www.zabbix.com/forum/showthread.php?t=1997 - - E: dos style EOL: http://www.zabbix.com/forum/showthread.php?t=1993 - - E: http://www.zabbix.com/forum/showthread.php?t=1992 - - E: select all: http://www.zabbix.com/forum/showthread.php?t=2051 - http://www.zabbix.com/forum/showthread.php?t=2070 - moltiplier: http://www.zabbix.com/forum/showthread.php?t=2004 - actions: http://www.zabbix.com/forum/showthread.php?t=2063 @@ -15,7 +8,6 @@ - http://www.zabbix.com/forum/showthread.php?t=1657 - http://www.zabbix.com/forum/showthread.php?t=1971 - make failed: http://www.zabbix.com/forum/showthread.php?t=1957 - - check if ZABBIX server accepts values returned by W32 agent - set host to unrechable if unreachable within N seconds - explain how templates work in the documentation diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql index 20661a96..a7f67dc7 100644 --- a/create/mysql/schema.sql +++ b/create/mysql/schema.sql @@ -308,9 +308,9 @@ CREATE TABLE hosts ( status int(4) DEFAULT '0' NOT NULL, -- If status=UNREACHABLE, host will not be checked until this time disable_until int(4) DEFAULT '0' NOT NULL, - network_errors int(4) DEFAULT '0' NOT NULL, error varchar(128) DEFAULT '' NOT NULL, available int(4) DEFAULT '0' NOT NULL, + errors_from int(4) DEFAULT '0' NOT NULL, PRIMARY KEY (hostid), UNIQUE (host), KEY (status) diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql index 21f1de6b..b925fbac 100644 --- a/create/postgresql/schema.sql +++ b/create/postgresql/schema.sql @@ -31,9 +31,9 @@ CREATE TABLE hosts ( port int4 DEFAULT '0' NOT NULL, status int4 DEFAULT '0' NOT NULL, disable_until int4 DEFAULT '0' NOT NULL, - network_errors int4 DEFAULT '0' NOT NULL, error varchar(128) DEFAULT '' NOT NULL, available int4 DEFAULT '0' NOT NULL, + errors_from int4 DEFAULT '0' NOT NULL, PRIMARY KEY (hostid) ); diff --git a/frontends/php/latest.php b/frontends/php/latest.php index 7876376e..66215c58 100644 --- a/frontends/php/latest.php +++ b/frontends/php/latest.php @@ -42,7 +42,7 @@ "select"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL) ); - check_fields($fields); +// check_fields($fields); ?> <?php @@ -28,7 +28,8 @@ cp /usr/share/automake-1.9/missing missing echo Configuring... export CFLAGS="-Wall" #export CFLAGS="-Wall -pedantic" -./configure --with-ldap --enable-agent --enable-server --with-mysql --with-net-snmp --prefix=`pwd` 2>>WARNINGS >/dev/null +#./configure --with-ldap --enable-agent --enable-server --with-mysql --with-net-snmp --prefix=`pwd` 2>>WARNINGS >/dev/null +./configure --enable-agent --enable-server --with-mysql --with-net-snmp --prefix=`pwd` 2>>WARNINGS >/dev/null echo Cleaning... make clean 2>>WARNINGS >/dev/null echo Making... diff --git a/include/common.h b/include/common.h index 3f20e6df..ad072326 100644 --- a/include/common.h +++ b/include/common.h @@ -256,13 +256,14 @@ #define AGENTD_FORKS 5 #define TRAPPERD_FORKS 5 - #define SUCKER_FORKS 11 -#define SUCKER_DELAY 60 + +#define POLLER_DELAY 1 #define SUCKER_TIMEOUT 5 -/* Delay on network failure*/ -#define DELAY_ON_NETWORK_FAILURE 60 +/* Do not perform more than this number of checks during unavailability period */ +#define SLEEP_ON_UNREACHABLE 60 +#define CHECKS_PER_UNAVAILABLE_PERIOD 4 #define AGENT_TIMEOUT 3 diff --git a/include/db.h b/include/db.h index ab75d9a6..09a52719 100644 --- a/include/db.h +++ b/include/db.h @@ -113,7 +113,7 @@ extern int CONFIG_DBPORT; #define ACTION_SUBJECT_LEN 255 #define ACTION_SUBJECT_LEN_MAX ACTION_SUBJECT_LEN+1 -#define ZBX_SQL_ITEM_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,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status,i.trapper_hosts,i.logtimefmt from hosts h, items i" +#define ZBX_SQL_ITEM_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,i.value_type,h.errors_from,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status,i.trapper_hosts,i.logtimefmt from hosts h, items i" DB_HOST { @@ -124,7 +124,7 @@ DB_HOST int port; int status; int disable_until; - int network_errors; + int errors_from; char error[HOST_ERROR_LEN_MAX]; int available; }; @@ -161,7 +161,7 @@ DB_ITEM char *host; int host_status; int host_available; - int host_network_errors; + int host_errors_from; int useip; char *ip; char *shortname; diff --git a/src/alphacode/poller/go b/src/alphacode/poller/go index f2505af8..a38d9819 100755 --- a/src/alphacode/poller/go +++ b/src/alphacode/poller/go @@ -1 +1,2 @@ -gcc snmp.c -I/usr/include/net-snmp -lsnmp +#gcc snmp.c -I/usr/include/net-snmp -lsnmp +gcc poller_epoll.c -o poller_epoll diff --git a/src/alphacode/poller/poller_epoll.c b/src/alphacode/poller/poller_epoll.c index 2841c315..749d67db 100644 --- a/src/alphacode/poller/poller_epoll.c +++ b/src/alphacode/poller/poller_epoll.c @@ -26,7 +26,7 @@ ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ -#define NUM 5 +#define NUM 1000 int s; @@ -47,6 +47,7 @@ void wait_connect() printf("epfd [%d]\n", epfd); printf("NUM [%d]\n", NUM); + events=malloc(NUM*sizeof(struct epoll_event)); retval = epoll_wait(epfd, events, NUM, -1); if(retval == -1) { @@ -54,6 +55,9 @@ void wait_connect() printf("Retval [%d]\n", errno); exit(-1); } + printf("Retval [%d]\n", retval); + sleep(1); + continue; for(i=0;i<retval;i++) { @@ -120,7 +124,7 @@ int main() { if(errno == EINPROGRESS) { - printf("Connection in progress\n"); +// printf("Connection in progress\n"); } else { @@ -129,11 +133,11 @@ int main() } } - if(fcntl(s, F_SETFL, O_NONBLOCK) == -1) - { - perror("fcntl() failed\n"); - exit(-1); - } +// if(fcntl(s, F_SETFL, O_NONBLOCK) == -1) +// { +// perror("fcntl() failed\n"); +// exit(-1); +// } ev.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLOUT; ev.data.fd = s; @@ -142,7 +146,7 @@ int main() perror("epoll_ctl, adding listenfd\n"); exit(1); } - printf("epoll_ctl ok fd [%d]\n", s); +// printf("epoll_ctl ok fd [%d]\n", s); } wait_connect(); diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index b4369c9b..adeb637d 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -870,7 +870,7 @@ void DBupdate_host_availability(int hostid,int available,int clock, char *error) if(available == atoi(DBget_field(result,0,0))) { if((available==HOST_AVAILABLE_FALSE) - &&(clock+DELAY_ON_NETWORK_FAILURE>disable_until) ) + &&(clock+SLEEP_ON_UNREACHABLE>disable_until) ) { } else @@ -885,19 +885,19 @@ void DBupdate_host_availability(int hostid,int available,int clock, char *error) if(available==HOST_AVAILABLE_TRUE) { - snprintf(sql,sizeof(sql)-1,"update hosts set available=%d where hostid=%d",HOST_AVAILABLE_TRUE,hostid); + snprintf(sql,sizeof(sql)-1,"update hosts set available=%d,error='',errors_from=0 where hostid=%d",HOST_AVAILABLE_TRUE,hostid); zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql); DBexecute(sql); } else if(available==HOST_AVAILABLE_FALSE) { - if(disable_until+DELAY_ON_NETWORK_FAILURE>clock) + if(disable_until+SLEEP_ON_UNREACHABLE>clock) { - snprintf(sql,sizeof(sql)-1,"update hosts set available=%d,disable_until=disable_until+%d,error='%s' where hostid=%d",HOST_AVAILABLE_FALSE,DELAY_ON_NETWORK_FAILURE,error_esc,hostid); + snprintf(sql,sizeof(sql)-1,"update hosts set available=%d,disable_until=disable_until+%d,error='%s' where hostid=%d",HOST_AVAILABLE_FALSE,SLEEP_ON_UNREACHABLE,error_esc,hostid); } else { - snprintf(sql,sizeof(sql)-1,"update hosts set available=%d,disable_until=%d,error='%s' where hostid=%d",HOST_AVAILABLE_FALSE,clock+DELAY_ON_NETWORK_FAILURE,error_esc,hostid); + snprintf(sql,sizeof(sql)-1,"update hosts set available=%d,disable_until=%d,error='%s' where hostid=%d",HOST_AVAILABLE_FALSE,clock+SLEEP_ON_UNREACHABLE,error_esc,hostid); } zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql); DBexecute(sql); @@ -1377,7 +1377,7 @@ void DBget_item_from_db(DB_ITEM *item,DB_RESULT *result, int row) item->host_status=atoi(DBget_field(result,i,16)); item->value_type=atoi(DBget_field(result,i,17)); - item->host_network_errors=atoi(DBget_field(result,i,18)); + item->host_errors_from=atoi(DBget_field(result,i,18)); item->snmp_port=atoi(DBget_field(result,i,19)); item->delta=atoi(DBget_field(result,i,20)); diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c index f9ef30de..8a7630a2 100644 --- a/src/libs/zbxdbhigh/host.c +++ b/src/libs/zbxdbhigh/host.c @@ -178,7 +178,7 @@ int DBget_host_by_hostid(int hostid,DB_HOST *host) zabbix_log( LOG_LEVEL_DEBUG, "In DBget_host_by_hostid(%d)", hostid); - snprintf(sql,sizeof(sql)-1,"select hostid,host,useip,ip,port,status,disable_until,network_errors,error,available from hosts where hostid=%d", hostid); + snprintf(sql,sizeof(sql)-1,"select hostid,host,useip,ip,port,status,disable_until,errors_from,error,available from hosts where hostid=%d", hostid); result=DBselect(sql); if(DBnum_rows(result)==0) @@ -194,7 +194,7 @@ int DBget_host_by_hostid(int hostid,DB_HOST *host) host->port=atoi(DBget_field(result,0,4)); host->status=atoi(DBget_field(result,0,5)); host->disable_until=atoi(DBget_field(result,0,6)); - host->network_errors=atoi(DBget_field(result,0,7)); + host->errors_from=atoi(DBget_field(result,0,7)); strscpy(host->error,DBget_field(result,0,8)); host->available=atoi(DBget_field(result,0,9)); } diff --git a/src/zabbix_server/poller/poller.c b/src/zabbix_server/poller/poller.c index 7db7db3f..dd9cfed8 100644 --- a/src/zabbix_server/poller/poller.c +++ b/src/zabbix_server/poller/poller.c @@ -113,11 +113,13 @@ static int get_minnextcheck(int now) 2 == UNREACHABLE */ if(CONFIG_REFRESH_UNSUPPORTED != 0) { - snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); +/* snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);*/ + snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } else { - snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and h.hostid=i.hostid and i.status in (%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); +/* snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and h.hostid=i.hostid and i.status in (%d) and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);*/ + snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where h.status=%d and h.disable_until<%d and h.hostid=i.hostid and i.status in (%d,%d) and i.type not in (%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } result = DBselect(sql); @@ -155,7 +157,7 @@ static void update_key_status(int hostid,int host_status) zabbix_log(LOG_LEVEL_DEBUG, "In update_key_status()"); - snprintf(sql,sizeof(sql)-1,"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,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available,i.status from items i,hosts h where h.hostid=i.hostid and h.hostid=%d and i.key_='%s'", hostid,SERVER_STATUS_KEY); + snprintf(sql,sizeof(sql)-1,"select %s where h.hostid=i.hostid and h.hostid=%d and i.key_='%s'", ZBX_SQL_ITEM_SELECT, hostid,SERVER_STATUS_KEY); result = DBselect(sql); if( DBnum_rows(result) == 0) @@ -213,11 +215,13 @@ int get_values(void) if(CONFIG_REFRESH_UNSUPPORTED != 0) { - snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d,%d) and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); +/* snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d,%d) and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);*/ + snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d,%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } else { - snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); +/* snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY);*/ + snprintf(sql,sizeof(sql)-1,"select %s where i.nextcheck<=%d and i.status in (%d) and i.type not in (%d,%d) and h.status=%d and h.disable_until<=%d and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", ZBX_SQL_ITEM_SELECT, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); } result = DBselect(sql); @@ -233,10 +237,9 @@ int get_values(void) { process_new_value(&item,&agent); - if(item.host_network_errors>0) + if(item.host_errors_from!=0) { - snprintf(sql,sizeof(sql)-1,"update hosts set network_errors=0,error='' where hostid=%d and network_errors>0", item.hostid); - DBexecute(sql); + zabbix_log( LOG_LEVEL_WARNING, "No network errors for [%s]", item.host); } /* if(HOST_STATUS_UNREACHABLE == item.host_status)*/ @@ -279,24 +282,34 @@ int get_values(void) } else if(res == NETWORK_ERROR) { - item.host_network_errors++; - if(item.host_network_errors>=3) + if(item.host_errors_from==0) + { + zabbix_log( LOG_LEVEL_WARNING, "Started network errors for [%s]", item.host); + item.host_errors_from=now; + snprintf(sql,sizeof(sql)-1,"update hosts set errors_from=%d,disable_until=%d where hostid=%d", now, now+(int)(CONFIG_UNAVAILABLE_PERIOD/CHECKS_PER_UNAVAILABLE_PERIOD), item.hostid); + zabbix_log( LOG_LEVEL_DEBUG, "SQL [%s]", sql); + DBexecute(sql); + } + + zabbix_log( LOG_LEVEL_WARNING, "errors_from [%d]+[%d]<[%d]", item.host_errors_from,CONFIG_UNAVAILABLE_PERIOD,now); + if(item.host_errors_from+CONFIG_UNAVAILABLE_PERIOD<now) { - zabbix_log( LOG_LEVEL_WARNING, "Host [%s] will be checked after [%d] seconds", item.host, DELAY_ON_NETWORK_FAILURE ); - zabbix_syslog("Host [%s] will be checked after [%d] seconds", item.host, DELAY_ON_NETWORK_FAILURE ); + zabbix_log( LOG_LEVEL_WARNING, "Host [%s] will be checked after [%d] seconds", item.host, 60); + zabbix_syslog("Host [%s] will be checked after [%d] seconds", item.host, 60); DBupdate_host_availability(item.hostid,HOST_AVAILABLE_FALSE,now,agent.msg); update_key_status(item.hostid,HOST_AVAILABLE_FALSE); /* 2 */ item.host_available=HOST_AVAILABLE_FALSE; - - snprintf(sql,sizeof(sql)-1,"update hosts set network_errors=3 where hostid=%d", item.hostid); - DBexecute(sql); } + /* Still unavailable, but won't change status to UNAVAILABLE yet */ else { - snprintf(sql,sizeof(sql)-1,"update hosts set network_errors=%d where hostid=%d", item.host_network_errors, item.hostid); + zabbix_log( LOG_LEVEL_WARNING, "Host [%s]: another network error, Wait for %d seconds", item.host, (int)(CONFIG_UNAVAILABLE_PERIOD/CHECKS_PER_UNAVAILABLE_PERIOD)); + snprintf(sql,sizeof(sql)-1,"update hosts set disable_until=%d where hostid=%d", now+(int)(CONFIG_UNAVAILABLE_PERIOD/CHECKS_PER_UNAVAILABLE_PERIOD), item.hostid); + zabbix_log( LOG_LEVEL_DEBUG, "SQL [%s]", sql); DBexecute(sql); } + stop=1; } /* Possibly, other logic required? */ @@ -343,7 +356,7 @@ void main_poller_loop() if( FAIL == nextcheck) { - sleeptime=SUCKER_DELAY; + sleeptime=POLLER_DELAY; } else { @@ -355,9 +368,9 @@ void main_poller_loop() } if(sleeptime>0) { - if(sleeptime > SUCKER_DELAY) + if(sleeptime > POLLER_DELAY) { - sleeptime = SUCKER_DELAY; + sleeptime = POLLER_DELAY; } zabbix_log( LOG_LEVEL_DEBUG, "Sleeping for %d seconds", sleeptime ); diff --git a/src/zabbix_server/poller/poller.h b/src/zabbix_server/poller/poller.h index 9c828bb6..28156222 100644 --- a/src/zabbix_server/poller/poller.h +++ b/src/zabbix_server/poller/poller.h @@ -26,6 +26,7 @@ extern int server_num; extern int CONFIG_TIMEOUT; extern int CONFIG_SUCKERD_FORKS; extern int CONFIG_REFRESH_UNSUPPORTED; +extern int CONFIG_UNAVAILABLE_PERIOD; void main_poller_loop(); diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c index 6d94571b..991b4a80 100644 --- a/src/zabbix_server/server.c +++ b/src/zabbix_server/server.c @@ -79,6 +79,7 @@ int CONFIG_SENDER_FREQUENCY = 30; int CONFIG_PINGER_FREQUENCY = 60; int CONFIG_DISABLE_PINGER = 0; int CONFIG_DISABLE_HOUSEKEEPING = 0; +int CONFIG_UNAVAILABLE_PERIOD = 20; int CONFIG_LOG_LEVEL = LOG_LEVEL_WARNING; char *CONFIG_FILE = NULL; char *CONFIG_PID_FILE = NULL; @@ -319,6 +320,7 @@ void init_config(void) {"Timeout",&CONFIG_TIMEOUT,0,TYPE_INT,PARM_OPT,1,30}, {"StartTrappers",&CONFIG_TRAPPERD_FORKS,0,TYPE_INT,PARM_OPT,2,255}, {"TrapperTimeout",&CONFIG_TRAPPER_TIMEOUT,0,TYPE_INT,PARM_OPT,1,30}, + {"UnavailablePeriod",&CONFIG_UNAVAILABLE_PERIOD,0,TYPE_INT,PARM_OPT,1,3600}, {"ListenPort",&CONFIG_LISTEN_PORT,0,TYPE_INT,PARM_OPT,1024,32768}, {"NoTimeWait",&CONFIG_NOTIMEWAIT,0,TYPE_INT,PARM_OPT,0,1}, {"DisablePinger",&CONFIG_DISABLE_PINGER,0,TYPE_INT,PARM_OPT,0,1}, @@ -573,7 +575,7 @@ int main(int argc, char **argv) for(i=0;i<CONFIG_SUCKERD_FORKS+CONFIG_TRAPPERD_FORKS-1;i++) { - zabbix_log( LOG_LEVEL_WARNING, "%d. PID=[%d]", i, pids[i]); + zabbix_log( LOG_LEVEL_DEBUG, "%d. PID=[%d]", i, pids[i]); } zabbix_log( LOG_LEVEL_CRIT, "ZABBIX server is up."); diff --git a/upgrades/dbpatches/1.1beta5_to_1.1beta6/mysql/patch.sql b/upgrades/dbpatches/1.1beta5_to_1.1beta6/mysql/patch.sql index 33341e6a..09e328b2 100644 --- a/upgrades/dbpatches/1.1beta5_to_1.1beta6/mysql/patch.sql +++ b/upgrades/dbpatches/1.1beta5_to_1.1beta6/mysql/patch.sql @@ -1 +1,4 @@ -alter table sysmaps add label_location int(1) DEFAULT '0' NOT NULL; +-alter table sysmaps add label_location int(1) DEFAULT '0' NOT NULL; + +alter table hosts drop network_errors; +alter table hosts add errors_from int(4) DEFAULT '0' NOT NULL; diff --git a/upgrades/dbpatches/1.1beta5_to_1.1beta6/postgresql/patch.sql b/upgrades/dbpatches/1.1beta5_to_1.1beta6/postgresql/patch.sql index f0144ce2..dce1df92 100644 --- a/upgrades/dbpatches/1.1beta5_to_1.1beta6/postgresql/patch.sql +++ b/upgrades/dbpatches/1.1beta5_to_1.1beta6/postgresql/patch.sql @@ -1 +1,4 @@ alter table sysmaps add label_location int2 DEFAULT '0' NOT NULL; + +alter table hosts drop network_errors; +alter table hosts add errors_from int4 DEFAULT '0' NOT NULL; |