Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlebs Ivanovskis <git-no-reply@zabbix.com>2017-11-14 17:06:58 +0300
committerGlebs Ivanovskis <git-no-reply@zabbix.com>2017-11-14 17:06:58 +0300
commitae04735bdd9ee2f47be3ef644c2cab4f9d7d7543 (patch)
treeaf0e90151aa7d0ad949ff929a5ffa0f76c8e0f0a /src
parent8bce93674365f18e6ad41b8e137503d320afcda2 (diff)
parentcc69524afb659d8726a726a5a47bbef3d1dfd215 (diff)
.......... [ZBXNEXT-761] updated to the latest trunk (without conflicts)
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxalgo/algodefs.c4
-rw-r--r--src/libs/zbxcommon/comms.c14
-rw-r--r--src/libs/zbxcommon/file.c11
-rw-r--r--src/libs/zbxcommon/iprange.c6
-rw-r--r--src/libs/zbxcommon/misc.c17
-rw-r--r--src/libs/zbxcommon/str.c22
-rw-r--r--src/libs/zbxcomms/comms.c10
-rw-r--r--src/libs/zbxdbcache/dbconfig.c34
-rw-r--r--src/libs/zbxdbcache/dbconfig.h1
-rw-r--r--src/libs/zbxdbhigh/host.c17
-rw-r--r--src/libs/zbxdbhigh/proxy.c54
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_3050.c20
-rw-r--r--src/libs/zbxjson/json_parser.c12
-rw-r--r--src/libs/zbxlog/log.c4
-rw-r--r--src/libs/zbxsysinfo/simple/ntp.c2
-rw-r--r--src/libs/zbxwin32/fatal.c2
-rw-r--r--src/zabbix_agent/active.c12
-rw-r--r--src/zabbix_agent/cpustat.c4
-rw-r--r--src/zabbix_agent/logfiles.c6
-rw-r--r--src/zabbix_java/src/com/zabbix/gateway/JMXItemChecker.java20
-rw-r--r--src/zabbix_server/alerter/alert_manager.c125
-rw-r--r--src/zabbix_server/alerter/alerter.c27
-rw-r--r--src/zabbix_server/ipmi/ipmi_manager.c26
-rw-r--r--src/zabbix_server/ipmi/ipmi_poller.c26
-rw-r--r--src/zabbix_server/preprocessor/preproc_manager.c20
-rw-r--r--src/zabbix_server/proxypoller/proxypoller.c4
26 files changed, 302 insertions, 198 deletions
diff --git a/src/libs/zbxalgo/algodefs.c b/src/libs/zbxalgo/algodefs.c
index 087626d46c3..da6ba17c186 100644
--- a/src/libs/zbxalgo/algodefs.c
+++ b/src/libs/zbxalgo/algodefs.c
@@ -60,7 +60,7 @@ zbx_hash_t zbx_hash_lookup2(const void *data, size_t len, zbx_hash_t seed)
len -= 12;
}
- c = c + len;
+ c = c + (zbx_hash_t)len;
switch (len)
{
@@ -119,7 +119,7 @@ zbx_hash_t zbx_hash_murmur2(const void *data, size_t len, zbx_hash_t seed)
const zbx_hash_t m = 0x5bd1e995u;
const zbx_hash_t r = 24;
- hash = seed ^ len;
+ hash = seed ^ (zbx_hash_t)len;
while (len >= 4)
{
diff --git a/src/libs/zbxcommon/comms.c b/src/libs/zbxcommon/comms.c
index 52ddd35049c..91b0e8aed37 100644
--- a/src/libs/zbxcommon/comms.c
+++ b/src/libs/zbxcommon/comms.c
@@ -38,7 +38,7 @@ int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size
if (SUCCEED == xml_get_data_dyn(xml, "host", &data_b64))
{
- str_base64_decode(data_b64, host, host_len - 1, &i);
+ str_base64_decode(data_b64, host, (int)host_len - 1, &i);
host[i] = '\0';
xml_free_data_dyn(&data_b64);
}
@@ -50,7 +50,7 @@ int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size
if (SUCCEED == xml_get_data_dyn(xml, "key", &data_b64))
{
- str_base64_decode(data_b64, key, key_len - 1, &i);
+ str_base64_decode(data_b64, key, (int)key_len - 1, &i);
key[i] = '\0';
xml_free_data_dyn(&data_b64);
}
@@ -62,7 +62,7 @@ int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size
if (SUCCEED == xml_get_data_dyn(xml, "data", &data_b64))
{
- str_base64_decode(data_b64, data, data_len - 1, &i);
+ str_base64_decode(data_b64, data, (int)data_len - 1, &i);
data[i] = '\0';
xml_free_data_dyn(&data_b64);
}
@@ -74,7 +74,7 @@ int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size
if (SUCCEED == xml_get_data_dyn(xml, "lastlogsize", &data_b64))
{
- str_base64_decode(data_b64, lastlogsize, lastlogsize_len - 1, &i);
+ str_base64_decode(data_b64, lastlogsize, (int)lastlogsize_len - 1, &i);
lastlogsize[i] = '\0';
xml_free_data_dyn(&data_b64);
}
@@ -83,7 +83,7 @@ int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size
if (SUCCEED == xml_get_data_dyn(xml, "timestamp", &data_b64))
{
- str_base64_decode(data_b64, timestamp, timestamp_len - 1, &i);
+ str_base64_decode(data_b64, timestamp, (int)timestamp_len - 1, &i);
timestamp[i] = '\0';
xml_free_data_dyn(&data_b64);
}
@@ -92,7 +92,7 @@ int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size
if (SUCCEED == xml_get_data_dyn(xml, "source", &data_b64))
{
- str_base64_decode(data_b64, source, source_len - 1, &i);
+ str_base64_decode(data_b64, source, (int)source_len - 1, &i);
source[i] = '\0';
xml_free_data_dyn(&data_b64);
}
@@ -101,7 +101,7 @@ int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size
if (SUCCEED == xml_get_data_dyn(xml, "severity", &data_b64))
{
- str_base64_decode(data_b64, severity, severity_len - 1, &i);
+ str_base64_decode(data_b64, severity, (int)severity_len - 1, &i);
severity[i] = '\0';
xml_free_data_dyn(&data_b64);
}
diff --git a/src/libs/zbxcommon/file.c b/src/libs/zbxcommon/file.c
index 81ac57c2a55..a93c6571723 100644
--- a/src/libs/zbxcommon/file.c
+++ b/src/libs/zbxcommon/file.c
@@ -99,20 +99,19 @@ void find_cr_lf_szbyte(const char *encoding, const char **cr, const char **lf, s
******************************************************************************/
int zbx_read(int fd, char *buf, size_t count, const char *encoding)
{
- size_t i, szbyte;
+ size_t i, szbyte, nbytes;
const char *cr, *lf;
- int nbytes;
zbx_offset_t offset;
if ((zbx_offset_t)-1 == (offset = zbx_lseek(fd, 0, SEEK_CUR)))
return -1;
- if (0 >= (nbytes = (int)read(fd, buf, count)))
- return nbytes;
+ if (0 >= (nbytes = read(fd, buf, (unsigned int)count)))
+ return (int)nbytes;
find_cr_lf_szbyte(encoding, &cr, &lf, &szbyte);
- for (i = 0; i <= (size_t)nbytes - szbyte; i += szbyte)
+ for (i = 0; i <= nbytes - szbyte; i += szbyte)
{
if (0 == memcmp(&buf[i], lf, szbyte)) /* LF (Unix) */
{
@@ -123,7 +122,7 @@ int zbx_read(int fd, char *buf, size_t count, const char *encoding)
if (0 == memcmp(&buf[i], cr, szbyte)) /* CR (Mac) */
{
/* CR+LF (Windows) ? */
- if (i < (size_t)nbytes - szbyte && 0 == memcmp(&buf[i + szbyte], lf, szbyte))
+ if (i < nbytes - szbyte && 0 == memcmp(&buf[i + szbyte], lf, szbyte))
i += szbyte;
i += szbyte;
diff --git a/src/libs/zbxcommon/iprange.c b/src/libs/zbxcommon/iprange.c
index 877ee6d768e..73b90187592 100644
--- a/src/libs/zbxcommon/iprange.c
+++ b/src/libs/zbxcommon/iprange.c
@@ -134,8 +134,9 @@ static void iprange_apply_mask(zbx_iprange_t *iprange, int bits)
******************************************************************************/
static int iprangev4_parse(zbx_iprange_t *iprange, const char *address)
{
- int index, len, bits = -1;
+ int index, bits = -1;
const char *ptr = address, *dash, *end;
+ size_t len;
iprange->type = ZBX_IPRANGE_V4;
@@ -227,8 +228,9 @@ static int iprangev4_parse(zbx_iprange_t *iprange, const char *address)
******************************************************************************/
static int iprangev6_parse(zbx_iprange_t *iprange, const char *address)
{
- int index, len, fill = -1, bits = -1, target;
+ int index, fill = -1, bits = -1, target;
const char *ptr = address, *dash, *end;
+ size_t len;
iprange->type = ZBX_IPRANGE_V6;
diff --git a/src/libs/zbxcommon/misc.c b/src/libs/zbxcommon/misc.c
index 061dadf404a..f7e90f5a2fe 100644
--- a/src/libs/zbxcommon/misc.c
+++ b/src/libs/zbxcommon/misc.c
@@ -874,7 +874,7 @@ int zbx_check_time_period(const char *period, time_t time, int *res)
tm = localtime(&time);
next = strchr(period, ';');
- while (SUCCEED == time_period_parse(&tp, period, (NULL == next ? (int)strlen(period) : next - period)))
+ while (SUCCEED == time_period_parse(&tp, period, (NULL == next ? (int)strlen(period) : (int)(next - period))))
{
if (SUCCEED == check_time_period(tp, tm))
res_total = SUCCEED; /* no short-circuits, validate all periods before return */
@@ -936,7 +936,7 @@ static int flexible_interval_parse(zbx_flexible_interval_t *interval, const char
for (ptr = text; 0 < len && '\0' != *ptr && '/' != *ptr; len--, ptr++)
;
- if (SUCCEED != is_time_suffix(text, &interval->delay, ptr - text))
+ if (SUCCEED != is_time_suffix(text, &interval->delay, (int)(ptr - text)))
return FAIL;
if (0 >= len-- || '/' != *ptr++)
@@ -1626,7 +1626,7 @@ static void scheduler_apply_second_filter(zbx_scheduler_interval_t *interval, st
static time_t scheduler_get_nextcheck(zbx_scheduler_interval_t *interval, time_t now)
{
struct tm tm_start, tm;
- int nextcheck = 0, current_nextcheck;
+ time_t nextcheck = 0, current_nextcheck;
tm_start = *(localtime(&now));
tm_start.tm_isdst = -1;
@@ -1677,7 +1677,7 @@ int zbx_interval_preproc(const char *interval_str, int *simple_interval, zbx_cus
int ret;
if (SUCCEED != (ret = is_time_suffix(interval_str, simple_interval,
- (NULL == (delim = strchr(interval_str, ';')) ? ZBX_LENGTH_UNLIMITED : delim - interval_str))))
+ (int)(NULL == (delim = strchr(interval_str, ';')) ? ZBX_LENGTH_UNLIMITED : delim - interval_str))))
{
interval_type = "update";
goto out;
@@ -1698,7 +1698,7 @@ int zbx_interval_preproc(const char *interval_str, int *simple_interval, zbx_cus
new_interval = zbx_malloc(NULL, sizeof(zbx_flexible_interval_t));
if (SUCCEED != (ret = flexible_interval_parse(new_interval, interval_str,
- (NULL == delim ? (int)strlen(interval_str) : delim - interval_str))))
+ (NULL == delim ? (int)strlen(interval_str) : (int)(delim - interval_str)))))
{
zbx_free(new_interval);
interval_type = "flexible";
@@ -1716,7 +1716,7 @@ int zbx_interval_preproc(const char *interval_str, int *simple_interval, zbx_cus
memset(new_interval, 0, sizeof(zbx_scheduler_interval_t));
if (SUCCEED != (ret = scheduler_interval_parse(new_interval, interval_str,
- (NULL == delim ? (int)strlen(interval_str) : delim - interval_str))))
+ (NULL == delim ? (int)strlen(interval_str) : (int)(delim - interval_str)))))
{
zbx_free(new_interval);
interval_type = "scheduling";
@@ -1733,7 +1733,8 @@ out:
if (NULL != error)
{
*error = zbx_dsprintf(*error, "Invalid %s interval \"%.*s\".", interval_type,
- (NULL == delim ? (int)strlen(interval_str) : delim - interval_str), interval_str);
+ (NULL == delim ? (int)strlen(interval_str) : (int)(delim - interval_str)),
+ interval_str);
}
flexible_interval_free(flexible);
@@ -1863,7 +1864,7 @@ int calculate_item_nextcheck(zbx_uint64_t seed, int item_type, int simple_interv
}
if (0 != scheduled_check && scheduled_check < nextcheck)
- nextcheck = scheduled_check;
+ nextcheck = (int)scheduled_check;
}
return nextcheck;
diff --git a/src/libs/zbxcommon/str.c b/src/libs/zbxcommon/str.c
index 45cbc6ed089..42371208d29 100644
--- a/src/libs/zbxcommon/str.c
+++ b/src/libs/zbxcommon/str.c
@@ -3286,7 +3286,8 @@ int zbx_user_macro_parse(const char *macro, int *macro_r, int *context_l, int *c
int zbx_user_macro_parse_dyn(const char *macro, char **name, char **context, int *length)
{
const char *ptr;
- int macro_r, context_l, context_r, len;
+ int macro_r, context_l, context_r;
+ size_t len;
if (SUCCEED != zbx_user_macro_parse(macro, &macro_r, &context_l, &context_r))
return FAIL;
@@ -3410,7 +3411,7 @@ char *zbx_user_macro_quote_context_dyn(const char *context, int force_quote)
if (0 == force_quote)
return zbx_strdup(NULL, context);
- len = strlen(context) + 2 + quotes;
+ len = (int)strlen(context) + 2 + quotes;
ptr_buffer = buffer = zbx_malloc(NULL, len + 1);
*ptr_buffer++ = '"';
@@ -3933,7 +3934,8 @@ int zbx_strcmp_natural(const char *s1, const char *s2)
******************************************************************************/
static int zbx_token_parse_user_macro(const char *expression, const char *macro, zbx_token_t *token)
{
- int macro_r, context_l, context_r, offset;
+ size_t offset;
+ int macro_r, context_l, context_r;
zbx_token_user_macro_t *data;
if (SUCCEED != zbx_user_macro_parse(macro, &macro_r, &context_l, &context_r))
@@ -3994,7 +3996,7 @@ static int zbx_token_parse_user_macro(const char *expression, const char *macro,
static int zbx_token_parse_lld_macro(const char *expression, const char *macro, zbx_token_t *token)
{
const char *ptr;
- int offset;
+ size_t offset;
zbx_token_macro_t *data;
/* find the end of lld macro by validating its name until the closing bracket } */
@@ -4047,7 +4049,7 @@ static int zbx_token_parse_lld_macro(const char *expression, const char *macro,
static int zbx_token_parse_objectid(const char *expression, const char *macro, zbx_token_t *token)
{
const char *ptr;
- int offset;
+ size_t offset;
zbx_token_macro_t *data;
/* find the end of object id by checking if it contains digits until the closing bracket } */
@@ -4101,7 +4103,7 @@ static int zbx_token_parse_objectid(const char *expression, const char *macro, z
static int zbx_token_parse_macro(const char *expression, const char *macro, zbx_token_t *token)
{
const char *ptr;
- int offset;
+ size_t offset;
zbx_token_macro_t *data;
/* find the end of simple macro by validating its name until the closing bracket } */
@@ -4192,7 +4194,7 @@ static int zbx_token_parse_func_macro(const char *expression, const char *macro,
zbx_strloc_t func_loc, func_param;
zbx_token_func_macro_t *data;
const char *ptr;
- int offset;
+ size_t offset;
if ('\0' == *func)
return FAIL;
@@ -4255,7 +4257,7 @@ static int zbx_token_parse_func_macro(const char *expression, const char *macro,
static int zbx_token_parse_simple_macro_key(const char *expression, const char *macro, const char *key,
zbx_token_t *token)
{
- int offset;
+ size_t offset;
zbx_token_simple_macro_t *data;
const char *ptr;
zbx_strloc_t key_loc, func_loc, func_param;
@@ -4706,7 +4708,7 @@ int zbx_number_find(const char *str, size_t pos, zbx_strloc_t *number_loc)
int zbx_replace_mem_dyn(char **data, size_t *data_alloc, size_t *data_len, size_t offset, size_t sz_to,
const char *from, size_t sz_from)
{
- int sz_changed = sz_from - sz_to;
+ size_t sz_changed = sz_from - sz_to;
if (0 != sz_changed)
{
@@ -4728,5 +4730,5 @@ int zbx_replace_mem_dyn(char **data, size_t *data_alloc, size_t *data_len, size_
memcpy(*data + offset, from, sz_from);
- return sz_changed;
+ return (int)sz_changed;
}
diff --git a/src/libs/zbxcomms/comms.c b/src/libs/zbxcomms/comms.c
index 62f54ad70bb..c54a02da5bc 100644
--- a/src/libs/zbxcomms/comms.c
+++ b/src/libs/zbxcomms/comms.c
@@ -497,7 +497,7 @@ static int zbx_socket_create(zbx_socket_t *s, int type, const char *source_ip, c
goto out;
}
- if (ZBX_PROTO_ERROR == bind(s->socket, ai_bind->ai_addr, ai_bind->ai_addrlen))
+ if (ZBX_PROTO_ERROR == zbx_bind(s->socket, ai_bind->ai_addr, ai_bind->ai_addrlen))
{
zbx_set_socket_strerror("bind() failed: %s", strerror_from_system(zbx_socket_last_error()));
func_socket_close(s);
@@ -505,7 +505,7 @@ static int zbx_socket_create(zbx_socket_t *s, int type, const char *source_ip, c
}
}
- if (SUCCEED != zbx_socket_connect(s, ai->ai_addr, ai->ai_addrlen, timeout, &error))
+ if (SUCCEED != zbx_socket_connect(s, ai->ai_addr, (socklen_t)ai->ai_addrlen, timeout, &error))
{
func_socket_close(s);
zbx_set_socket_strerror("cannot connect to [[%s]:%hu]: %s", ip, port, error);
@@ -982,7 +982,7 @@ int zbx_tcp_listen(zbx_socket_t *s, const char *listen_ip, unsigned short listen
strerror_from_system(zbx_socket_last_error()));
}
#endif
- if (ZBX_PROTO_ERROR == bind(s->sockets[s->num_socks], current_ai->ai_addr,
+ if (ZBX_PROTO_ERROR == zbx_bind(s->sockets[s->num_socks], current_ai->ai_addr,
current_ai->ai_addrlen))
{
zbx_set_socket_strerror("bind() for [[%s]:%s] failed: %s",
@@ -1446,7 +1446,7 @@ const char *zbx_tcp_recv_line(zbx_socket_t *s)
}
else
{
- if (0 != (left = MIN(ZBX_TCP_LINE_LEN - s->read_bytes, ptr - buffer)))
+ if (0 != (left = MIN(ZBX_TCP_LINE_LEN - s->read_bytes, (size_t)(ptr - buffer))))
{
/* fill the string to the defined limit */
zbx_strncpy_alloc(&s->buffer, &alloc, &offset, buffer, left);
@@ -2021,7 +2021,7 @@ int zbx_udp_send(zbx_socket_t *s, const char *data, size_t data_len, int timeout
if (0 != timeout)
zbx_socket_timeout_set(s, timeout);
- if (ZBX_PROTO_ERROR == sendto(s->socket, data, data_len, 0, NULL, 0))
+ if (ZBX_PROTO_ERROR == zbx_sendto(s->socket, data, data_len, 0, NULL, 0))
{
zbx_set_socket_strerror("sendto() failed: %s", strerror_from_system(zbx_socket_last_error()));
ret = FAIL;
diff --git a/src/libs/zbxdbcache/dbconfig.c b/src/libs/zbxdbcache/dbconfig.c
index 51f999ce98f..abb1a83d709 100644
--- a/src/libs/zbxdbcache/dbconfig.c
+++ b/src/libs/zbxdbcache/dbconfig.c
@@ -4870,6 +4870,7 @@ void DCsync_configuration(unsigned char mode)
config->status->last_update = 0;
config->sync_ts = time(NULL);
+ config->proxy_lastaccess_ts = time(NULL);
FINISH_SYNC;
out:
@@ -10635,18 +10636,47 @@ void zbx_dc_items_update_nextcheck(DC_ITEM *items, zbx_agent_value_t *values, in
* *
* Parameter: hostid - [IN] the proxy identifier (hostid) *
* lastaccess - [IN] the last time proxy data was received/sent *
+ * proxy_diff - [OUT] last access updates for proxies that need *
+ * to be synced with database *
* *
******************************************************************************/
-void zbx_dc_update_proxy_lastaccess(zbx_uint64_t hostid, int lastaccess)
+void zbx_dc_update_proxy_lastaccess(zbx_uint64_t hostid, int lastaccess, zbx_vector_uint64_pair_t *proxy_diff)
{
ZBX_DC_PROXY *proxy;
+ int now;
LOCK_CACHE;
if (NULL != (proxy = (ZBX_DC_PROXY *)zbx_hashset_search(&config->proxies, &hostid)))
- proxy->lastaccess = lastaccess;
+ {
+ if (lastaccess < config->proxy_lastaccess_ts)
+ proxy->lastaccess = config->proxy_lastaccess_ts;
+ else
+ proxy->lastaccess = lastaccess;
+ }
+
+ if (ZBX_PROXY_LASTACCESS_UPDATE_FREQUENCY < (now = time(NULL)) - config->proxy_lastaccess_ts)
+ {
+ zbx_hashset_iter_t iter;
+
+ zbx_hashset_iter_reset(&config->proxies, &iter);
+
+ while (NULL != (proxy = (ZBX_DC_PROXY *)zbx_hashset_iter_next(&iter)))
+ {
+ if (proxy->lastaccess >= config->proxy_lastaccess_ts)
+ {
+ zbx_uint64_pair_t pair = {proxy->hostid, proxy->lastaccess};
+
+ zbx_vector_uint64_pair_append(proxy_diff, pair);
+ }
+ }
+
+ config->proxy_lastaccess_ts = now;
+ }
UNLOCK_CACHE;
+
+ zbx_vector_uint64_pair_sort(proxy_diff, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
}
/******************************************************************************
diff --git a/src/libs/zbxdbcache/dbconfig.h b/src/libs/zbxdbcache/dbconfig.h
index 35fb109d5e5..3fe954d8d80 100644
--- a/src/libs/zbxdbcache/dbconfig.h
+++ b/src/libs/zbxdbcache/dbconfig.h
@@ -599,6 +599,7 @@ typedef struct
{
/* timestamp of the last host availability diff sent to sever, used only by proxies */
int availability_diff_ts;
+ int proxy_lastaccess_ts;
int sync_ts;
zbx_hashset_t items;
diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c
index 8c5960dfe06..ec9e0ee6c23 100644
--- a/src/libs/zbxdbhigh/host.c
+++ b/src/libs/zbxdbhigh/host.c
@@ -4018,10 +4018,12 @@ typedef struct
char *required;
char *status_codes;
zbx_vector_ptr_t httpstepitems;
- int no;
+ zbx_vector_ptr_t fields;
char *timeout;
+ int no;
+ int follow_redirects;
+ int retrieve_mode;
int post_type;
- zbx_vector_ptr_t fields;
}
httpstep_t;
@@ -4189,7 +4191,8 @@ static void DBget_httptests(zbx_uint64_t hostid, const zbx_vector_uint64_t *temp
sql_offset = 0;
zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset,
- "select httpstepid,httptestid,name,no,url,timeout,posts,required,status_codes,post_type"
+ "select httpstepid,httptestid,name,no,url,timeout,posts,required,status_codes,"
+ "follow_redirects,retrieve_mode,post_type"
" from httpstep"
" where");
DBadd_condition_alloc(&sql, &sql_alloc, &sql_offset, "httptestid",
@@ -4224,7 +4227,9 @@ static void DBget_httptests(zbx_uint64_t hostid, const zbx_vector_uint64_t *temp
httpstep->posts = zbx_strdup(NULL, row[6]);
httpstep->required = zbx_strdup(NULL, row[7]);
httpstep->status_codes = zbx_strdup(NULL, row[8]);
- httpstep->post_type = atoi(row[9]);
+ httpstep->follow_redirects = atoi(row[9]);
+ httpstep->retrieve_mode = atoi(row[10]);
+ httpstep->post_type = atoi(row[11]);
zbx_vector_ptr_create(&httpstep->httpstepitems);
zbx_vector_ptr_create(&httpstep->fields);
@@ -4567,7 +4572,8 @@ static void DBsave_httptests(zbx_uint64_t hostid, zbx_vector_ptr_t *httptests)
httpstepid = DBget_maxid_num("httpstep", num_httpsteps);
zbx_db_insert_prepare(&db_insert_hstep, "httpstep", "httpstepid", "httptestid", "name", "no", "url",
- "timeout", "posts", "required", "status_codes", "post_type", NULL);
+ "timeout", "posts", "required", "status_codes", "follow_redirects", "retrieve_mode",
+ "post_type", NULL);
}
if (0 != num_httptestitems)
@@ -4627,6 +4633,7 @@ static void DBsave_httptests(zbx_uint64_t hostid, zbx_vector_ptr_t *httptests)
zbx_db_insert_add_values(&db_insert_hstep, httpstepid, httptest->httptestid,
httpstep->name, httpstep->no, httpstep->url, httpstep->timeout,
httpstep->posts, httpstep->required, httpstep->status_codes,
+ httpstep->follow_redirects, httpstep->retrieve_mode,
httpstep->post_type);
for (k = 0; k < httpstep->fields.values_num; k++)
diff --git a/src/libs/zbxdbhigh/proxy.c b/src/libs/zbxdbhigh/proxy.c
index 23fc897d6c1..d50a756384b 100644
--- a/src/libs/zbxdbhigh/proxy.c
+++ b/src/libs/zbxdbhigh/proxy.c
@@ -394,13 +394,63 @@ int check_access_passive_proxy(zbx_socket_t *sock, int send_response, const char
/******************************************************************************
* *
+ * Function: db_update_proxies_lastaccess *
+ * *
+ * Purpose: updates proxy last access timestamp in database *
+ * *
+ * Parameter: proxy_diff - [IN] last access updates for proxies *
+ * *
+ ******************************************************************************/
+static void db_update_proxies_lastaccess(const zbx_vector_uint64_pair_t *proxy_diff)
+{
+ char *sql;
+ size_t sql_alloc = 256, sql_offset = 0;
+ int i;
+
+ sql = zbx_malloc(NULL, sql_alloc);
+
+ DBbegin();
+ DBbegin_multiple_update(&sql, &sql_alloc, &sql_offset);
+
+ for (i = 0; i < proxy_diff->values_num; i++)
+ {
+ zbx_uint64_pair_t pair = proxy_diff->values[i];
+
+ zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, "update hosts"
+ " set lastaccess=%d"
+ " where hostid=" ZBX_FS_UI64 ";\n",
+ pair.second, pair.first);
+
+ DBexecute_overflowed_sql(&sql, &sql_alloc, &sql_offset);
+ }
+
+ DBend_multiple_update(&sql, &sql_alloc, &sql_offset);
+
+ if (16 < sql_offset) /* in ORACLE always present begin..end; */
+ DBexecute("%s", sql);
+
+ DBcommit();
+
+ zbx_free(sql);
+}
+
+/******************************************************************************
+ * *
* Function: update_proxy_lastaccess *
* *
******************************************************************************/
void update_proxy_lastaccess(const zbx_uint64_t hostid, time_t last_access)
{
- DBexecute("update hosts set lastaccess=%d where hostid=" ZBX_FS_UI64, last_access, hostid);
- zbx_dc_update_proxy_lastaccess(hostid, last_access);
+ zbx_vector_uint64_pair_t proxy_diff;
+
+ zbx_vector_uint64_pair_create(&proxy_diff);
+
+ zbx_dc_update_proxy_lastaccess(hostid, last_access, &proxy_diff);
+
+ if (0 != proxy_diff.values_num)
+ db_update_proxies_lastaccess(&proxy_diff);
+
+ zbx_vector_uint64_pair_destroy(&proxy_diff);
}
/******************************************************************************
diff --git a/src/libs/zbxdbupgrade/dbupgrade_3050.c b/src/libs/zbxdbupgrade/dbupgrade_3050.c
index a8d5ea2f2f2..d70f707d631 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_3050.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_3050.c
@@ -75,6 +75,24 @@ clean:
return ret;
}
+static int DBpatch_3050002(void)
+{
+ const ZBX_FIELD field = {"colorpalette", "", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
+
+ return DBadd_field("graph_theme", &field);
+}
+
+static int DBpatch_3050003(void)
+{
+ const char *colorpalette = "1A7C11,F63100,2774A4,A54F10,FC6EA3,6C59DC,AC8C14,611F27,F230E0,5CCD18,BB2A02,"
+ "5A2B57,89ABF8,7EC25C,274482,2B5429,8048B4,FD5434,790E1F,87AC4D,E89DF4";
+
+ if (ZBX_DB_OK > DBexecute("update graph_theme set colorpalette='%s'", colorpalette))
+ return FAIL;
+
+ return SUCCEED;
+}
+
#endif
DBPATCH_START(3050)
@@ -83,5 +101,7 @@ DBPATCH_START(3050)
DBPATCH_ADD(3050000, 0, 1)
DBPATCH_ADD(3050001, 0, 1)
+DBPATCH_ADD(3050002, 0, 1)
+DBPATCH_ADD(3050003, 0, 1)
DBPATCH_END()
diff --git a/src/libs/zbxjson/json_parser.c b/src/libs/zbxjson/json_parser.c
index 4c7aa74934a..12c2f7337f0 100644
--- a/src/libs/zbxjson/json_parser.c
+++ b/src/libs/zbxjson/json_parser.c
@@ -129,7 +129,7 @@ static int json_parse_string(const char *start, char **error)
ptr++;
}
- return ptr - start + 1;
+ return (int)(ptr - start) + 1;
}
/******************************************************************************
@@ -178,7 +178,7 @@ static int json_parse_array(const char *start, char **error)
return json_error("invalid array format, expected closing character ']'", ptr, error);
}
- return ptr - start + 1;
+ return (int)(ptr - start) + 1;
}
/******************************************************************************
@@ -253,7 +253,7 @@ static int json_parse_number(const char *start, char **error)
}
}
- return ptr - start;
+ return (int)(ptr - start);
}
/******************************************************************************
@@ -288,7 +288,7 @@ static int json_parse_literal(const char *start, const char *text, char **error)
text++;
}
- return ptr - start;
+ return (int)(ptr - start);
}
/******************************************************************************
@@ -360,7 +360,7 @@ int json_parse_value(const char *start, char **error)
return json_error("invalid JSON object value starting character", ptr, error);
}
- return ptr - start + len;
+ return (int)(ptr - start) + len;
}
/******************************************************************************
@@ -429,7 +429,7 @@ static int json_parse_object(const char *start, char **error)
return json_error("invalid object format, expected closing character '}'", ptr, error);
}
- return ptr - start + 1;
+ return (int)(ptr - start) + 1;
}
/******************************************************************************
diff --git a/src/libs/zbxlog/log.c b/src/libs/zbxlog/log.c
index 5e9dac3dcc9..a60d173d006 100644
--- a/src/libs/zbxlog/log.c
+++ b/src/libs/zbxlog/log.c
@@ -595,9 +595,9 @@ void __zbx_zabbix_log(int level, const char *fmt, ...)
int zbx_get_log_type(const char *logtype)
{
const char *logtypes[] = {ZBX_OPTION_LOGTYPE_SYSTEM, ZBX_OPTION_LOGTYPE_FILE, ZBX_OPTION_LOGTYPE_CONSOLE};
- size_t i;
+ int i;
- for (i = 0; i < ARRSIZE(logtypes); i++)
+ for (i = 0; i < (int)ARRSIZE(logtypes); i++)
{
if (0 == strcmp(logtype, logtypes[i]))
return i + 1;
diff --git a/src/libs/zbxsysinfo/simple/ntp.c b/src/libs/zbxsysinfo/simple/ntp.c
index dea0994a52a..3dcc6b49269 100644
--- a/src/libs/zbxsysinfo/simple/ntp.c
+++ b/src/libs/zbxsysinfo/simple/ntp.c
@@ -161,7 +161,7 @@ int check_ntp(char *host, unsigned short port, int timeout, int *value_int)
if (SUCCEED == (ret = zbx_udp_recv(&s, timeout)))
{
*value_int = (SUCCEED == unpack_ntp(&data, (unsigned char *)request,
- (unsigned char *)s.buffer, s.read_bytes));
+ (unsigned char *)s.buffer, (int)s.read_bytes));
}
}
diff --git a/src/libs/zbxwin32/fatal.c b/src/libs/zbxwin32/fatal.c
index 3dd625fba9f..c4cfa4de45a 100644
--- a/src/libs/zbxwin32/fatal.c
+++ b/src/libs/zbxwin32/fatal.c
@@ -146,7 +146,7 @@ static void print_backtrace(CONTEXT *pctx)
if (0 != GetModuleFileNameEx(hProcess, NULL, szProcessName, ARRSIZE(szProcessName)))
{
char *ptr;
- int path_alloc = 0, path_offset = 0;
+ size_t path_alloc = 0, path_offset = 0;
process_name = zbx_unicode_to_utf8(szProcessName);
diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c
index 381ff60da52..74311644705 100644
--- a/src/zabbix_agent/active.c
+++ b/src/zabbix_agent/active.c
@@ -1871,7 +1871,7 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
{
ZBX_THREAD_ACTIVECHK_ARGS activechk_args;
- int nextcheck = 0, nextrefresh = 0, nextsend = 0, now, delta, lastcheck = 0;
+ time_t nextcheck = 0, nextrefresh = 0, nextsend = 0, now, delta, lastcheck = 0;
assert(args);
assert(((zbx_thread_args_t *)args)->args);
@@ -1902,7 +1902,7 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
if (now >= nextsend)
{
send_buffer(activechk_args.host, activechk_args.port);
- nextsend = (int)time(NULL) + 1;
+ nextsend = time(NULL) + 1;
}
if (now >= nextrefresh)
@@ -1911,11 +1911,11 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
if (FAIL == refresh_active_checks(activechk_args.host, activechk_args.port))
{
- nextrefresh = (int)time(NULL) + 60;
+ nextrefresh = time(NULL) + 60;
}
else
{
- nextrefresh = (int)time(NULL) + CONFIG_REFRESH_ACTIVE_CHECKS;
+ nextrefresh = time(NULL) + CONFIG_REFRESH_ACTIVE_CHECKS;
}
}
@@ -1930,7 +1930,7 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
nextcheck = get_min_nextcheck();
if (FAIL == nextcheck)
- nextcheck = (int)time(NULL) + 60;
+ nextcheck = time(NULL) + 60;
}
else
{
@@ -1938,7 +1938,7 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
{
zabbix_log(LOG_LEVEL_WARNING, "the system time has been pushed back,"
" adjusting active check schedule");
- update_schedule(delta);
+ update_schedule((int)delta);
nextcheck += delta;
nextsend += delta;
nextrefresh += delta;
diff --git a/src/zabbix_agent/cpustat.c b/src/zabbix_agent/cpustat.c
index 5b2f3933341..9333443b1df 100644
--- a/src/zabbix_agent/cpustat.c
+++ b/src/zabbix_agent/cpustat.c
@@ -395,6 +395,10 @@ static void update_cpustats(ZBX_CPUS_STAT_DATA *pcpus)
&counter[ZBX_CPU_STATE_SOFTIRQ], &counter[ZBX_CPU_STATE_STEAL],
&counter[ZBX_CPU_STATE_GCPU], &counter[ZBX_CPU_STATE_GNICE]);
+ /* Linux includes guest times in user and nice times */
+ counter[ZBX_CPU_STATE_USER] -= counter[ZBX_CPU_STATE_GCPU];
+ counter[ZBX_CPU_STATE_NICE] -= counter[ZBX_CPU_STATE_GNICE];
+
update_cpu_counters(&pcpus->cpu[idx], counter);
cpu_status[idx] = SYSINFO_RET_OK;
}
diff --git a/src/zabbix_agent/logfiles.c b/src/zabbix_agent/logfiles.c
index 76cd9073c92..f6cc98c83d5 100644
--- a/src/zabbix_agent/logfiles.c
+++ b/src/zabbix_agent/logfiles.c
@@ -61,8 +61,8 @@ static int split_string(const char *str, const char *del, char **part1, char **p
assert(NULL != str && '\0' != *str);
assert(NULL != del && '\0' != *del);
- assert(NULL != part1 && '\0' == *part1); /* target 1 must be empty */
- assert(NULL != part2 && '\0' == *part2); /* target 2 must be empty */
+ assert(NULL != part1 && NULL == *part1); /* target 1 must be empty */
+ assert(NULL != part2 && NULL == *part2); /* target 2 must be empty */
zabbix_log(LOG_LEVEL_DEBUG, "In %s() str:'%s' del:'%s'", __function_name, str, del);
@@ -1110,7 +1110,7 @@ static void add_logfile(struct st_logfile **logfiles, int *logfiles_alloc, int *
}
(*logfiles)[i].filename = zbx_strdup(NULL, filename);
- (*logfiles)[i].mtime = st->st_mtime;
+ (*logfiles)[i].mtime = (int)st->st_mtime;
(*logfiles)[i].md5size = -1;
(*logfiles)[i].seq = 0;
(*logfiles)[i].incomplete = 0;
diff --git a/src/zabbix_java/src/com/zabbix/gateway/JMXItemChecker.java b/src/zabbix_java/src/com/zabbix/gateway/JMXItemChecker.java
index c314f49dddb..6a6c1ed328b 100644
--- a/src/zabbix_java/src/com/zabbix/gateway/JMXItemChecker.java
+++ b/src/zabbix_java/src/com/zabbix/gateway/JMXItemChecker.java
@@ -21,6 +21,7 @@ package com.zabbix.gateway;
import java.util.HashMap;
import java.util.Map;
+import java.util.HashSet;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanServerConnection;
@@ -156,7 +157,7 @@ class JMXItemChecker extends ItemChecker
JSONArray counters = new JSONArray();
ObjectName filter = (2 == argumentCount) ? new ObjectName(item.getArgument(2)) : null;
-
+
int mode = DISCOVERY_MODE_ATTRIBUTES;
if (0 != argumentCount)
{
@@ -259,13 +260,28 @@ class JMXItemChecker extends ItemChecker
{
try
{
+ HashSet<String> properties = new HashSet<String>();
JSONObject counter = new JSONObject();
+ // Default properties are added.
counter.put("{#JMXOBJ}", name);
counter.put("{#JMXDOMAIN}", name.getDomain());
+ properties.add("OBJ");
+ properties.add("DOMAIN");
for (Map.Entry<String, String> property : name.getKeyPropertyList().entrySet())
- counter.put("{#JMX" + property.getKey().toUpperCase() + "}" , property.getValue());
+ {
+ String key = property.getKey().toUpperCase();
+
+ // Property key should only contain valid characters and should not be already added to attribute list.
+ if (key.matches("^[A-Z0-9_\\.]+$") && !properties.contains(key))
+ {
+ counter.put("{#JMX" + key + "}" , property.getValue());
+ properties.add(key);
+ }
+ else
+ logger.trace("bean '{}' property '{}' was ignored", name, property.getKey());
+ }
counters.put(counter);
}
diff --git a/src/zabbix_server/alerter/alert_manager.c b/src/zabbix_server/alerter/alert_manager.c
index e080915642f..66aa5cedc3c 100644
--- a/src/zabbix_server/alerter/alert_manager.c
+++ b/src/zabbix_server/alerter/alert_manager.c
@@ -1022,6 +1022,48 @@ static void am_destroy(zbx_am_t *manager)
/******************************************************************************
* *
+ * Function: am_db_update_alert *
+ * *
+ * Purpose: update alert status in local cache to be flushed after reading *
+ * new alerts from database *
+ * *
+ * Parameters: manager - [IN] the manager *
+ * alertid - [IN] the alert identifier *
+ * status - [IN] the alert status *
+ * retries - [IN] the number of attempted sending retries *
+ * error - [IN] the error message *
+ * *
+ ******************************************************************************/
+static void am_db_update_alert(zbx_am_t *manager, zbx_uint64_t alertid, int status, int retries, char *error)
+{
+ const char *__function_name = "am_db_update_alert";
+
+ zbx_am_alertstatus_t *update;
+
+ zabbix_log(LOG_LEVEL_DEBUG, "In %s() alertid:" ZBX_FS_UI64 " status:%d retries:%d error:%s", __function_name,
+ alertid, status, retries, error);
+
+ /* alerts with 0 alertid are runtime alerts generated by alert manager when database is down */
+ if (0 != alertid)
+ {
+ if (NULL == (update = (zbx_am_alertstatus_t *)zbx_hashset_search(&manager->alertupdates, &alertid)))
+ {
+ zbx_am_alertstatus_t update_local = {.alertid = alertid};
+
+ update = (zbx_am_alertstatus_t *)zbx_hashset_insert(&manager->alertupdates, &update_local,
+ sizeof(update_local));
+ }
+
+ update->retries = retries;
+ update->status = status;
+ ZBX_UPDATE_STR(update->error, error);
+ }
+
+ zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);
+}
+
+/******************************************************************************
+ * *
* Function: am_db_get_alerts *
* *
* Purpose: reads the new alerts from database *
@@ -1036,7 +1078,7 @@ static void am_destroy(zbx_am_t *manager)
* FAIL - database connection error *
* *
******************************************************************************/
-static int am_db_get_alerts(zbx_vector_ptr_t *alerts, int now)
+static int am_db_get_alerts(zbx_am_t *manager, zbx_vector_ptr_t *alerts, int now)
{
const char *__function_name = "am_db_get_alerts";
@@ -1082,6 +1124,14 @@ static int am_db_get_alerts(zbx_vector_ptr_t *alerts, int now)
ZBX_STR2UINT64(mediatypeid, row[1]);
status = atoi(row[5]);
attempts = atoi(row[6]);
+
+ if (SUCCEED == DBis_null(row[7]))
+ {
+ am_db_update_alert(manager, alertid, ALERT_STATUS_FAILED, 0,
+ "Related event was removed.");
+ continue;
+ }
+
source = atoi(row[7]);
object = atoi(row[8]);
ZBX_STR2UINT64(objectid, row[9]);
@@ -1250,7 +1300,7 @@ static int am_db_queue_alerts(zbx_am_t *manager, int now)
zbx_vector_ptr_create(&alerts);
- if (FAIL == (ret = am_db_get_alerts(&alerts, now)))
+ if (FAIL == (ret = am_db_get_alerts(manager, &alerts, now)))
goto out;
/* update media types for new and queued alerts */
@@ -1311,48 +1361,6 @@ out:
/******************************************************************************
* *
- * Function: am_db_update_alert *
- * *
- * Purpose: update alert status in local cache to be flushed after reading *
- * new alerts from database *
- * *
- * Parameters: manager - [IN] the manager *
- * alertid - [IN] the alert identifier *
- * status - [IN] the alert status *
- * retries - [IN] the number of attempted sending retries *
- * error - [IN] the error message *
- * *
- ******************************************************************************/
-static void am_db_update_alert(zbx_am_t *manager, zbx_uint64_t alertid, int status, int retries, char *error)
-{
- const char *__function_name = "am_db_update_alert";
-
- zbx_am_alertstatus_t *update;
-
- zabbix_log(LOG_LEVEL_DEBUG, "In %s() alertid:" ZBX_FS_UI64 " status:%d retries:%d error:%s", __function_name,
- alertid, status, retries, error);
-
- /* alerts with 0 alertid are runtime alerts generated by alert manager when database is down */
- if (0 != alertid)
- {
- if (NULL == (update = (zbx_am_alertstatus_t *)zbx_hashset_search(&manager->alertupdates, &alertid)))
- {
- zbx_am_alertstatus_t update_local = {.alertid = alertid};
-
- update = (zbx_am_alertstatus_t *)zbx_hashset_insert(&manager->alertupdates, &update_local,
- sizeof(update_local));
- }
-
- update->retries = retries;
- update->status = status;
- ZBX_UPDATE_STR(update->error, error);
- }
-
- zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);
-}
-
-/******************************************************************************
- * *
* Function: am_db_flush_alert_updates *
* *
* Purpose: flush cached alert status updates to database *
@@ -1851,11 +1859,10 @@ ZBX_THREAD_ENTRY(alert_manager_thread, args)
zbx_ipc_client_t *client;
zbx_ipc_message_t *message;
zbx_am_alerter_t *alerter;
- int ret, sent_num, failed_num, now, time_db, time_watchdog, freq_watchdog, time_connect;
- double time_stat, time_idle, time_now;
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- double resolver_timestamp = 0.0;
-#endif
+ int ret, sent_num = 0, failed_num = 0, now, time_db = 0, time_watchdog = 0, freq_watchdog;
+ int time_connect;
+ double time_stat, time_idle = 0, time_now, time_file = 0;
+
process_type = ((zbx_thread_args_t *)args)->process_type;
server_num = ((zbx_thread_args_t *)args)->server_num;
process_num = ((zbx_thread_args_t *)args)->process_num;
@@ -1880,11 +1887,6 @@ ZBX_THREAD_ENTRY(alert_manager_thread, args)
time_stat = zbx_time();
time_now = time_stat;
time_connect = time_now;
- time_idle = 0;
- sent_num = 0;
- failed_num = 0;
- time_db = 0;
- time_watchdog = 0;
if (ZBX_WATCHDOG_ALERT_FREQUENCY < (freq_watchdog = CONFIG_CONFSYNCER_FREQUENCY))
freq_watchdog = ZBX_WATCHDOG_ALERT_FREQUENCY;
@@ -1929,8 +1931,6 @@ ZBX_THREAD_ENTRY(alert_manager_thread, args)
failed_num = 0;
}
- zbx_handle_log();
-
if (ZBX_DB_OK == manager.dbstatus && now - time_db >= ZBX_AM_DB_POLL_DELAY)
{
if (SUCCEED == (ret = am_db_flush_alert_updates(&manager)))
@@ -1968,15 +1968,16 @@ ZBX_THREAD_ENTRY(alert_manager_thread, args)
ret = zbx_ipc_service_recv(&alerter_service, 1, &client, &message);
update_selfmon_counter(ZBX_PROCESS_STATE_BUSY);
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- /* handle /etc/resolv.conf update less often than once a second */
-
- if (1.0 < time_now - resolver_timestamp)
+ /* handle /etc/resolv.conf update and log rotate less often than once a second */
+ if (1.0 < time_now - time_file)
{
- resolver_timestamp = time_now;
+ time_file = time_now;
+ zbx_handle_log();
+#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
zbx_update_resolver_conf();
- }
#endif
+ }
+
if (ZBX_IPC_RECV_IMMEDIATE != ret)
time_idle += zbx_time() - time_now;
diff --git a/src/zabbix_server/alerter/alerter.c b/src/zabbix_server/alerter/alerter.c
index d235b247eb5..477a926d850 100644
--- a/src/zabbix_server/alerter/alerter.c
+++ b/src/zabbix_server/alerter/alerter.c
@@ -280,13 +280,11 @@ ZBX_THREAD_ENTRY(alerter_thread, args)
/* once in STAT_INTERVAL seconds */
char *error = NULL;
- int success_num, fail_num;
+ int success_num = 0, fail_num = 0;
zbx_ipc_socket_t alerter_socket;
zbx_ipc_message_t message;
- double time_stat, time_idle, time_now, time_read;
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- double resolver_timestamp = 0.0;
-#endif
+ double time_stat, time_idle = 0, time_now, time_read, time_file = 0;
+
process_type = ((zbx_thread_args_t *)args)->process_type;
server_num = ((zbx_thread_args_t *)args)->server_num;
process_num = ((zbx_thread_args_t *)args)->process_num;
@@ -307,11 +305,7 @@ ZBX_THREAD_ENTRY(alerter_thread, args)
alerter_register(&alerter_socket);
- /* initialize statistics */
time_stat = zbx_time();
- time_idle = 0;
- success_num = 0;
- fail_num = 0;
zbx_setproctitle("%s #%d started", get_process_type_string(process_type), process_num);
@@ -333,8 +327,6 @@ ZBX_THREAD_ENTRY(alerter_thread, args)
fail_num = 0;
}
- zbx_handle_log();
-
update_selfmon_counter(ZBX_PROCESS_STATE_IDLE);
if (SUCCEED != zbx_ipc_socket_read(&alerter_socket, &message))
@@ -345,15 +337,16 @@ ZBX_THREAD_ENTRY(alerter_thread, args)
update_selfmon_counter(ZBX_PROCESS_STATE_BUSY);
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- /* handle /etc/resolv.conf update less often than once a second */
-
- if (1.0 < time_now - resolver_timestamp)
+ /* handle /etc/resolv.conf update and log rotate less often than once a second */
+ if (1.0 < time_now - time_file)
{
- resolver_timestamp = time_now;
+ time_file = time_now;
+ zbx_handle_log();
+#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
zbx_update_resolver_conf();
- }
#endif
+ }
+
time_read = zbx_time();
time_idle += time_read - time_now;
diff --git a/src/zabbix_server/ipmi/ipmi_manager.c b/src/zabbix_server/ipmi/ipmi_manager.c
index 4f7dbf479fb..7150c939c01 100644
--- a/src/zabbix_server/ipmi/ipmi_manager.c
+++ b/src/zabbix_server/ipmi/ipmi_manager.c
@@ -957,11 +957,8 @@ ZBX_THREAD_ENTRY(ipmi_manager_thread, args)
zbx_ipc_message_t *message;
zbx_ipmi_manager_t ipmi_manager;
zbx_ipmi_poller_t *poller;
- int ret, nextcheck, timeout, nextcleanup, polled_num, scheduled_num, now;
- double time_stat, time_idle, time_now;
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- double resolver_timestamp = 0.0;
-#endif
+ int ret, nextcheck, timeout, nextcleanup, polled_num = 0, scheduled_num = 0, now;
+ double time_stat, time_idle = 0, time_now, time_file = 0;
#define STAT_INTERVAL 5 /* if a process is busy and does not sleep then update status not faster than */
/* once in STAT_INTERVAL seconds */
@@ -988,11 +985,7 @@ ZBX_THREAD_ENTRY(ipmi_manager_thread, args)
nextcleanup = time(NULL) + ZBX_IPMI_MANAGER_CLEANUP_DELAY;
- /* initialize statistics */
time_stat = zbx_time();
- time_idle = 0;
- polled_num = 0;
- scheduled_num = 0;
zbx_setproctitle("%s #%d started", get_process_type_string(process_type), process_num);
@@ -1015,8 +1008,6 @@ ZBX_THREAD_ENTRY(ipmi_manager_thread, args)
scheduled_num = 0;
}
- zbx_handle_log();
-
scheduled_num += ipmi_manager_schedule_requests(&ipmi_manager, now, &nextcheck);
if (FAIL != nextcheck)
@@ -1031,15 +1022,16 @@ ZBX_THREAD_ENTRY(ipmi_manager_thread, args)
ret = zbx_ipc_service_recv(&ipmi_service, timeout, &client, &message);
update_selfmon_counter(ZBX_PROCESS_STATE_BUSY);
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- /* handle /etc/resolv.conf update less often than once a second */
-
- if (1.0 < time_now - resolver_timestamp)
+ /* handle /etc/resolv.conf update and log rotate less often than once a second */
+ if (1.0 < time_now - time_file)
{
- resolver_timestamp = time_now;
+ time_file = time_now;
+ zbx_handle_log();
+#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
zbx_update_resolver_conf();
- }
#endif
+ }
+
if (ZBX_IPC_RECV_IMMEDIATE != ret)
time_idle += zbx_time() - time_now;
diff --git a/src/zabbix_server/ipmi/ipmi_poller.c b/src/zabbix_server/ipmi/ipmi_poller.c
index b818dd06064..289ed816d65 100644
--- a/src/zabbix_server/ipmi/ipmi_poller.c
+++ b/src/zabbix_server/ipmi/ipmi_poller.c
@@ -30,6 +30,7 @@
#include "ipmi_manager.h"
#include "ipmi_protocol.h"
#include "checks_ipmi.h"
+#include "ipmi_poller.h"
#define ZBX_IPMI_MANAGER_CLEANUP_DELAY SEC_PER_DAY
@@ -168,11 +169,8 @@ ZBX_THREAD_ENTRY(ipmi_poller_thread, args)
char *error = NULL;
zbx_ipc_socket_t ipmi_socket;
zbx_ipc_message_t message;
- int polled_num;
- double time_stat, time_idle, time_now, time_read;
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- double resolver_timestamp = 0.0;
-#endif
+ int polled_num = 0;
+ double time_stat, time_idle = 0, time_now, time_read, time_file = 0;
#define STAT_INTERVAL 5 /* if a process is busy and does not sleep then update status not faster than */
/* once in STAT_INTERVAL seconds */
@@ -200,10 +198,7 @@ ZBX_THREAD_ENTRY(ipmi_poller_thread, args)
ipmi_poller_register(&ipmi_socket);
- /* initialize statistics */
time_stat = zbx_time();
- time_idle = 0;
- polled_num = 0;
zbx_setproctitle("%s #%d started", get_process_type_string(process_type), process_num);
@@ -224,8 +219,6 @@ ZBX_THREAD_ENTRY(ipmi_poller_thread, args)
polled_num = 0;
}
- zbx_handle_log();
-
update_selfmon_counter(ZBX_PROCESS_STATE_IDLE);
if (SUCCEED != zbx_ipc_socket_read(&ipmi_socket, &message))
@@ -236,15 +229,16 @@ ZBX_THREAD_ENTRY(ipmi_poller_thread, args)
update_selfmon_counter(ZBX_PROCESS_STATE_BUSY);
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- /* handle /etc/resolv.conf update less often than once a second */
-
- if (1.0 < time_now - resolver_timestamp)
+ /* handle /etc/resolv.conf update and log rotate less often than once a second */
+ if (1.0 < time_now - time_file)
{
- resolver_timestamp = time_now;
+ time_file = time_now;
+ zbx_handle_log();
+#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
zbx_update_resolver_conf();
- }
#endif
+ }
+
time_read = zbx_time();
time_idle += time_read - time_now;
diff --git a/src/zabbix_server/preprocessor/preproc_manager.c b/src/zabbix_server/preprocessor/preproc_manager.c
index 41403198cfe..6538cf10390 100644
--- a/src/zabbix_server/preprocessor/preproc_manager.c
+++ b/src/zabbix_server/preprocessor/preproc_manager.c
@@ -1003,10 +1003,7 @@ ZBX_THREAD_ENTRY(preprocessing_manager_thread, args)
zbx_ipc_message_t *message;
zbx_preprocessing_manager_t manager;
int ret;
- double time_stat, time_idle, time_now, time_flush;
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- double resolver_timestamp = 0.0;
-#endif
+ double time_stat, time_idle = 0, time_now, time_flush, time_file = 0;
#define STAT_INTERVAL 5 /* if a process is busy and does not sleep then update status not faster than */
/* once in STAT_INTERVAL seconds */
@@ -1033,7 +1030,6 @@ ZBX_THREAD_ENTRY(preprocessing_manager_thread, args)
time_stat = zbx_time();
time_now = time_stat;
time_flush = time_stat;
- time_idle = 0;
zbx_setproctitle("%s #%d started", get_process_type_string(process_type), process_num);
@@ -1054,20 +1050,20 @@ ZBX_THREAD_ENTRY(preprocessing_manager_thread, args)
manager.processed_num = 0;
}
- zbx_handle_log();
update_selfmon_counter(ZBX_PROCESS_STATE_IDLE);
ret = zbx_ipc_service_recv(&service, ZBX_PREPROCESSING_MANAGER_DELAY, &client, &message);
update_selfmon_counter(ZBX_PROCESS_STATE_BUSY);
-#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
- /* handle /etc/resolv.conf update less often than once a second */
-
- if (1.0 < time_now - resolver_timestamp)
+ /* handle /etc/resolv.conf update and log rotate less often than once a second */
+ if (1.0 < time_now - time_file)
{
- resolver_timestamp = time_now;
+ time_file = time_now;
+ zbx_handle_log();
+#if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
zbx_update_resolver_conf();
- }
#endif
+ }
+
if (ZBX_IPC_RECV_IMMEDIATE != ret)
time_idle += zbx_time() - time_now;
diff --git a/src/zabbix_server/proxypoller/proxypoller.c b/src/zabbix_server/proxypoller/proxypoller.c
index 92d9a3f2a21..b462a435073 100644
--- a/src/zabbix_server/proxypoller/proxypoller.c
+++ b/src/zabbix_server/proxypoller/proxypoller.c
@@ -830,11 +830,7 @@ static int process_proxy(void)
}
network_error:
if (0 != last_access)
- {
- DBbegin();
update_proxy_lastaccess(proxy.hostid, last_access);
- DBcommit();
- }
DCrequeue_proxy(proxy.hostid, update_nextcheck);
}