diff options
author | Michael Veksler <Mihails.Vekslers@zabbix.com> | 2021-05-06 13:30:13 +0300 |
---|---|---|
committer | Michael Veksler <Mihails.Vekslers@zabbix.com> | 2021-05-06 13:30:13 +0300 |
commit | a188c49914f1482a4554dd87e5f9f987196cc684 (patch) | |
tree | b687b79dfec7105ebbbea787b2eae3e06075e296 /include | |
parent | 8575e2e8ef9920f1190e48e268897a6db582cd2f (diff) | |
parent | 761774601a6a56de0736e92a18e0dc6f8e3b92be (diff) |
........S. [ZBXNEXT-6465] update from branch 'master'
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 15 | ||||
-rw-r--r-- | include/db.h | 17 | ||||
-rw-r--r-- | include/preproc.h | 2 | ||||
-rw-r--r-- | include/version.h | 2 | ||||
-rw-r--r-- | include/zbxalert.h | 29 | ||||
-rw-r--r-- | include/zbxalgo.h | 1 | ||||
-rw-r--r-- | include/zbxipcservice.h | 3 | ||||
-rw-r--r-- | include/zbxjson.h | 11 | ||||
-rw-r--r-- | include/zbxlld.h | 4 | ||||
-rw-r--r-- | include/zbxmedia.h | 4 | ||||
-rw-r--r-- | include/zbxprometheus.h | 6 | ||||
-rw-r--r-- | include/zbxreport.h | 34 | ||||
-rw-r--r-- | include/zbxserialize.h | 10 | ||||
-rw-r--r-- | include/zbxserver.h | 1 | ||||
-rw-r--r-- | include/zbxtypes.h | 2 |
15 files changed, 121 insertions, 20 deletions
diff --git a/include/common.h b/include/common.h index 0ed86170393..10c16b69228 100644 --- a/include/common.h +++ b/include/common.h @@ -551,7 +551,9 @@ const char *get_program_type_string(unsigned char program_type); #define ZBX_PROCESS_TYPE_ALERTSYNCER 30 #define ZBX_PROCESS_TYPE_HISTORYPOLLER 31 #define ZBX_PROCESS_TYPE_AVAILMAN 32 -#define ZBX_PROCESS_TYPE_COUNT 33 /* number of process types */ +#define ZBX_PROCESS_TYPE_REPORTMANAGER 33 +#define ZBX_PROCESS_TYPE_REPORTWRITER 34 +#define ZBX_PROCESS_TYPE_COUNT 35 /* number of process types */ #define ZBX_PROCESS_TYPE_UNKNOWN 255 const char *get_process_type_string(unsigned char proc_type); int get_process_type_by_name(const char *proc_type_str); @@ -1664,7 +1666,6 @@ int zbx_validate_value_dbl(double value, int dbl_precision); void zbx_update_env(double time_now); int zbx_get_agent_item_nextcheck(zbx_uint64_t itemid, const char *delay, int now, int *nextcheck, char **error); - #define ZBX_DATA_SESSION_TOKEN_SIZE (MD5_DIGEST_SIZE * 2) char *zbx_create_token(zbx_uint64_t seed); @@ -1726,4 +1727,14 @@ int zbx_open_xml(char *data, int options, int maxerrlen, void **xml_doc, void ** int zbx_check_xml_memory(char *mem, int maxerrlen, char **errmsg); #endif +/* report scheduling */ + +#define ZBX_REPORT_CYCLE_DAILY 0 +#define ZBX_REPORT_CYCLE_WEEKLY 1 +#define ZBX_REPORT_CYCLE_MONTHLY 2 +#define ZBX_REPORT_CYCLE_YEARLY 3 + +int zbx_get_report_nextcheck(int now, unsigned char cycle, unsigned char weekdays, int start_time, + const char *tz); + #endif diff --git a/include/db.h b/include/db.h index d297ad216dd..cbed36b4b8d 100644 --- a/include/db.h +++ b/include/db.h @@ -210,6 +210,8 @@ struct _DC_TRIGGER; #define FUNCTION_PARAM_LEN 255 +#define REPORT_ERROR_LEN 2048 + #define ZBX_SQL_ITEM_FIELDS "i.itemid,i.key_,h.host,i.type,i.history,i.hostid,i.value_type,i.delta," \ "i.units,i.multiplier,i.formula,i.state,i.valuemapid,i.trends,i.data_type" #define ZBX_SQL_ITEM_TABLES "hosts h,items i" @@ -352,11 +354,10 @@ typedef struct } DB_EVENT; -typedef struct +typedef struct DB_MEDIATYPE { zbx_uint64_t mediatypeid; zbx_media_type_t type; - char *description; char *smtp_server; char *smtp_helo; char *smtp_email; @@ -365,14 +366,25 @@ typedef struct char *gsm_modem; char *username; char *passwd; + char *script; + char *attempt_interval; + char *timeout; unsigned short smtp_port; unsigned char smtp_security; unsigned char smtp_verify_peer; unsigned char smtp_verify_host; unsigned char smtp_authentication; + unsigned char content_type; + int maxsessions; + int maxattempts; } DB_MEDIATYPE; +void zbx_db_mediatype_clean(DB_MEDIATYPE *mt); +void zbx_serialize_mediatype(unsigned char **data, zbx_uint32_t *data_alloc, zbx_uint32_t *data_offset, + const DB_MEDIATYPE *mt); +zbx_uint32_t zbx_deserialize_mediatype(const unsigned char *data, DB_MEDIATYPE *mt); + typedef struct { zbx_uint64_t alertid; @@ -877,6 +889,7 @@ void zbx_lld_override_operation_free(zbx_lld_override_operation_t *override_oper void zbx_load_lld_override_operations(const zbx_vector_uint64_t *overrideids, char **sql, size_t *sql_alloc, zbx_vector_ptr_t *ops); +#define ZBX_TIMEZONE_DEFAULT_VALUE "default" #endif diff --git a/include/preproc.h b/include/preproc.h index 6a011cbd716..b9cde38d2a0 100644 --- a/include/preproc.h +++ b/include/preproc.h @@ -43,7 +43,7 @@ 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, +void zbx_preprocess_item_value(zbx_uint64_t itemid, zbx_uint64_t hostid, unsigned char item_value_type, unsigned char item_flags, AGENT_RESULT *result, zbx_timespec_t *ts, unsigned char state, char *error); void zbx_preprocessor_flush(void); zbx_uint64_t zbx_preprocessor_get_queue_size(void); diff --git a/include/version.h b/include/version.h index e7cf328aeac..fef5d4ade55 100644 --- a/include/version.h +++ b/include/version.h @@ -24,7 +24,7 @@ #define ZBX_STR(str) ZBX_STR2(str) #define APPLICATION_NAME "Zabbix Agent" -#define ZABBIX_REVDATE "22 March 2021" +#define ZABBIX_REVDATE "26 April 2021" #define ZABBIX_VERSION_MAJOR 5 #define ZABBIX_VERSION_MINOR 4 #define ZABBIX_VERSION_PATCH 0 diff --git a/include/zbxalert.h b/include/zbxalert.h index e8b6c8095cb..3209b5e7316 100644 --- a/include/zbxalert.h +++ b/include/zbxalert.h @@ -21,6 +21,8 @@ #define ZABBIX_ZBXALERT_H #include "common.h" +#include "db.h" +#include "zbxipcservice.h" typedef struct { @@ -31,10 +33,33 @@ typedef struct } zbx_am_source_stats_t; -int zbx_alerter_get_diag_stats(zbx_uint64_t *alerts_num, char **error); +typedef struct +{ + char *recipient; + char *info; + int status; +} +zbx_alerter_dispatch_result_t; -int zbx_alerter_get_top_mediatypes(int limit, zbx_vector_uint64_pair_t *mediatypes, char **error); +typedef struct +{ + zbx_ipc_async_socket_t alerter; + int total_num; + zbx_vector_ptr_t results; +} +zbx_alerter_dispatch_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); +int zbx_alerter_begin_dispatch(zbx_alerter_dispatch_t *dispatch, const char *subject, const char *message, + const char *content_name, const char *content_type, const char *content, zbx_uint32_t content_size, + char **error); +int zbx_alerter_send_dispatch(zbx_alerter_dispatch_t *dispatch, const DB_MEDIATYPE *mediatype, + const zbx_vector_str_t *recipients, char **error); +int zbx_alerter_end_dispatch(zbx_alerter_dispatch_t *dispatch, char **error); +void zbx_alerter_dispatch_result_free(zbx_alerter_dispatch_result_t *result); +void zbx_alerter_clear_dispatch(zbx_alerter_dispatch_t *dispatch); + #endif diff --git a/include/zbxalgo.h b/include/zbxalgo.h index 782135dbcb6..a79b360ec95 100644 --- a/include/zbxalgo.h +++ b/include/zbxalgo.h @@ -459,5 +459,4 @@ int zbx_list_iterator_equal(const zbx_list_iterator_t *iterator1, const zbx_list 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/zbxipcservice.h b/include/zbxipcservice.h index 8f9cd56e0b3..95e71ed5cba 100644 --- a/include/zbxipcservice.h +++ b/include/zbxipcservice.h @@ -107,6 +107,8 @@ void zbx_ipc_client_release(zbx_ipc_client_t *client); int zbx_ipc_client_connected(zbx_ipc_client_t *client); zbx_uint64_t zbx_ipc_client_id(const zbx_ipc_client_t *client); zbx_ipc_client_t *zbx_ipc_client_by_id(const zbx_ipc_service_t *service, zbx_uint64_t id); +void zbx_ipc_client_set_userdata(zbx_ipc_client_t *client, void *userdata); +void *zbx_ipc_client_get_userdata(zbx_ipc_client_t *client); int zbx_ipc_socket_open(zbx_ipc_socket_t *csocket, const char *service_name, int timeout, char **error); void zbx_ipc_socket_close(zbx_ipc_socket_t *csocket); @@ -121,6 +123,7 @@ int zbx_ipc_async_socket_send(zbx_ipc_async_socket_t *asocket, zbx_uint32_t code int zbx_ipc_async_socket_recv(zbx_ipc_async_socket_t *asocket, int timeout, zbx_ipc_message_t **message); int zbx_ipc_async_socket_flush(zbx_ipc_async_socket_t *asocket, int timeout); int zbx_ipc_async_socket_check_unsent(zbx_ipc_async_socket_t *asocket); +int zbx_ipc_async_socket_connected(zbx_ipc_async_socket_t *asocket); int zbx_ipc_async_exchange(const char *service_name, zbx_uint32_t code, int timeout, const unsigned char *data, zbx_uint32_t size, unsigned char **out, char **error); diff --git a/include/zbxjson.h b/include/zbxjson.h index e066d0a2bff..1a3971e02be 100644 --- a/include/zbxjson.h +++ b/include/zbxjson.h @@ -167,6 +167,15 @@ #define ZBX_PROTO_TAG_CLIENTIP "clientip" #define ZBX_PROTO_TAG_ITEM_TAGS "item_tags" #define ZBX_PROTO_TAG_PROXY_UPLOAD "upload" +#define ZBX_PROTO_TAG_DASHBOARDID "dashboardid" +#define ZBX_PROTO_TAG_USERID "userid" +#define ZBX_PROTO_TAG_PERIOD "period" +#define ZBX_PROTO_TAG_NOW "now" +#define ZBX_PROTO_TAG_SESSIONID "sessionid" +#define ZBX_PROTO_TAG_SIGN "sign" +#define ZBX_PROTO_TAG_DETAIL "detail" +#define ZBX_PROTO_TAG_RECIPIENT "recipient" +#define ZBX_PROTO_TAG_RECIPIENTS "recipients" #define ZBX_PROTO_VALUE_FAILED "failed" #define ZBX_PROTO_VALUE_SUCCESS "success" @@ -202,6 +211,8 @@ #define ZBX_PROTO_VALUE_PROXY_UPLOAD_ENABLED "enabled" #define ZBX_PROTO_VALUE_PROXY_UPLOAD_DISABLED "disabled" +#define ZBX_PROTO_VALUE_REPORT_TEST "report.test" + typedef enum { ZBX_JSON_TYPE_UNKNOWN = 0, diff --git a/include/zbxlld.h b/include/zbxlld.h index 6df122d99ed..f4e3068bfe9 100644 --- a/include/zbxlld.h +++ b/include/zbxlld.h @@ -23,10 +23,10 @@ #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, +void zbx_lld_process_value(zbx_uint64_t itemid, zbx_uint64_t hostid, const char *value, const zbx_timespec_t *ts, unsigned char meta, zbx_uint64_t lastlogsize, int mtime, const char *error); -void zbx_lld_process_agent_result(zbx_uint64_t itemid, AGENT_RESULT *result, zbx_timespec_t *ts, char *error); +void zbx_lld_process_agent_result(zbx_uint64_t itemid, zbx_uint64_t hostid, AGENT_RESULT *result, zbx_timespec_t *ts, char *error); int zbx_lld_get_queue_size(zbx_uint64_t *size, char **error); diff --git a/include/zbxmedia.h b/include/zbxmedia.h index 763e457d3c7..b8a7d698088 100644 --- a/include/zbxmedia.h +++ b/include/zbxmedia.h @@ -24,6 +24,7 @@ #define ZBX_MEDIA_CONTENT_TYPE_TEXT 0 #define ZBX_MEDIA_CONTENT_TYPE_HTML 1 +#define ZBX_MEDIA_CONTENT_TYPE_MULTI 2 /* multipart/mixed message with pre-formatted message body */ extern char *CONFIG_SOURCE_IP; @@ -41,4 +42,7 @@ int send_email(const char *smtp_server, unsigned short smtp_port, const char *sm unsigned char content_type, int timeout, char *error, size_t max_error_len); int send_sms(const char *device, const char *number, const char *message, char *error, int max_error_len); +char *zbx_email_make_body(const char *message, unsigned char content_type, const char *attachment_name, + const char *attachment_type, const char *attachment, size_t attachment_size); + #endif diff --git a/include/zbxprometheus.h b/include/zbxprometheus.h index 698b44be2da..74eaf6efb07 100644 --- a/include/zbxprometheus.h +++ b/include/zbxprometheus.h @@ -17,8 +17,8 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ -#ifndef __zbxprometheus_h__ -#define __zbxprometheus_h__ +#ifndef ZABBIX_ZBXPROMETHEUS_H +#define ZABBIX_ZBXPROMETHEUS_H int zbx_prometheus_pattern(const char *data, const char *filter_data, const char *output, char **value, char **error); @@ -27,4 +27,4 @@ int zbx_prometheus_to_json(const char *data, const char *filter_data, char **val int zbx_prometheus_validate_filter(const char *pattern, char **error); int zbx_prometheus_validate_label(const char *label); -#endif /* __zbxprometheus_h__ */ +#endif diff --git a/include/zbxreport.h b/include/zbxreport.h new file mode 100644 index 00000000000..8631e3d5083 --- /dev/null +++ b/include/zbxreport.h @@ -0,0 +1,34 @@ +/* +** 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_ZBXREPORT_H +#define ZABBIX_ZBXREPORT_H + +#include "zbxjson.h" + +#define ZBX_REPORT_STATUS_ENABLED 0 +#define ZBX_REPORT_STATUS_DISABLED 1 + +#define ZBX_REPORT_PERIOD_DAY 0 +#define ZBX_REPORT_PERIOD_WEEK 0 +#define ZBX_REPORT_PERIOD_MONTH 0 +#define ZBX_REPORT_PERIOD_YEAR 0 + +void zbx_report_test(const struct zbx_json_parse *jp, zbx_uint64_t userid, struct zbx_json *j); + +#endif diff --git a/include/zbxserialize.h b/include/zbxserialize.h index 8afc9787be5..77790a312f6 100644 --- a/include/zbxserialize.h +++ b/include/zbxserialize.h @@ -22,16 +22,16 @@ #include "common.h" -#define zbx_serialize_prepare_str(len, str) \ - str##_len = (NULL != str ? strlen(str) + 1 : 0); \ +#define zbx_serialize_prepare_str(len, str) \ + str##_len = (NULL != str ? (zbx_uint32_t)strlen(str) + 1 : 0); \ len += str##_len + sizeof(zbx_uint32_t) -#define zbx_serialize_prepare_str_len(len, str, str_len) \ - str_len = (NULL != str ? strlen(str) + 1 : 0); \ +#define zbx_serialize_prepare_str_len(len, str, str_len) \ + str_len = (NULL != str ? (zbx_uint32_t)strlen(str) + 1 : 0); \ len += str_len + sizeof(zbx_uint32_t) #define zbx_serialize_prepare_value(len, value) \ - len += sizeof(value) + len += (zbx_uint32_t)sizeof(value) #define zbx_serialize_uint64(buffer, value) (memcpy(buffer, &value, sizeof(zbx_uint64_t)), sizeof(zbx_uint64_t)) diff --git a/include/zbxserver.h b/include/zbxserver.h index c76b49a8faa..6ae77a86fc9 100644 --- a/include/zbxserver.h +++ b/include/zbxserver.h @@ -53,6 +53,7 @@ #define MACRO_TYPE_SCRIPT_PARAMS_FIELD 0x08000000 #define MACRO_TYPE_SCRIPT_NORMAL 0x10000000 #define MACRO_TYPE_SCRIPT_RECOVERY 0x20000000 +#define MACRO_TYPE_REPORT 0x40000000 #define MACRO_EXPAND_NO 0 #define MACRO_EXPAND_YES 1 diff --git a/include/zbxtypes.h b/include/zbxtypes.h index 42c55a17800..5182e11e675 100644 --- a/include/zbxtypes.h +++ b/include/zbxtypes.h @@ -214,7 +214,7 @@ zbx_uint128_t; /* macro to test if a signed value has been assigned to unsigned type (char, short, int, long long) */ #define ZBX_IS_TOP_BIT_SET(x) (0 != ((__UINT64_C(1) << ((sizeof(x) << 3) - 1)) & (x))) -#if defined(_WINDOWS) +#if defined(_WINDOWS) || defined(__MINGW32__) #define localtime_r(x, y) localtime_s(y, x) #endif |