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
diff options
context:
space:
mode:
-rw-r--r--include/dbcache.h2
-rw-r--r--include/proxy.h4
-rw-r--r--include/zbxalgo.h43
-rw-r--r--include/zbxjson.h4
-rw-r--r--src/libs/zbxalgo/Makefile.am1
-rw-r--r--src/libs/zbxalgo/linked_list.c (renamed from src/zabbix_server/preprocessor/linked_list.c)29
-rw-r--r--src/libs/zbxdbcache/dbcache.c200
-rw-r--r--src/libs/zbxdbhigh/proxy.c2
-rw-r--r--src/zabbix_proxy/datasender/datasender.c72
-rw-r--r--src/zabbix_proxy/heart/heart.c2
-rw-r--r--src/zabbix_proxy/servercomms.c2
-rw-r--r--src/zabbix_server/preprocessor/Makefile.am2
-rw-r--r--src/zabbix_server/preprocessor/linked_list.h65
-rw-r--r--src/zabbix_server/preprocessor/preproc_manager.c2
-rw-r--r--src/zabbix_server/proxypoller/proxypoller.c6
-rw-r--r--src/zabbix_server/trapper/proxydata.c28
-rw-r--r--src/zabbix_server/trapper/proxydata.h2
17 files changed, 368 insertions, 98 deletions
diff --git a/include/dbcache.h b/include/dbcache.h
index 28843140b7c..1e66f16bee1 100644
--- a/include/dbcache.h
+++ b/include/dbcache.h
@@ -1005,4 +1005,6 @@ void zbx_db_trigger_queue_unlock(void);
void zbx_get_host_interfaces_availability(zbx_uint64_t hostid, zbx_agent_availability_t *agents);
+int zbx_hc_check_proxy(zbx_uint64_t proxyid);
+
#endif
diff --git a/include/proxy.h b/include/proxy.h
index 2d045c2aa75..246e47c6f0c 100644
--- a/include/proxy.h
+++ b/include/proxy.h
@@ -33,6 +33,10 @@
#define ZBX_PROXY_DATA_DONE 0
#define ZBX_PROXY_DATA_MORE 1
+#define ZBX_PROXY_UPLOAD_UNDEFINED 0
+#define ZBX_PROXY_UPLOAD_DISABLED 1
+#define ZBX_PROXY_UPLOAD_ENABLED 2
+
int get_active_proxy_from_request(struct zbx_json_parse *jp, DC_PROXY *proxy, char **error);
int zbx_proxy_check_permissions(const DC_PROXY *proxy, const zbx_socket_t *sock, char **error);
int check_access_passive_proxy(zbx_socket_t *sock, int send_response, const char *req);
diff --git a/include/zbxalgo.h b/include/zbxalgo.h
index 4e016a9171c..a3ac1de008c 100644
--- a/include/zbxalgo.h
+++ b/include/zbxalgo.h
@@ -413,6 +413,49 @@ void zbx_queue_ptr_push(zbx_queue_ptr_t *queue, void *value);
void *zbx_queue_ptr_pop(zbx_queue_ptr_t *queue);
void zbx_queue_ptr_remove_value(zbx_queue_ptr_t *queue, const void *value);
+/* list item data */
+typedef struct list_item
+{
+ struct list_item *next;
+ void *data;
+}
+zbx_list_item_t;
+
+/* list data */
+typedef struct
+{
+ zbx_list_item_t *head;
+ zbx_list_item_t *tail;
+ zbx_mem_malloc_func_t mem_malloc_func;
+ zbx_mem_realloc_func_t mem_realloc_func;
+ zbx_mem_free_func_t mem_free_func;
+}
+zbx_list_t;
+
+/* queue item data */
+typedef struct
+{
+ zbx_list_t *list;
+ zbx_list_item_t *current;
+ zbx_list_item_t *next;
+}
+zbx_list_iterator_t;
+
+void zbx_list_create(zbx_list_t *queue);
+void zbx_list_create_ext(zbx_list_t *queue, zbx_mem_malloc_func_t mem_malloc_func, zbx_mem_free_func_t mem_free_func);
+void zbx_list_destroy(zbx_list_t *list);
+void zbx_list_append(zbx_list_t *list, void *value, zbx_list_item_t **inserted);
+void zbx_list_insert_after(zbx_list_t *list, zbx_list_item_t *after, void *value, zbx_list_item_t **inserted);
+void zbx_list_prepend(zbx_list_t *list, void *value, zbx_list_item_t **inserted);
+int zbx_list_pop(zbx_list_t *list, void **value);
+int zbx_list_peek(const zbx_list_t *list, void **value);
+void zbx_list_iterator_init(zbx_list_t *list, zbx_list_iterator_t *iterator);
+int zbx_list_iterator_next(zbx_list_iterator_t *iterator);
+int zbx_list_iterator_peek(const zbx_list_iterator_t *iterator, void **value);
+void zbx_list_iterator_clear(zbx_list_iterator_t *iterator);
+int zbx_list_iterator_equal(const zbx_list_iterator_t *iterator1, const zbx_list_iterator_t *iterator2);
+int zbx_list_iterator_isset(const zbx_list_iterator_t *iterator);
+void zbx_list_iterator_update(zbx_list_iterator_t *iterator);
#endif
diff --git a/include/zbxjson.h b/include/zbxjson.h
index 9e4284390cb..cb570c47eed 100644
--- a/include/zbxjson.h
+++ b/include/zbxjson.h
@@ -166,6 +166,7 @@
#define ZBX_PROTO_TAG_EXPRESSIONS "expressions"
#define ZBX_PROTO_TAG_EXPRESSION "expression"
#define ZBX_PROTO_TAG_CLIENTIP "clientip"
+#define ZBX_PROTO_TAG_PROXY_UPLOAD "upload"
#define ZBX_PROTO_VALUE_FAILED "failed"
#define ZBX_PROTO_VALUE_SUCCESS "success"
@@ -198,6 +199,9 @@
#define ZBX_PROTO_VALUE_PREPROCESSING_TEST "preprocessing.test"
#define ZBX_PROTO_VALUE_EXPRESSIONS_EVALUATE "expressions.evaluate"
+#define ZBX_PROTO_VALUE_PROXY_UPLOAD_ENABLED "enabled"
+#define ZBX_PROTO_VALUE_PROXY_UPLOAD_DISABLED "disabled"
+
typedef enum
{
ZBX_JSON_TYPE_UNKNOWN = 0,
diff --git a/src/libs/zbxalgo/Makefile.am b/src/libs/zbxalgo/Makefile.am
index 17c668e3f8d..05b624ef494 100644
--- a/src/libs/zbxalgo/Makefile.am
+++ b/src/libs/zbxalgo/Makefile.am
@@ -16,6 +16,7 @@ libzbxalgo_a_SOURCES = \
$(EVALUATE_C) \
hashmap.c \
hashset.c \
+ linked_list.c \
int128.c \
prediction.c \
queue.c \
diff --git a/src/zabbix_server/preprocessor/linked_list.c b/src/libs/zbxalgo/linked_list.c
index 494d70d0e1d..2b0c679d4ff 100644
--- a/src/zabbix_server/preprocessor/linked_list.c
+++ b/src/libs/zbxalgo/linked_list.c
@@ -18,8 +18,27 @@
**/
#include "common.h"
-#include "linked_list.h"
#include "log.h"
+#include "zbxalgo.h"
+
+/******************************************************************************
+ * *
+ * Function: zbx_list_create_ext *
+ * *
+ * Purpose: create singly linked list (with custom memory functions) *
+ * *
+ * Parameters: queue - [IN] the list *
+ * mem_malloc_func - [IN] callback for malloc *
+ * mem_free_func - [IN] callback for free *
+ * *
+ ******************************************************************************/
+void zbx_list_create_ext(zbx_list_t *queue, zbx_mem_malloc_func_t mem_malloc_func, zbx_mem_free_func_t mem_free_func)
+{
+ memset(queue, 0, sizeof(*queue));
+
+ queue->mem_malloc_func = mem_malloc_func;
+ queue->mem_free_func = mem_free_func;
+}
/******************************************************************************
* *
@@ -32,7 +51,7 @@
******************************************************************************/
void zbx_list_create(zbx_list_t *queue)
{
- memset(queue, 0, sizeof(*queue));
+ zbx_list_create_ext(queue, ZBX_DEFAULT_MEM_MALLOC_FUNC, ZBX_DEFAULT_MEM_FREE_FUNC);
}
/******************************************************************************
@@ -67,7 +86,7 @@ static void list_create_item(zbx_list_t *list, void *value, zbx_list_item_t **cr
ZBX_UNUSED(list);
- item = (zbx_list_item_t *)zbx_malloc(NULL, sizeof(zbx_list_item_t));
+ item = (zbx_list_item_t *)list->mem_malloc_func(NULL, sizeof(zbx_list_item_t));
item->next = NULL;
item->data = value;
@@ -102,7 +121,9 @@ void zbx_list_insert_after(zbx_list_t *list, zbx_list_item_t *after, void *value
after->next = item;
}
else
+ {
list->head = item;
+ }
if (after == list->tail)
list->tail = item;
@@ -179,7 +200,7 @@ int zbx_list_pop(zbx_list_t *list, void **value)
*value = head->data;
list->head = list->head->next;
- zbx_free(head);
+ list->mem_free_func(head);
if (NULL == list->head)
list->tail = NULL;
diff --git a/src/libs/zbxdbcache/dbcache.c b/src/libs/zbxdbcache/dbcache.c
index ebb76793cd3..d61ad56e9db 100644
--- a/src/libs/zbxdbcache/dbcache.c
+++ b/src/libs/zbxdbcache/dbcache.c
@@ -39,6 +39,7 @@
#include "daemon.h"
#include "zbxavailability.h"
#include "zbxtrends.h"
+#include "zbxalgo.h"
static zbx_mem_info_t *hc_index_mem = NULL;
static zbx_mem_info_t *hc_mem = NULL;
@@ -86,6 +87,9 @@ extern int CONFIG_DOUBLE_PRECISION;
#define ZBX_DC_FLAGS_NOT_FOR_MODULES (ZBX_DC_FLAGS_NOT_FOR_HISTORY | ZBX_DC_FLAG_LLD)
#define ZBX_DC_FLAGS_NOT_FOR_EXPORT (ZBX_DC_FLAG_NOVALUE | ZBX_DC_FLAG_UNDEF)
+#define ZBX_HC_PROXYQUEUE_STATE_NORMAL 0
+#define ZBX_HC_PROXYQUEUE_STATE_WAIT 1
+
typedef struct
{
char table_name[ZBX_TABLENAME_LEN_MAX];
@@ -103,6 +107,14 @@ static ZBX_DC_IDS *ids = NULL;
typedef struct
{
+ zbx_list_t list;
+ zbx_hashset_t index;
+ int state;
+}
+zbx_hc_proxyqueue_t;
+
+typedef struct
+{
zbx_hashset_t trends;
ZBX_DC_STATS stats;
@@ -116,6 +128,9 @@ typedef struct
int history_progress_ts;
unsigned char db_trigger_queue_lock;
+
+ zbx_hc_proxyqueue_t proxyqueue;
+ int active_proxy_status;
}
ZBX_DC_CACHE;
@@ -4424,9 +4439,21 @@ int init_database_cache(char **error)
if (0 != (program_type & ZBX_PROGRAM_TYPE_SERVER))
{
+ zbx_hashset_create_ext(&(cache->proxyqueue.index), ZBX_HC_SYNC_MAX,
+ ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC, NULL,
+ __hc_index_mem_malloc_func, __hc_index_mem_realloc_func, __hc_index_mem_free_func);
+
+ zbx_list_create_ext(&(cache->proxyqueue.list), __hc_index_mem_malloc_func, __hc_index_mem_free_func);
+
+ cache->proxyqueue.state = ZBX_HC_PROXYQUEUE_STATE_NORMAL;
+
if (SUCCEED != (ret = init_trend_cache(error)))
goto out;
}
+ else if (0 != (program_type & ZBX_PROGRAM_TYPE_PROXY_ACTIVE))
+ {
+ cache->active_proxy_status = 0;
+ }
cache->history_num_total = 0;
cache->history_progress_ts = 0;
@@ -4435,6 +4462,7 @@ int init_database_cache(char **error)
if (NULL == sql)
sql = (char *)zbx_malloc(sql, sql_alloc);
+
out:
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
@@ -4681,3 +4709,175 @@ void zbx_db_trigger_queue_unlock(void)
cache->db_trigger_queue_lock = 0;
}
+
+/******************************************************************************
+ * *
+ * Function: zbx_hc_proxyqueue_peek *
+ * *
+ * Purpose: return first proxy in a queue, function assumes that a queue is *
+ * not empty *
+ * *
+ * Return value: proxyid at the top a queue *
+ * *
+ ******************************************************************************/
+static zbx_uint64_t zbx_hc_proxyqueue_peek()
+{
+ zbx_uint64_t *p_val;
+
+ if (NULL == cache->proxyqueue.list.head)
+ return 0;
+
+ p_val = (zbx_uint64_t *)(cache->proxyqueue.list.head->data);
+
+ return *p_val;
+}
+
+/******************************************************************************
+ * *
+ * Function: zbx_hc_proxyqueue_enqueue *
+ * *
+ * Purpose: add new proxyid to a queue *
+ * *
+ * Parameters: proxyid - [IN] the proxy id *
+ * *
+ ******************************************************************************/
+static void zbx_hc_proxyqueue_enqueue(zbx_uint64_t proxyid)
+{
+ if (NULL == zbx_hashset_search(&cache->proxyqueue.index, &proxyid))
+ {
+ zbx_uint64_t *ptr;
+
+ ptr = zbx_hashset_insert(&cache->proxyqueue.index, &proxyid, sizeof(proxyid));
+ *ptr = proxyid;
+
+ zbx_list_append(&cache->proxyqueue.list, ptr, NULL);
+ }
+}
+
+/******************************************************************************
+ * *
+ * Function: zbx_hc_proxyqueue_dequeue *
+ * *
+ * Purpose: try to dequeue proxyid from a proxy queue *
+ * *
+ * Parameters: chk_proxyid - [IN] the proxyid *
+ * *
+ * Return value: SUCCEED - retrieval successful *
+ * FAIL - otherwise *
+ * *
+ ******************************************************************************/
+static int zbx_hc_proxyqueue_dequeue(zbx_uint64_t proxyid)
+{
+ zbx_uint64_t top_val;
+ zbx_uint64_t *rem_val = 0;
+
+ top_val = zbx_hc_proxyqueue_peek();
+
+ if (proxyid != top_val)
+ return FAIL;
+
+ if (FAIL == zbx_list_pop(&cache->proxyqueue.list, (void**)&rem_val))
+ return FAIL;
+
+ if (NULL != zbx_hashset_search(&cache->proxyqueue.index, rem_val))
+ zbx_hashset_remove(&cache->proxyqueue.index, rem_val);
+
+ return SUCCEED;
+}
+
+/******************************************************************************
+ * *
+ * Function: zbx_hc_proxyqueue_clear *
+ * *
+ * Purpose: remove all proxies from proxy priority queue *
+ * *
+ ******************************************************************************/
+static void zbx_hc_proxyqueue_clear(void)
+{
+ zbx_list_item_t *item = cache->proxyqueue.list.head;
+ zbx_list_item_t *nextitem = 0;
+
+ zbx_hashset_clear(&cache->proxyqueue.index);
+
+ while (NULL != item)
+ {
+ cache->proxyqueue.list.mem_free_func(item->data);
+ nextitem = item->next;
+ cache->proxyqueue.list.mem_free_func(item);
+ item = nextitem;
+ }
+}
+
+/******************************************************************************
+ * *
+ * Function: zbx_hc_check_proxy *
+ * *
+ * Purpose: check status of a history cache usage, enqueue/dequeue proxy *
+ * from priority list and accordingly enable or disable wait mode *
+ * *
+ * Parameters: proxyid - [IN] the proxyid *
+ * *
+ * Return value: SUCCEED - proxy can be processed now *
+ * FAIL - proxy cannot be processed now, it got enqueued *
+ * *
+ ******************************************************************************/
+int zbx_hc_check_proxy(zbx_uint64_t proxyid)
+{
+ double hc_pused;
+ int ret;
+
+ zabbix_log(LOG_LEVEL_DEBUG, "In %s() proxyid:"ZBX_FS_UI64, __func__, proxyid);
+
+ LOCK_CACHE;
+
+ hc_pused = 100 * (double)(hc_mem->total_size - hc_mem->free_size) / hc_mem->total_size;
+
+ if (20 >= hc_pused)
+ {
+ cache->proxyqueue.state = ZBX_HC_PROXYQUEUE_STATE_NORMAL;
+
+ zbx_hc_proxyqueue_clear();
+
+ ret = SUCCEED;
+ goto out;
+ }
+
+ if (ZBX_HC_PROXYQUEUE_STATE_WAIT == cache->proxyqueue.state)
+ {
+ zbx_hc_proxyqueue_enqueue(proxyid);
+
+ if (60 < hc_pused)
+ {
+ ret = FAIL;
+ goto out;
+ }
+
+ cache->proxyqueue.state = ZBX_HC_PROXYQUEUE_STATE_NORMAL;
+ }
+ else
+ {
+ if (80 <= hc_pused)
+ {
+ cache->proxyqueue.state = ZBX_HC_PROXYQUEUE_STATE_WAIT;
+ zbx_hc_proxyqueue_enqueue(proxyid);
+
+ ret = FAIL;
+ goto out;
+ }
+ }
+
+ if (0 == zbx_hc_proxyqueue_peek())
+ {
+ ret = SUCCEED;
+ goto out;
+ }
+
+ ret = zbx_hc_proxyqueue_dequeue(proxyid);
+
+out:
+ UNLOCK_CACHE;
+
+ zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __func__, zbx_result_string(ret));
+
+ return ret;
+}
diff --git a/src/libs/zbxdbhigh/proxy.c b/src/libs/zbxdbhigh/proxy.c
index 4663dfe8391..c55a29d8cfd 100644
--- a/src/libs/zbxdbhigh/proxy.c
+++ b/src/libs/zbxdbhigh/proxy.c
@@ -4682,7 +4682,7 @@ int process_proxy_data(const DC_PROXY *proxy, struct zbx_json_parse *jp, zbx_tim
unsigned char proxy_status, int *more, char **error)
{
struct zbx_json_parse jp_data;
- int ret = SUCCEED, flags_old;
+ int ret = SUCCEED, proxy_check = SUCCEED, flags_old;
char *error_step = NULL, value[MAX_STRING_LEN];
size_t error_alloc = 0, error_offset = 0;
zbx_proxy_diff_t proxy_diff;
diff --git a/src/zabbix_proxy/datasender/datasender.c b/src/zabbix_proxy/datasender/datasender.c
index ded98a00639..283ec75516d 100644
--- a/src/zabbix_proxy/datasender/datasender.c
+++ b/src/zabbix_proxy/datasender/datasender.c
@@ -36,6 +36,7 @@
extern unsigned char process_type, program_type;
extern int server_num, process_num;
+
#define ZBX_DATASENDER_AVAILABILITY 0x0001
#define ZBX_DATASENDER_HISTORY 0x0002
#define ZBX_DATASENDER_DISCOVERY 0x0004
@@ -50,13 +51,42 @@ extern int server_num, process_num;
/******************************************************************************
* *
+ * Function: get_hist_upload_state *
+ * *
+ * Purpose: Get current history upload state (disabled/enabled) *
+ * *
+ * Parameters: buffer - [IN] the contents of a packet (JSON) *
+ * *
+ * Return value: SUCCEED - processed successfully *
+ * FAIL - an error occurred *
+ * *
+ ******************************************************************************/
+static void get_hist_upload_state(const char *buffer, int *state)
+{
+ struct zbx_json_parse jp;
+ char value[MAX_STRING_LEN];
+
+ if ('\0' == *buffer || SUCCEED != zbx_json_open(buffer, &jp))
+ return;
+
+ if (SUCCEED == zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_PROXY_UPLOAD, value, sizeof(value), NULL))
+ {
+ if (0 != strcmp(value, ZBX_PROTO_VALUE_PROXY_UPLOAD_ENABLED))
+ *state = ZBX_PROXY_UPLOAD_ENABLED;
+ else if (0 != strcmp(value, ZBX_PROTO_VALUE_PROXY_UPLOAD_DISABLED))
+ *state = ZBX_PROXY_UPLOAD_DISABLED;
+ }
+}
+
+/******************************************************************************
+ * *
* Function: proxy_data_sender *
* *
* Purpose: collects host availability, history, discovery, autoregistration *
* data and sends 'proxy data' request *
* *
******************************************************************************/
-static int proxy_data_sender(int *more, int now)
+static int proxy_data_sender(int *more, int now, int *hist_upload_state)
{
static int data_timestamp = 0, task_timestamp = 0, upload_state = SUCCEED;
@@ -70,7 +100,7 @@ static int proxy_data_sender(int *more, int now)
char *error = NULL;
zbx_vector_ptr_t tasks;
- zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
+ zabbix_log(3, "In %s()", __func__);
*more = ZBX_PROXY_DATA_DONE;
zbx_json_init(&j, 16 * ZBX_KIBIBYTE);
@@ -84,22 +114,25 @@ static int proxy_data_sender(int *more, int now)
if (SUCCEED == get_interface_availability_data(&j, &availability_ts))
flags |= ZBX_DATASENDER_AVAILABILITY;
- history_records = proxy_get_hist_data(&j, &history_lastid, &more_history);
- if (0 != history_lastid)
- flags |= ZBX_DATASENDER_HISTORY;
+ if (ZBX_PROXY_UPLOAD_DISABLED != *hist_upload_state)
+ {
+ history_records = proxy_get_hist_data(&j, &history_lastid, &more_history);
+ if (0 != history_lastid)
+ flags |= ZBX_DATASENDER_HISTORY;
- discovery_records = proxy_get_dhis_data(&j, &discovery_lastid, &more_discovery);
- if (0 != discovery_records)
- flags |= ZBX_DATASENDER_DISCOVERY;
+ discovery_records = proxy_get_dhis_data(&j, &discovery_lastid, &more_discovery);
+ if (0 != discovery_records)
+ flags |= ZBX_DATASENDER_DISCOVERY;
- areg_records = proxy_get_areg_data(&j, &areg_lastid, &more_areg);
- if (0 != areg_records)
- flags |= ZBX_DATASENDER_AUTOREGISTRATION;
+ areg_records = proxy_get_areg_data(&j, &areg_lastid, &more_areg);
+ if (0 != areg_records)
+ flags |= ZBX_DATASENDER_AUTOREGISTRATION;
- if (ZBX_PROXY_DATA_MORE != more_history && ZBX_PROXY_DATA_MORE != more_discovery &&
- ZBX_PROXY_DATA_MORE != more_areg)
- {
- data_timestamp = now;
+ if (ZBX_PROXY_DATA_MORE != more_history && ZBX_PROXY_DATA_MORE != more_discovery &&
+ ZBX_PROXY_DATA_MORE != more_areg)
+ {
+ data_timestamp = now;
+ }
}
}
@@ -145,7 +178,10 @@ static int proxy_data_sender(int *more, int now)
if (0 != (flags & ZBX_DATASENDER_HISTORY) && 0 != (proxy_delay = proxy_get_delay(history_lastid)))
zbx_json_adduint64(&j, ZBX_PROTO_TAG_PROXY_DELAY, proxy_delay);
- if (SUCCEED != (upload_state = put_data_to_server(&sock, &j, &error)))
+ upload_state = put_data_to_server(&sock, &j, &error);
+ get_hist_upload_state(sock.buffer, hist_upload_state);
+
+ if (SUCCEED != upload_state)
{
*more = ZBX_PROXY_DATA_DONE;
zabbix_log(LOG_LEVEL_WARNING, "cannot send proxy data to server at \"%s\": %s",
@@ -215,7 +251,7 @@ clean:
******************************************************************************/
ZBX_THREAD_ENTRY(datasender_thread, args)
{
- int records = 0, more;
+ int records = 0, hist_upload_state = ZBX_PROXY_UPLOAD_ENABLED, more;
double time_start, time_diff = 0.0, time_now;
process_type = ((zbx_thread_args_t *)args)->process_type;
@@ -247,7 +283,7 @@ ZBX_THREAD_ENTRY(datasender_thread, args)
do
{
- records += proxy_data_sender(&more, (int)time_now);
+ records += proxy_data_sender(&more, (int)time_now, &hist_upload_state);
time_now = zbx_time();
time_diff = time_now - time_start;
diff --git a/src/zabbix_proxy/heart/heart.c b/src/zabbix_proxy/heart/heart.c
index 64d9f2ad166..caeb6fedd74 100644
--- a/src/zabbix_proxy/heart/heart.c
+++ b/src/zabbix_proxy/heart/heart.c
@@ -52,7 +52,7 @@ static int send_heartbeat(void)
if (FAIL == connect_to_server(&sock, CONFIG_HEARTBEAT_FREQUENCY, 0)) /* do not retry */
return FAIL;
- if (SUCCEED != put_data_to_server(&sock, &j, &error))
+ if (SUCCEED != put_data_to_server(&sock, &j, &error, 0))
{
zabbix_log(LOG_LEVEL_WARNING, "cannot send heartbeat message to server at \"%s\": %s",
sock.peer, error);
diff --git a/src/zabbix_proxy/servercomms.c b/src/zabbix_proxy/servercomms.c
index 63e919ce8c6..1ae9f70d0c0 100644
--- a/src/zabbix_proxy/servercomms.c
+++ b/src/zabbix_proxy/servercomms.c
@@ -23,10 +23,12 @@
#include "db.h"
#include "log.h"
#include "zbxjson.h"
+#include "dbcache.h"
#include "comms.h"
#include "servercomms.h"
#include "daemon.h"
+#include "proxy.h"
extern unsigned int configured_tls_connect_mode;
diff --git a/src/zabbix_server/preprocessor/Makefile.am b/src/zabbix_server/preprocessor/Makefile.am
index c01aca9c9d7..7c1381d4b0d 100644
--- a/src/zabbix_server/preprocessor/Makefile.am
+++ b/src/zabbix_server/preprocessor/Makefile.am
@@ -5,8 +5,6 @@ noinst_LIBRARIES = libpreprocessor.a
libpreprocessor_a_SOURCES = \
item_preproc.c \
item_preproc.h \
- linked_list.c \
- linked_list.h \
preproc_history.c \
preproc_history.h \
preproc_manager.c \
diff --git a/src/zabbix_server/preprocessor/linked_list.h b/src/zabbix_server/preprocessor/linked_list.h
deleted file mode 100644
index b27422f7db8..00000000000
--- a/src/zabbix_server/preprocessor/linked_list.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-** Zabbix
-** Copyright (C) 2001-2021 Zabbix SIA
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-**/
-
-#ifndef ZABBIX_LIST_H
-#define ZABBIX_LIST_H
-
-#include "common.h"
-
-/* list item data */
-typedef struct list_item
-{
- struct list_item *next;
- void *data;
-}
-zbx_list_item_t;
-
-/* list data */
-typedef struct
-{
- zbx_list_item_t *head;
- zbx_list_item_t *tail;
-}
-zbx_list_t;
-
-/* queue item data */
-typedef struct
-{
- zbx_list_t *list;
- zbx_list_item_t *current;
- zbx_list_item_t *next;
-}
-zbx_list_iterator_t;
-
-void zbx_list_create(zbx_list_t *queue);
-void zbx_list_destroy(zbx_list_t *list);
-void zbx_list_append(zbx_list_t *list, void *value, zbx_list_item_t **inserted);
-void zbx_list_insert_after(zbx_list_t *list, zbx_list_item_t *after, void *value, zbx_list_item_t **inserted);
-void zbx_list_prepend(zbx_list_t *list, void *value, zbx_list_item_t **inserted);
-int zbx_list_pop(zbx_list_t *list, void **value);
-int zbx_list_peek(const zbx_list_t *list, void **value);
-void zbx_list_iterator_init(zbx_list_t *list, zbx_list_iterator_t *iterator);
-int zbx_list_iterator_next(zbx_list_iterator_t *iterator);
-int zbx_list_iterator_peek(const zbx_list_iterator_t *iterator, void **value);
-void zbx_list_iterator_clear(zbx_list_iterator_t *iterator);
-int zbx_list_iterator_equal(const zbx_list_iterator_t *iterator1, const zbx_list_iterator_t *iterator2);
-int zbx_list_iterator_isset(const zbx_list_iterator_t *iterator);
-void zbx_list_iterator_update(zbx_list_iterator_t *iterator);
-
-#endif
diff --git a/src/zabbix_server/preprocessor/preproc_manager.c b/src/zabbix_server/preprocessor/preproc_manager.c
index fe5952b7305..26454d6aae7 100644
--- a/src/zabbix_server/preprocessor/preproc_manager.c
+++ b/src/zabbix_server/preprocessor/preproc_manager.c
@@ -31,7 +31,7 @@
#include "preprocessing.h"
#include "preproc_manager.h"
-#include "linked_list.h"
+#include "zbxalgo.h"
#include "preproc_history.h"
extern unsigned char process_type, program_type;
diff --git a/src/zabbix_server/proxypoller/proxypoller.c b/src/zabbix_server/proxypoller/proxypoller.c
index 3f268bd69c4..c483f7b957a 100644
--- a/src/zabbix_server/proxypoller/proxypoller.c
+++ b/src/zabbix_server/proxypoller/proxypoller.c
@@ -194,7 +194,7 @@ static int get_data_from_proxy(DC_PROXY *proxy, const char *request, char **data
}
else
{
- ret = zbx_send_proxy_data_response(proxy, &s, NULL);
+ ret = zbx_send_proxy_data_response(proxy, &s, NULL, 0);
if (SUCCEED == ret)
*data = zbx_strdup(*data, s.buffer);
@@ -510,8 +510,12 @@ static int process_proxy(void)
if (proxy.proxy_data_nextcheck <= now)
{
+
int more;
+ if (FAIL == zbx_hc_check_proxy(proxy.hostid))
+ goto error;
+
do
{
if (SUCCEED != (ret = proxy_get_data(&proxy, &more)))
diff --git a/src/zabbix_server/trapper/proxydata.c b/src/zabbix_server/trapper/proxydata.c
index 4e089d0f81a..cb55508f5c4 100644
--- a/src/zabbix_server/trapper/proxydata.c
+++ b/src/zabbix_server/trapper/proxydata.c
@@ -34,7 +34,7 @@ static zbx_mutex_t proxy_lock = ZBX_MUTEX_NULL;
#define LOCK_PROXY_HISTORY if (0 != (program_type & ZBX_PROGRAM_TYPE_PROXY_PASSIVE)) zbx_mutex_lock(proxy_lock)
#define UNLOCK_PROXY_HISTORY if (0 != (program_type & ZBX_PROGRAM_TYPE_PROXY_PASSIVE)) zbx_mutex_unlock(proxy_lock)
-int zbx_send_proxy_data_response(const DC_PROXY *proxy, zbx_socket_t *sock, const char *info)
+int zbx_send_proxy_data_response(const DC_PROXY *proxy, zbx_socket_t *sock, const char *info, int upload_status)
{
struct zbx_json json;
zbx_vector_ptr_t tasks;
@@ -46,7 +46,18 @@ int zbx_send_proxy_data_response(const DC_PROXY *proxy, zbx_socket_t *sock, cons
zbx_json_init(&json, ZBX_JSON_STAT_BUF_LEN);
- zbx_json_addstring(&json, ZBX_PROTO_TAG_RESPONSE, ZBX_PROTO_VALUE_SUCCESS, ZBX_JSON_TYPE_STRING);
+ if (ZBX_PROXY_UPLOAD_DISABLED == upload_status)
+ {
+ zbx_json_addstring(&json, ZBX_PROTO_TAG_RESPONSE, ZBX_PROTO_VALUE_FAILED, ZBX_JSON_TYPE_STRING);
+ zbx_json_addstring(&json, ZBX_PROTO_TAG_PROXY_UPLOAD, ZBX_PROTO_VALUE_PROXY_UPLOAD_DISABLED,
+ ZBX_JSON_TYPE_STRING);
+ }
+ else
+ {
+ zbx_json_addstring(&json, ZBX_PROTO_TAG_RESPONSE, ZBX_PROTO_VALUE_SUCCESS, ZBX_JSON_TYPE_STRING);
+ zbx_json_addstring(&json, ZBX_PROTO_TAG_PROXY_UPLOAD, ZBX_PROTO_VALUE_PROXY_UPLOAD_ENABLED,
+ ZBX_JSON_TYPE_STRING);
+ }
if (NULL != info && '\0' != *info)
zbx_json_addstring(&json, ZBX_PROTO_TAG_INFO, info, ZBX_JSON_TYPE_STRING);
@@ -84,7 +95,7 @@ int zbx_send_proxy_data_response(const DC_PROXY *proxy, zbx_socket_t *sock, cons
******************************************************************************/
void zbx_recv_proxy_data(zbx_socket_t *sock, struct zbx_json_parse *jp, zbx_timespec_t *ts)
{
- int ret = FAIL, status, version;
+ int ret = FAIL, upload_status = 0, status, version;
char *error = NULL;
DC_PROXY proxy;
@@ -111,6 +122,14 @@ void zbx_recv_proxy_data(zbx_socket_t *sock, struct zbx_json_parse *jp, zbx_time
goto out;
}
+ if (FAIL == zbx_hc_check_proxy(proxy.hostid))
+ {
+ upload_status = ZBX_PROXY_UPLOAD_DISABLED;
+ goto send_response;
+ }
+ else
+ upload_status = ZBX_PROXY_UPLOAD_ENABLED;
+
if (SUCCEED != (ret = process_proxy_data(&proxy, jp, ts, HOST_STATUS_PROXY_ACTIVE, NULL, &error)))
{
zabbix_log(LOG_LEVEL_WARNING, "received invalid proxy data from proxy \"%s\" at \"%s\": %s",
@@ -119,6 +138,7 @@ void zbx_recv_proxy_data(zbx_socket_t *sock, struct zbx_json_parse *jp, zbx_time
goto out;
}
+send_response:
if (!ZBX_IS_RUNNING())
{
error = zbx_strdup(error, "Zabbix server shutdown in progress");
@@ -128,7 +148,7 @@ void zbx_recv_proxy_data(zbx_socket_t *sock, struct zbx_json_parse *jp, zbx_time
goto out;
}
else
- zbx_send_proxy_data_response(&proxy, sock, error);
+ zbx_send_proxy_data_response(&proxy, sock, error, upload_status);
out:
if (SUCCEED == status) /* moved the unpredictable long operation to the end */
diff --git a/src/zabbix_server/trapper/proxydata.h b/src/zabbix_server/trapper/proxydata.h
index a6ea5bc80b0..33ba5f772c8 100644
--- a/src/zabbix_server/trapper/proxydata.h
+++ b/src/zabbix_server/trapper/proxydata.h
@@ -30,7 +30,7 @@ void zbx_recv_proxy_data(zbx_socket_t *sock, struct zbx_json_parse *jp, zbx_time
void zbx_send_proxy_data(zbx_socket_t *sock, zbx_timespec_t *ts);
void zbx_send_task_data(zbx_socket_t *sock, zbx_timespec_t *ts);
-int zbx_send_proxy_data_response(const DC_PROXY *proxy, zbx_socket_t *sock, const char *info);
+int zbx_send_proxy_data_response(const DC_PROXY *proxy, zbx_socket_t *sock, const char *info, int upload_status);
int init_proxy_history_lock(char **error);
void free_proxy_history_lock(void);