diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | include/common.h | 2 | ||||
-rw-r--r-- | src/libs/zbxcommon/misc.c | 9 | ||||
-rw-r--r-- | src/zabbix_server/functions.c | 31 |
4 files changed, 35 insertions, 8 deletions
@@ -12,6 +12,7 @@ Changes for 1.3: Integrated from 1.1.x + - better calculation of next check timestamp for active items (Alexei) - new algorithm for housekeeping same for all DB engines (Alexei) - always draw graphs for items having type "trapper" (Alexei) - fixed assignment of default listen port for Win agent (Eugene) diff --git a/include/common.h b/include/common.h index e35c9dd5..f5146413 100644 --- a/include/common.h +++ b/include/common.h @@ -415,7 +415,7 @@ void rtrim_spaces(char *c); void delete_reol(char *c); int get_param(const char *param, int num, char *buf, int maxlen); int num_param(const char *param); -int calculate_item_nextcheck(int itemid, int delay, char *delay_flex, time_t now); +int calculate_item_nextcheck(int itemid, int item_type, int delay, char *delay_flex, time_t now); int check_time_period(const char *period, time_t now); void zbx_setproctitle(const char *fmt, ...); diff --git a/src/libs/zbxcommon/misc.c b/src/libs/zbxcommon/misc.c index a4aaaf9d..4e6ccd84 100644 --- a/src/libs/zbxcommon/misc.c +++ b/src/libs/zbxcommon/misc.c @@ -146,7 +146,7 @@ void zbx_setproctitle(const char *fmt, ...) * New one: preserve period, if delay==5, nextcheck = 0,5,10,15,... * * * ******************************************************************************/ -int calculate_item_nextcheck(int itemid, int delay, char *delay_flex, time_t now) +int calculate_item_nextcheck(int itemid, int item_type, int delay, char *delay_flex, time_t now) { int i; char *p; @@ -155,6 +155,13 @@ int calculate_item_nextcheck(int itemid, int delay, char *delay_flex, time_t now zabbix_log( LOG_LEVEL_DEBUG, "In calculate_item_nextcheck [%d, %d, %s, %d]",itemid,delay,delay_flex,now); +/* Special processing of active items to see better view in queue */ + if(item_type == ITEM_TYPE_ZABBIX_ACTIVE) + { + return (now+delay); + } + + if(delay_flex && *delay_flex) { do diff --git a/src/zabbix_server/functions.c b/src/zabbix_server/functions.c index 9a9d7845..d5a37517 100644 --- a/src/zabbix_server/functions.c +++ b/src/zabbix_server/functions.c @@ -703,7 +703,10 @@ static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now) DBescape_string(value_str,value_esc,MAX_STRING_LEN); /* snprintf(sql,sizeof(sql)-1,"update items set nextcheck=%d,prevvalue=lastvalue,lastvalue='%s',lastclock=%d where itemid=%d",now+item->delay,value_esc,now,item->itemid);*/ DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,lastvalue='%s',lastclock=%d where itemid=" ZBX_FS_UI64, - calculate_item_nextcheck(item->itemid, item->delay, item->delay_flex, now),value_esc,(int)now,item->itemid); + calculate_item_nextcheck(item->itemid, item->type, item->delay, item->delay_flex, now), + value_esc, + (int)now, + item->itemid); item->prevvalue=item->lastvalue; item->lastvalue=value_double; @@ -717,7 +720,9 @@ static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now) { /* snprintf(sql,sizeof(sql)-1,"update items set nextcheck=%d,lastclock=%d where itemid=%d",now+item->delay,now,item->itemid);*/ DBexecute("update items set nextcheck=%d,lastclock=%d where itemid=" ZBX_FS_UI64, - calculate_item_nextcheck(item->itemid, item->delay, item->delay_flex, now),(int)now,item->itemid); + calculate_item_nextcheck(item->itemid, item->type, item->delay, item->delay_flex, now), + (int)now, + item->itemid); } } /* Logic for delta as speed of change */ @@ -727,13 +732,20 @@ static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now) { /* snprintf(sql,sizeof(sql)-1,"update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue=%f,lastvalue='%f',lastclock=%d where itemid=%d",now+item->delay,value_double,(value_double - item->prevorgvalue)/(now-item->lastclock),now,item->itemid);*/ DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue=%f,lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64, - calculate_item_nextcheck(item->itemid, item->delay,item->delay_flex,now),value_double,(value_double - item->prevorgvalue)/(now-item->lastclock),(int)now,item->itemid); + calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now), + value_double, + (value_double - item->prevorgvalue)/(now-item->lastclock), + (int)now, + item->itemid); } else { /* snprintf(sql,sizeof(sql)-1,"update items set nextcheck=%d,prevorgvalue=%f,lastclock=%d where itemid=%d",now+item->delay,value_double,now,item->itemid);*/ DBexecute("update items set nextcheck=%d,prevorgvalue=%f,lastclock=%d where itemid=" ZBX_FS_UI64, - calculate_item_nextcheck(item->itemid, item->delay,item->delay_flex,now),value_double,(int)now,item->itemid); + calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now), + value_double, + (int)now, + item->itemid); } item->prevvalue=item->lastvalue; @@ -750,12 +762,19 @@ static int update_item(DB_ITEM *item, AGENT_RESULT *value, time_t now) if((item->prevorgvalue_null == 0) && (item->prevorgvalue <= value_double) ) { DBexecute("update items set nextcheck=%d,prevvalue=lastvalue,prevorgvalue=%f,lastvalue='%f',lastclock=%d where itemid=" ZBX_FS_UI64, - calculate_item_nextcheck(item->itemid, item->delay,item->delay_flex,now),value_double,(value_double - item->prevorgvalue),(int)now,item->itemid); + calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex,now), + value_double, + (value_double - item->prevorgvalue), + (int)now, + item->itemid); } else { DBexecute("update items set nextcheck=%d,prevorgvalue=%f,lastclock=%d where itemid=" ZBX_FS_UI64, - calculate_item_nextcheck(item->itemid, item->delay,item->delay_flex, now),value_double,(int)now,item->itemid); + calculate_item_nextcheck(item->itemid, item->type, item->delay,item->delay_flex, now), + value_double, + (int)now, + item->itemid); } item->prevvalue=item->lastvalue; |