calculation of nextcheck is incorrect when "Interval" of "flexible intervals" is set to a large value.
1)Type : Zabbix agent
2)Update interval (in sec) : 300
3)Flexible intervals
Interval : 22200
Period : 1-7,00:54-07:00
Added the log output to calculate_item_nextcheck.
look at the log of [2014/5/24 00:50:06]
43876:20140524:005006.793 calculate_item_nextcheck **********************************************
43876:20140524:005006.793 calculate_item_nextcheck interfaceid : 1
43876:20140524:005006.793 calculate_item_nextcheck shift : 23706
43876:20140524:005006.793 calculate_item_nextcheck tmax - 1432396206 - 0:50:6 (tmax : t + one year)
43876:20140524:005006.793 calculate_item_nextcheck ********* loop *********
43876:20140524:005006.793 calculate_item_nextcheck next_interval - 341966240 - 6:31:12
43876:20140524:005006.793 calculate_item_nextcheck t - 1400860206 - 0:50:6
43876:20140524:005006.793 calculate_item_nextcheck current_delay : 300
43876:20140524:005006.793 calculate_item_nextcheck 1:nextcheck - 1400860206 - 0:50:6
43876:20140524:005006.793 calculate_item_nextcheck 2:nextcheck - 1400860506 - 0:55:6 <-- orver "Period"of "flexible intervals"
43876:20140524:005006.793 calculate_item_nextcheck ********* not break *********
43876:20140524:005006.793 calculate_item_nextcheck ********* loop *********
43876:20140524:005006.793 calculate_item_nextcheck next_interval - 1400860440 - 0:54:0
43876:20140524:005006.793 calculate_item_nextcheck t - 1400860440 - 0:54:0
43876:20140524:005006.793 calculate_item_nextcheck current_delay : 22200
43876:20140524:005006.793 calculate_item_nextcheck 1:nextcheck - 1400843706 - 20:15:6 <-- here!
43876:20140524:005006.793 calculate_item_nextcheck 2:nextcheck - 1400865906 - 2:25:6 <-- here!
43876:20140524:005006.793 calculate_item_nextcheck return - 1400865906 - 2:25:6
The nextcheck of [2014/5/24 00:50] must be after [2014/5/24 07:00].
-
-
-
-
-
-
-
- calculate_item_nextcheck ***************************
int calculate_item_nextcheck(zbx_uint64_t interfaceid, zbx_uint64_t itemid, int item_type,
int delay, const char *flex_intervals, time_t now, int *effective_delay)
{
const char *__function_name = "calculate_item_nextcheck";
struct tm *d_tm;
time_t d_time;
int nextcheck = 0;
zabbix_log(LOG_LEVEL_ERR, "%s **********************************************", __function_name);
zabbix_log(LOG_LEVEL_ERR, "%s interfaceid : %d", __function_name, interfaceid);
if (0 == delay)
delay = SEC_PER_YEAR;
/* special processing of active items to see better view in queue */
if (ITEM_TYPE_ZABBIX_ACTIVE == item_type)
{
nextcheck = (int)now + delay;
}
else
{
int current_delay = SEC_PER_YEAR, try = 0;
time_t next_interval, t, tmax;
zbx_uint64_t shift;
/* Try to find the nearest 'nextcheck' value with condition */
/* 'now' < 'nextcheck' < 'now' + SEC_PER_YEAR */
t = now;
tmax = now + SEC_PER_YEAR;
shift = (ITEM_TYPE_JMX == item_type ? interfaceid : itemid);
zabbix_log(LOG_LEVEL_ERR, "%s shift : %d", __function_name, shift);
d_time = (time_t)tmax;
d_tm = localtime(&d_time);
zabbix_log(LOG_LEVEL_ERR, "%s tmax - %d - %d:%d:%d (tmax : t + one year)", __function_name, tmax, d_tm->tm_hour, d_tm->tm_min, d_tm->tm_sec);
while (t < tmax)
{
zabbix_log(LOG_LEVEL_ERR, "%s ********* loop *********", __function_name);
d_time = (time_t)next_interval;
d_tm = localtime(&d_time);
zabbix_log(LOG_LEVEL_ERR, "%s next_interval - %d - %d:%d:%d", __function_name, next_interval, d_tm->tm_hour, d_tm->tm_min, d_tm->tm_sec);
d_time = (time_t)t;
d_tm = localtime(&d_time);
zabbix_log(LOG_LEVEL_ERR, "%s t - %d - %d:%d:%d", __function_name, t, d_tm->tm_hour, d_tm->tm_min, d_tm->tm_sec);
/* calculate 'nextcheck' value for the current interval */
current_delay = get_current_delay(delay, flex_intervals, t);
zabbix_log(LOG_LEVEL_ERR, "%s current_delay : %d", __function_name, current_delay);
nextcheck = current_delay * (int)(t / (time_t)current_delay) +
(int)(shift % (zbx_uint64_t)current_delay);
d_time = (time_t)nextcheck;
d_tm = localtime(&d_time);
zabbix_log(LOG_LEVEL_ERR, "%s 1:nextcheck - %d - %d:%d:%d", __function_name, nextcheck, d_tm->tm_hour, d_tm->tm_min, d_tm->tm_sec);
if (0 == try)
{
while (nextcheck <= t)
nextcheck += current_delay;
}
else
{
while (nextcheck < t)
nextcheck += current_delay;
}
d_time = (time_t)nextcheck;
d_tm = localtime(&d_time);
zabbix_log(LOG_LEVEL_ERR, "%s 2:nextcheck - %d - %d:%d:%d", __function_name, nextcheck, d_tm->tm_hour, d_tm->tm_min, d_tm->tm_sec);
/* 'nextcheck' < end of the current interval ? */
/* the end of the current interval is the beginning of the next interval - 1 */
if (FAIL != get_next_delay_interval(flex_intervals, t, &next_interval) &&
nextcheck >= next_interval)
{
/* 'nextcheck' is beyond the current interval */
t = next_interval;
try++;
zabbix_log(LOG_LEVEL_ERR, "%s ********* not break *********", __function_name);
}
else
break; /* nextcheck is within the current interval */
}
delay = current_delay;
}
if (NULL != effective_delay)
*effective_delay = delay;
d_time = (time_t)nextcheck;
d_tm = localtime(&d_time);
zabbix_log(LOG_LEVEL_ERR, "%s return - %d - %d:%d:%d", __function_name, nextcheck, d_tm->tm_hour, d_tm->tm_min, d_tm->tm_sec);
return nextcheck;
}
|