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:
authorAndris Zeila <andris.zeila@zabbix.com>2020-08-28 10:53:42 +0300
committerAndris Zeila <andris.zeila@zabbix.com>2020-08-28 11:11:02 +0300
commit3b6e07d1ec2ebb46ebe5294da2a71f362c6a5c1c (patch)
tree7f1b166d21c6a822b4b5c7e0deb6c15c37ee6636 /include
parent7fcb4908ac42281568e4e85f3adefe4a9b6ecd5e (diff)
.......PS. [ZBXNEXT-6167] added diaginfo runtime command to log internal diagnostic information
* commit 'b9d85eedee7431f9204ac3a00eea559b81486ae7': (45 commits) .D........ [ZBXNEXT-6167] updated server and proxy man pages .D........ [ZBXNEXT-6167] added changelog entry .......PS. [ZBXNEXT-6167] don't allow runtime command on Zabbix agentd .......PS. [ZBXNEXT-6167] style fix .......PS. [ZBXNEXT-6167] style fix .......PS. [ZBXNEXT-6167] simplified main process waiting for dead children .......PS. [ZBXNEXT-6167] added missing include file, more defines .......PS. [ZBXNEXT-6167] added diaginfo remote command suppor to proxy .......PS. [ZBXNEXT-6167] added comments, minor refactoring ........S. [ZBXNEXT-6167] added remote command support for diaginfo printing on server .......PS. [ZBXNEXT-6167] small style fixes ........S. [ZBXNEXT-6167] fixed value cache diagnostics retrieval with disabled value cache .......PS. [ZBXNEXT-6167] fixed vector not being destroyed on failure .......PS. [ZBXNEXT-6167] fixed vector not being destroyed on failure .......PS. [ZBXNEXT-6167] fixed warning .......PS. [ZBXNEXT-6167] fixed memory leak ........S. [ZBXNEXT-6167] fixed memory leak ........S. [ZBXNEXT-6167] fixed wrong type used when serializing lld top result ........S. [ZBXNEXT-6167] small style fix ........S. [ZBXNEXT-6167] small style fixes ... (cherry picked from commit dabac74c51a9d19db24c871f7f8ec247ac540eeb)
Diffstat (limited to 'include')
-rw-r--r--include/common.h2
-rw-r--r--include/dbcache.h7
-rw-r--r--include/memalloc.h19
-rw-r--r--include/preproc.h12
-rw-r--r--include/zbxalert.h40
-rw-r--r--include/zbxdiag.h48
-rw-r--r--include/zbxjson.h3
-rw-r--r--include/zbxlld.h5
-rw-r--r--include/zbxserver.h2
-rw-r--r--include/zbxtasks.h3
10 files changed, 139 insertions, 2 deletions
diff --git a/include/common.h b/include/common.h
index ae86cfb27b2..aa447981927 100644
--- a/include/common.h
+++ b/include/common.h
@@ -439,6 +439,7 @@ zbx_graph_yaxis_types_t;
#define ZBX_LOG_LEVEL_INCREASE "log_level_increase"
#define ZBX_LOG_LEVEL_DECREASE "log_level_decrease"
#define ZBX_SNMP_CACHE_RELOAD "snmp_cache_reload"
+#define ZBX_DIAGINFO "diaginfo"
/* value for not supported items */
#define ZBX_NOTSUPPORTED "ZBX_NOTSUPPORTED"
@@ -930,6 +931,7 @@ zbx_task_t;
#define ZBX_RTC_HOUSEKEEPER_EXECUTE 3
#define ZBX_RTC_CONFIG_CACHE_RELOAD 8
#define ZBX_RTC_SNMP_CACHE_RELOAD 9
+#define ZBX_RTC_DIAGINFO 10
typedef enum
{
diff --git a/include/dbcache.h b/include/dbcache.h
index 88c993b1abe..c26038661f1 100644
--- a/include/dbcache.h
+++ b/include/dbcache.h
@@ -25,6 +25,7 @@
#include "sysinfo.h"
#include "zbxalgo.h"
#include "zbxjson.h"
+#include "memalloc.h"
#define ZBX_SYNC_DONE 0
#define ZBX_SYNC_MORE 1
@@ -849,6 +850,7 @@ typedef struct
{
zbx_uint64_t itemid;
unsigned char status;
+ int values_num;
zbx_hc_data_t *tail;
zbx_hc_data_t *head;
@@ -985,4 +987,9 @@ const char *zbx_dc_get_instanceid(void);
char *zbx_dc_expand_user_macros(const char *text, zbx_uint64_t hostid);
char *zbx_dc_expand_user_macros_in_func_params(const char *params, zbx_uint64_t hostid);
+/* diagnostic data */
+void zbx_hc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num);
+void zbx_hc_get_mem_stats(zbx_mem_stats_t *data, zbx_mem_stats_t *index);
+void zbx_hc_get_items(zbx_vector_uint64_pair_t *top);
+
#endif
diff --git a/include/memalloc.h b/include/memalloc.h
index c0f11e6238c..8f67d850977 100644
--- a/include/memalloc.h
+++ b/include/memalloc.h
@@ -23,6 +23,12 @@
#include "common.h"
#include "mutexs.h"
+#define MEM_MIN_ALLOC 24 /* should be a multiple of 8 and at least (2 * ZBX_PTR_SIZE) */
+
+#define MEM_MIN_BUCKET_SIZE MEM_MIN_ALLOC
+#define MEM_MAX_BUCKET_SIZE 256 /* starting from this size all free chunks are put into the same bucket */
+#define MEM_BUCKET_COUNT ((MEM_MAX_BUCKET_SIZE - MEM_MIN_BUCKET_SIZE) / 8 + 1)
+
typedef struct
{
void **buckets;
@@ -44,6 +50,18 @@ typedef struct
}
zbx_mem_info_t;
+typedef struct
+{
+ zbx_uint64_t free_size;
+ zbx_uint64_t used_size;
+ zbx_uint64_t min_chunk_size;
+ zbx_uint64_t max_chunk_size;
+ unsigned int chunks_num[MEM_BUCKET_COUNT];
+ unsigned int free_chunks;
+ unsigned int used_chunks;
+}
+zbx_mem_stats_t;
+
int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr, const char *param, int allow_oom,
char **error);
@@ -64,6 +82,7 @@ void __zbx_mem_free(const char *file, int line, zbx_mem_info_t *info, void *ptr)
void zbx_mem_clear(zbx_mem_info_t *info);
+void zbx_mem_get_stats(const zbx_mem_info_t *info, zbx_mem_stats_t *stats);
void zbx_mem_dump_stats(int level, zbx_mem_info_t *info);
size_t zbx_mem_required_size(int chunks_num, const char *descr, const char *param);
diff --git a/include/preproc.h b/include/preproc.h
index 9a83845a811..36afc5cf6ba 100644
--- a/include/preproc.h
+++ b/include/preproc.h
@@ -33,6 +33,14 @@ typedef struct
}
zbx_preproc_result_t;
+typedef struct
+{
+ zbx_uint64_t itemid;
+ int values_num;
+ int steps_num;
+}
+zbx_preproc_item_stats_t;
+
/* the following functions are implemented differently for server and proxy */
void zbx_preprocess_item_value(zbx_uint64_t itemid, unsigned char item_value_type, unsigned char item_flags,
@@ -47,4 +55,8 @@ int zbx_preprocessor_test(unsigned char value_type, const char *value, const zbx
const zbx_vector_ptr_t *steps, zbx_vector_ptr_t *results, zbx_vector_ptr_t *history,
char **preproc_error, char **error);
+int zbx_preprocessor_get_diag_stats(int *values_num, int *values_preproc_num, char **error);
+
+
+int zbx_preprocessor_get_top_items(int limit, zbx_vector_ptr_t *items, char **error);
#endif /* ZABBIX_PREPROC_H */
diff --git a/include/zbxalert.h b/include/zbxalert.h
new file mode 100644
index 00000000000..67cfaa2ecc9
--- /dev/null
+++ b/include/zbxalert.h
@@ -0,0 +1,40 @@
+/*
+** Zabbix
+** Copyright (C) 2001-2020 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_ZBXALERT_H
+#define ZABBIX_ZBXALERT_H
+
+#include "common.h"
+
+typedef struct
+{
+ int source;
+ int object;
+ zbx_uint64_t objectid;
+ int alerts_num;
+}
+zbx_am_source_stats_t;
+
+int zbx_alerter_get_diag_stats(zbx_uint64_t *alerts_num, char **error);
+
+int zbx_alerter_get_top_mediatypes(int limit, zbx_vector_uint64_pair_t *mediatypes, char **error);
+
+int zbx_alerter_get_top_sources(int limit, zbx_vector_ptr_t *sources, char **error);
+
+#endif
diff --git a/include/zbxdiag.h b/include/zbxdiag.h
new file mode 100644
index 00000000000..3a77db8a626
--- /dev/null
+++ b/include/zbxdiag.h
@@ -0,0 +1,48 @@
+/*
+** Zabbix
+** Copyright (C) 2001-2020 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_ZBXDIAG_H
+#define ZABBIX_ZBXDIAG_H
+
+#include "common.h"
+#include "zbxjson.h"
+
+typedef enum
+{
+ ZBX_DIAGINFO_UNDEFINED = -1,
+ ZBX_DIAGINFO_ALL,
+ ZBX_DIAGINFO_HISTORYCACHE,
+ ZBX_DIAGINFO_VALUECACHE,
+ ZBX_DIAGINFO_PREPROCESSING,
+ ZBX_DIAGINFO_LLD,
+ ZBX_DIAGINFO_ALERTING
+}
+zbx_diaginfo_section_t;
+
+#define ZBX_DIAG_HISTORYCACHE "historycache"
+#define ZBX_DIAG_VALUECACHE "valuecache"
+#define ZBX_DIAG_PREPROCESSING "preprocessing"
+#define ZBX_DIAG_LLD "lld"
+#define ZBX_DIAG_ALERTING "alerting"
+
+int zbx_diag_get_info(const struct zbx_json_parse *jp, char **info);
+void zbx_diag_log_info(unsigned int flags);
+
+#endif
diff --git a/include/zbxjson.h b/include/zbxjson.h
index 499ff77bf5e..1edc6c42d1b 100644
--- a/include/zbxjson.h
+++ b/include/zbxjson.h
@@ -280,6 +280,9 @@ int zbx_json_count(const struct zbx_json_parse *jp);
const char *zbx_json_decodevalue(const char *p, char *string, size_t size, zbx_json_type_t *type);
const char *zbx_json_decodevalue_dyn(const char *p, char **string, size_t *string_alloc, zbx_json_type_t *type);
void zbx_json_escape(char **string);
+int zbx_json_open_path(const struct zbx_json_parse *jp, const char *path, struct zbx_json_parse *out);
+
+void zbx_json_log(const struct zbx_json_parse *jp, int loglevel);
/* jsonpath support */
diff --git a/include/zbxlld.h b/include/zbxlld.h
index d7016bfd730..639389ea92f 100644
--- a/include/zbxlld.h
+++ b/include/zbxlld.h
@@ -21,6 +21,7 @@
#define ZABBIX_LLD_H
#include "common.h"
+#include "zbxalgo.h"
void zbx_lld_process_value(zbx_uint64_t itemid, const char *value, const zbx_timespec_t *ts, unsigned char meta,
zbx_uint64_t lastlogsize, int mtime, const char *error);
@@ -29,4 +30,8 @@ void zbx_lld_process_agent_result(zbx_uint64_t itemid, AGENT_RESULT *result, zbx
int zbx_lld_get_queue_size(zbx_uint64_t *size, char **error);
+int zbx_lld_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num, char **error);
+
+int zbx_lld_get_top_items(int limit, zbx_vector_uint64_pair_t *items, char **error);
+
#endif /* ZABBIX_LLD_H */
diff --git a/include/zbxserver.h b/include/zbxserver.h
index ce167b490db..d6de7772675 100644
--- a/include/zbxserver.h
+++ b/include/zbxserver.h
@@ -54,8 +54,6 @@
#define STR_CONTAINS_MACROS(str) (NULL != strchr(str, '{'))
-char *dc_expand_user_macros_in_expression(const char *text, zbx_uint64_t *hostids, int hostids_num);
-
int get_N_functionid(const char *expression, int N_functionid, zbx_uint64_t *functionid, const char **end);
void get_functionids(zbx_vector_uint64_t *functionids, const char *expression);
diff --git a/include/zbxtasks.h b/include/zbxtasks.h
index d2b409d0752..565d0fd941e 100644
--- a/include/zbxtasks.h
+++ b/include/zbxtasks.h
@@ -47,6 +47,7 @@
/* task data type */
#define ZBX_TM_DATA_TYPE_TEST_ITEM 0
+#define ZBX_TM_DATA_TYPE_DIAGINFO 1
/* the time period after which finished (done/expired) tasks are removed */
#define ZBX_TM_CLEANUP_TASK_AGE SEC_PER_DAY
@@ -149,4 +150,6 @@ void zbx_tm_json_deserialize_tasks(const struct zbx_json_parse *jp, zbx_vector_p
/* separate implementation for proxy and server */
void zbx_tm_get_remote_tasks(zbx_vector_ptr_t *tasks, zbx_uint64_t proxy_hostid);
+int zbx_tm_get_diaginfo(const struct zbx_json_parse *jp, char **info);
+
#endif