diff options
author | Janis Freibergs <janis.freibergs@zabbix.com> | 2022-10-24 18:52:19 +0300 |
---|---|---|
committer | Janis Freibergs <janis.freibergs@zabbix.com> | 2022-10-24 18:52:19 +0300 |
commit | e59b61e5403fdacc0083fb475419b99a48f88dc0 (patch) | |
tree | 9e6d8a68105d1aae6bdbf02f93060de7a4d9916d /include | |
parent | 753b79f09550e50ea48de74a4c03fb79eb38e291 (diff) | |
parent | 9061d353e2cb5465acab966ea9c79480a21232a0 (diff) |
.......... [ZBXNEXT-7122] updated to latest from master; resolved conflicts
- src/zabbix_server/housekeeper/housekeeper.c
Diffstat (limited to 'include')
-rw-r--r-- | include/audit/zbxaudit_trigger.h | 7 | ||||
-rw-r--r-- | include/common/zbxsysinc.h | 4 | ||||
-rw-r--r-- | include/common/zbxtypes.h | 4 | ||||
-rw-r--r-- | include/dbcache.h | 80 | ||||
-rw-r--r-- | include/proxy.h | 7 | ||||
-rw-r--r-- | include/version.h | 4 | ||||
-rw-r--r-- | include/zbx_rtc_constants.h | 51 | ||||
-rw-r--r-- | include/zbxavailability.h | 6 | ||||
-rw-r--r-- | include/zbxcommon.h | 140 | ||||
-rw-r--r-- | include/zbxcrypto.h | 4 | ||||
-rw-r--r-- | include/zbxdb.h | 8 | ||||
-rw-r--r-- | include/zbxdbhigh.h | 43 | ||||
-rw-r--r-- | include/zbxexpr.h | 27 | ||||
-rw-r--r-- | include/zbxha.h | 4 | ||||
-rw-r--r-- | include/zbxjson.h | 4 | ||||
-rw-r--r-- | include/zbxnum.h | 2 | ||||
-rw-r--r-- | include/zbxrtc.h | 23 | ||||
-rw-r--r-- | include/zbxself.h | 26 | ||||
-rw-r--r-- | include/zbxsysinfo.h | 122 | ||||
-rw-r--r-- | include/zbxthreads.h | 8 | ||||
-rw-r--r-- | include/zbxtime.h | 2 | ||||
-rw-r--r-- | include/zbxxml.h | 1 |
22 files changed, 297 insertions, 280 deletions
diff --git a/include/audit/zbxaudit_trigger.h b/include/audit/zbxaudit_trigger.h index b2594bbcf49..e20772fabb1 100644 --- a/include/audit/zbxaudit_trigger.h +++ b/include/audit/zbxaudit_trigger.h @@ -27,9 +27,9 @@ void zbx_audit_trigger_create_entry(int audit_action, zbx_uint64_t triggerid, co void zbx_audit_trigger_update_json_add_data(zbx_uint64_t triggerid, zbx_uint64_t templateid, unsigned char recovery_mode, unsigned char status, unsigned char type, zbx_uint64_t value, - zbx_uint64_t state, unsigned char priority, const char *comments, const char *url, int flags, - unsigned char correlation_mode, const char *correlation_tag, unsigned char manual_close, - const char *opdata, unsigned char discover, const char *event_name); + zbx_uint64_t state, unsigned char priority, const char *comments, const char *url, + const char *url_name, int flags, unsigned char correlation_mode, const char *correlation_tag, + unsigned char manual_close, const char *opdata, unsigned char discover, const char *event_name); void zbx_audit_trigger_update_json_add_expr(zbx_uint64_t triggerid, int flags, const char *expression); void zbx_audit_trigger_update_json_add_rexpr(zbx_uint64_t triggerid, int flags, const char *recovery_expression); @@ -48,6 +48,7 @@ PREPARE_AUDIT_TRIGGER_UPDATE_H(event_name, const char*) PREPARE_AUDIT_TRIGGER_UPDATE_H(priority, int) PREPARE_AUDIT_TRIGGER_UPDATE_H(comments, const char*) PREPARE_AUDIT_TRIGGER_UPDATE_H(url, const char*) +PREPARE_AUDIT_TRIGGER_UPDATE_H(url_name, const char*) PREPARE_AUDIT_TRIGGER_UPDATE_H(type, int) PREPARE_AUDIT_TRIGGER_UPDATE_H(status, int) PREPARE_AUDIT_TRIGGER_UPDATE_H(templateid, zbx_uint64_t) diff --git a/include/common/zbxsysinc.h b/include/common/zbxsysinc.h index e7632ef38b9..94f60d98804 100644 --- a/include/common/zbxsysinc.h +++ b/include/common/zbxsysinc.h @@ -442,4 +442,8 @@ # include <float.h> #endif +#ifdef HAVE_SYS_UTSNAME_H +# include <sys/utsname.h> +#endif + #endif diff --git a/include/common/zbxtypes.h b/include/common/zbxtypes.h index ad5b844b7b0..f784d51456a 100644 --- a/include/common/zbxtypes.h +++ b/include/common/zbxtypes.h @@ -106,7 +106,7 @@ typedef long ssize_t; # endif # define zbx_uint64_t uint64_t -# if __WORDSIZE == 64 +# if __WORDSIZE == 64 || defined(__64BIT__) # if defined(__APPLE__) && defined(__MACH__) /* OS X */ # define ZBX_FS_UI64 "%llu" # define ZBX_FS_UO64 "%llo" @@ -129,7 +129,7 @@ typedef long ssize_t; # endif # define zbx_int64_t int64_t -# if __WORDSIZE == 64 +# if __WORDSIZE == 64 || defined(__64BIT__) # if defined(__APPLE__) && defined(__MACH__) /* OS X */ # define ZBX_FS_I64 "%lld" # define ZBX_FS_O64 "%llo" diff --git a/include/dbcache.h b/include/dbcache.h index 5cd8e45c6c5..a99d998c39d 100644 --- a/include/dbcache.h +++ b/include/dbcache.h @@ -40,7 +40,6 @@ #define ZBX_POLLER_TYPE_ODBC 6 #define ZBX_POLLER_TYPE_COUNT 7 /* number of poller types */ - typedef enum { ZBX_SESSION_TYPE_DATA = 0, @@ -320,6 +319,9 @@ typedef struct char tls_psk_identity[HOST_TLS_PSK_IDENTITY_LEN_MAX]; char tls_psk[HOST_TLS_PSK_LEN_MAX]; #endif + zbx_uint64_t revision; + zbx_uint64_t macro_revision; + char proxy_address[HOST_PROXY_ADDRESS_LEN_MAX]; int last_version_error_time; } @@ -590,14 +592,10 @@ typedef struct unsigned char type; unsigned char error_handler; char *params; - char *params_orig; char *error_handler_params; } zbx_preproc_op_t; -#define ZBX_PREPROC_MACRO_UPDATE_TRUE 1 -#define ZBX_PREPROC_MACRO_UPDATE_FALSE 0 - typedef struct { zbx_uint64_t itemid; @@ -607,8 +605,8 @@ typedef struct int dep_itemids_num; int preproc_ops_num; - int update_time; - int macro_update; + zbx_uint64_t revision; + zbx_uint64_t preproc_revision; zbx_uint64_pair_t *dep_itemids; zbx_preproc_op_t *preproc_ops; @@ -740,7 +738,7 @@ zbx_synced_new_config_t; #define ZBX_TRIGGER_GET_DEFAULT (~(unsigned int)ZBX_TRIGGER_GET_ITEMIDS) #define ZBX_TRIGGER_GET_ALL (~(unsigned int)0) -void DCsync_configuration(unsigned char mode, zbx_synced_new_config_t synced); +void DCsync_configuration(unsigned char mode, zbx_synced_new_config_t synced, zbx_vector_uint64_t *deleted_itemids); void DCsync_kvs_paths(const struct zbx_json_parse *jp_kvs_paths); int init_configuration_cache(char **error); void free_configuration_cache(void); @@ -758,7 +756,7 @@ void DCconfig_get_items_by_itemids_partial(DC_ITEM *items, const zbx_uint64_t *i unsigned int mode); int DCconfig_get_active_items_count_by_hostid(zbx_uint64_t hostid); void DCconfig_get_active_items_by_hostid(DC_ITEM *items, zbx_uint64_t hostid, int *errcodes, size_t num); -void DCconfig_get_preprocessable_items(zbx_hashset_t *items, int *timestamp); +void DCconfig_get_preprocessable_items(zbx_hashset_t *items, zbx_uint64_t *revision); void DCconfig_get_functions_by_functionids(DC_FUNCTION *functions, zbx_uint64_t *functionids, int *errcodes, size_t num); void DCconfig_clean_functions(DC_FUNCTION *functions, int *errcodes, size_t num); @@ -831,7 +829,7 @@ int DCconfig_get_proxypoller_nextcheck(void); void DCrequeue_proxy(zbx_uint64_t hostid, unsigned char update_nextcheck, int proxy_conn_err); int DCcheck_proxy_permissions(const char *host, const zbx_socket_t *sock, zbx_uint64_t *hostid, char **error); int DCcheck_host_permissions(const char *host, const zbx_socket_t *sock, zbx_uint64_t *hostid, - zbx_uint32_t *revision, char **error); + zbx_uint64_t *revision, char **error); int DCis_autoreg_host_changed(const char *host, unsigned short port, const char *host_metadata, zbx_conn_flags_t flag, const char *interface, int now, int heartbeat); @@ -1003,9 +1001,22 @@ typedef struct } zbx_session_t; +typedef struct +{ + zbx_uint64_t config; /* configuration cache revision, increased every sync */ + zbx_uint64_t expression; /* global expression revision */ + zbx_uint64_t autoreg_tls; /* autoregistration tls revision */ + zbx_uint64_t upstream; /* configuration revision received from server */ + zbx_uint64_t config_table; /* the global configuration revision (config table) */ +} +zbx_dc_revision_t; + const char *zbx_dc_get_session_token(void); -zbx_session_t *zbx_dc_get_or_create_session(zbx_uint64_t hostid, const char *token, - zbx_session_type_t session_type); +zbx_session_t *zbx_dc_get_or_create_session(zbx_uint64_t hostid, const char *token, zbx_session_type_t session_type); + +int zbx_dc_register_config_session(zbx_uint64_t hostid, const char *token, zbx_uint64_t session_config_revision, + zbx_dc_revision_t *dc_revision); + void zbx_dc_cleanup_sessions(void); void zbx_dc_cleanup_autoreg_host(void); @@ -1089,7 +1100,7 @@ typedef struct zbx_uint64_t hostid; zbx_uint32_t type; unsigned char lock; /* 1 if the timer has locked trigger, 0 otherwise */ - zbx_uint32_t revision; /* revision */ + zbx_uint64_t revision; /* revision */ time_t lastcheck; zbx_timespec_t eval_ts; /* the history time for which trigger must be recalculated */ zbx_timespec_t check_ts; /* time when timer must be checked */ @@ -1149,11 +1160,50 @@ typedef struct } zbx_cached_proxy_t; -ZBX_PTR_VECTOR_DECL(cached_proxy, zbx_cached_proxy_t *) +ZBX_PTR_VECTOR_DECL(cached_proxy_ptr, zbx_cached_proxy_t *) -void zbx_dc_get_all_proxies(zbx_vector_cached_proxy_t *proxies); +void zbx_dc_get_all_proxies(zbx_vector_cached_proxy_ptr_t *proxies); void zbx_cached_proxy_free(zbx_cached_proxy_t *proxy); int zbx_dc_get_proxy_name_type_by_id(zbx_uint64_t proxyid, int *status, char **name); +/* item snmpv3 security levels */ +#define ZBX_ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV 0 +#define ZBX_ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV 1 +#define ZBX_ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV 2 + +/* maintenance tag operators */ +#define ZBX_MAINTENANCE_TAG_OPERATOR_EQUAL 0 +#define ZBX_MAINTENANCE_TAG_OPERATOR_LIKE 2 + +/* maintenance tag evaluation types */ +/* SYNC WITH PHP! */ +#define ZBX_MAINTENANCE_TAG_EVAL_TYPE_AND_OR 0 +#define ZBX_MAINTENANCE_TAG_EVAL_TYPE_OR 2 + +/* special item key used for ICMP pings */ +#define ZBX_SERVER_ICMPPING_KEY "icmpping" +/* special item key used for ICMP ping latency */ +#define ZBX_SERVER_ICMPPINGSEC_KEY "icmppingsec" +/* special item key used for ICMP ping loss packages */ +#define ZBX_SERVER_ICMPPINGLOSS_KEY "icmppingloss" + +int zbx_dc_drule_next(time_t now, zbx_uint64_t *druleid, time_t *nextcheck); +void zbx_dc_drule_queue(time_t now, zbx_uint64_t druleid, int delay); + +int zbx_dc_httptest_next(time_t now, zbx_uint64_t *httptestid, time_t *nextcheck); +void zbx_dc_httptest_queue(time_t now, zbx_uint64_t httptestid, int delay); + +zbx_uint64_t zbx_dc_get_received_revision(void); +void zbx_dc_update_received_revision(zbx_uint64_t revision); + +void zbx_dc_get_proxy_config_updates(zbx_uint64_t proxy_hostid, zbx_uint64_t revision, zbx_vector_uint64_t *hostids, + zbx_vector_uint64_t *updated_hostids, zbx_vector_uint64_t *removed_hostids, + zbx_vector_uint64_t *httptestids); + +void zbx_dc_get_macro_updates(const zbx_vector_uint64_t *hostids, const zbx_vector_uint64_t *updated_hostids, + zbx_uint64_t revision, zbx_vector_uint64_t *macro_hostids, int *global, + zbx_vector_uint64_t *del_macro_hostids); +void zbx_dc_get_unused_macro_templates(zbx_hashset_t *templates, const zbx_vector_uint64_t *hostids, + zbx_vector_uint64_t *templateids); #endif diff --git a/include/proxy.h b/include/proxy.h index 250bdbd1873..060254e5ee6 100644 --- a/include/proxy.h +++ b/include/proxy.h @@ -37,16 +37,13 @@ #define ZBX_PROXY_ACTIVE_CHECK_AVAIL_TIMEOUT 30 -int get_active_proxy_from_request(struct zbx_json_parse *jp, DC_PROXY *proxy, char **error); +int get_active_proxy_from_request(const 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, const zbx_config_tls_t *zbx_config_tls); void update_proxy_lastaccess(const zbx_uint64_t hostid, time_t last_access); -int get_proxyconfig_data(zbx_uint64_t proxy_hostid, struct zbx_json *j, char **error); -int process_proxyconfig(struct zbx_json_parse *jp_data, struct zbx_json_parse *jp_kvs_paths); - int get_interface_availability_data(struct zbx_json *json, int *ts); int proxy_get_hist_data(struct zbx_json *j, zbx_uint64_t *lastid, int *more); @@ -67,7 +64,7 @@ int lld_process_discovery_rule(zbx_uint64_t lld_ruleid, const char *value, char int proxy_get_history_count(void); int proxy_get_delay(zbx_uint64_t lastid); -char *zbx_get_proxy_protocol_version_str(struct zbx_json_parse *jp); +char *zbx_get_proxy_protocol_version_str(const struct zbx_json_parse *jp); int zbx_get_proxy_protocol_version_int(const char *version_str); void zbx_update_proxy_data(DC_PROXY *proxy, char *version_str, int version_int, int lastaccess, int compress, zbx_uint64_t flags_add); diff --git a/include/version.h b/include/version.h index a4e04be3ab0..625d0d7ddc8 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 "14 September 2022" +#define ZABBIX_REVDATE "29 September 2022" #define ZABBIX_VERSION_MAJOR 6 #define ZABBIX_VERSION_MINOR 4 #define ZABBIX_VERSION_PATCH 0 @@ -36,7 +36,7 @@ # define ZABBIX_VERSION_RC_NUM {ZABBIX_RC_NUM} # endif #endif -#define ZABBIX_VERSION_RC "alpha2" +#define ZABBIX_VERSION_RC "beta2" #define ZABBIX_VERSION ZBX_STR(ZABBIX_VERSION_MAJOR) "." ZBX_STR(ZABBIX_VERSION_MINOR) "." \ ZBX_STR(ZABBIX_VERSION_PATCH) ZABBIX_VERSION_RC #define ZABBIX_REVISION ZBX_STR(ZABBIX_VERSION_REVISION) diff --git a/include/zbx_rtc_constants.h b/include/zbx_rtc_constants.h new file mode 100644 index 00000000000..9c9eec52a90 --- /dev/null +++ b/include/zbx_rtc_constants.h @@ -0,0 +1,51 @@ +/* +** Zabbix +** Copyright (C) 2001-2022 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_ZBX_RTC_CONSTANTS_H +#define ZABBIX_ZBX_RTC_CONSTANTS_H + +/* runtime control commands */ +#define ZBX_RTC_UNKNOWN 0 +#define ZBX_RTC_LOG_LEVEL_INCREASE 1 +#define ZBX_RTC_LOG_LEVEL_DECREASE 2 +#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 +#define ZBX_RTC_SECRETS_RELOAD 11 +#define ZBX_RTC_SERVICE_CACHE_RELOAD 12 +#define ZBX_RTC_TRIGGER_HOUSEKEEPER_EXECUTE 13 +#define ZBX_RTC_HA_STATUS 14 +#define ZBX_RTC_HA_REMOVE_NODE 15 +#define ZBX_RTC_HA_SET_FAILOVER_DELAY 16 +#define ZBX_RTC_USER_PARAMETERS_RELOAD 17 +#define ZBX_RTC_PROXY_CONFIG_CACHE_RELOAD 18 +#define ZBX_RTC_PROXYPOLLER_PROCESS 19 + +/* internal rtc messages */ +#define ZBX_RTC_SUBSCRIBE 100 +#define ZBX_RTC_SHUTDOWN 101 +#define ZBX_RTC_CONFIG_CACHE_RELOAD_WAIT 102 + +/* runtime control notifications, must be less than 10000 */ +#define ZBX_RTC_CONFIG_SYNC_NOTIFY 9999 + +#define ZBX_IPC_RTC_MAX 9999 + +#endif diff --git a/include/zbxavailability.h b/include/zbxavailability.h index d3c83a8436e..66009bdae9c 100644 --- a/include/zbxavailability.h +++ b/include/zbxavailability.h @@ -31,7 +31,7 @@ #define ZBX_IPC_AVAILMAN_ACTIVE_STATUS 4 #define ZBX_IPC_AVAILMAN_CONFSYNC_DIFF 5 #define ZBX_IPC_AVAILMAN_PROCESS_PROXY_HOSTDATA 6 -#define ZBX_IPC_AVAILMAN_PROXY_FLUSH_ALL_HOSTS 7 +#define ZBX_IPC_AVAILMAN_ACTIVE_PROXY_HB_UPDATE 7 #define ZBX_AVAIL_SERVER_CONN_TIMEOUT 3600 /* agent (ZABBIX, SNMP, IPMI, JMX) availability data */ @@ -145,4 +145,8 @@ void zbx_availability_deserialize_proxy_hostdata(const unsigned char *data, zbx zbx_uint32_t zbx_availability_serialize_hostids(unsigned char **data, zbx_vector_uint64_t *hostids); void zbx_availability_deserialize_hostids(const unsigned char *data, zbx_vector_uint64_t *hostids); + +zbx_uint32_t zbx_availability_serialize_active_proxy_hb_update(unsigned char **data, zbx_uint64_t hostid); +void zbx_availability_deserialize_active_proxy_hb_update(const unsigned char *data, zbx_uint64_t *hostid); + #endif /* ZABBIX_AVAILABILITY_H */ diff --git a/include/zbxcommon.h b/include/zbxcommon.h index 91e1fbc92da..a950e280195 100644 --- a/include/zbxcommon.h +++ b/include/zbxcommon.h @@ -289,99 +289,6 @@ typedef enum } zbx_dservice_type_t; -/* item snmpv3 security levels */ -#define ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV 0 -#define ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV 1 -#define ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV 2 - -/* item snmpv3 authentication protocol */ -#define ITEM_SNMPV3_AUTHPROTOCOL_MD5 0 -#define ITEM_SNMPV3_AUTHPROTOCOL_SHA1 1 -#define ITEM_SNMPV3_AUTHPROTOCOL_SHA224 2 -#define ITEM_SNMPV3_AUTHPROTOCOL_SHA256 3 -#define ITEM_SNMPV3_AUTHPROTOCOL_SHA384 4 -#define ITEM_SNMPV3_AUTHPROTOCOL_SHA512 5 - -/* item snmpv3 privacy protocol */ -#define ITEM_SNMPV3_PRIVPROTOCOL_DES 0 -#define ITEM_SNMPV3_PRIVPROTOCOL_AES128 1 -#define ITEM_SNMPV3_PRIVPROTOCOL_AES192 2 -#define ITEM_SNMPV3_PRIVPROTOCOL_AES256 3 -#define ITEM_SNMPV3_PRIVPROTOCOL_AES192C 4 -#define ITEM_SNMPV3_PRIVPROTOCOL_AES256C 5 - -/* condition evaluation types */ -#define CONDITION_EVAL_TYPE_AND_OR 0 -#define CONDITION_EVAL_TYPE_AND 1 -#define CONDITION_EVAL_TYPE_OR 2 -#define CONDITION_EVAL_TYPE_EXPRESSION 3 - -/* condition types */ -#define CONDITION_TYPE_HOST_GROUP 0 -#define CONDITION_TYPE_HOST 1 -#define CONDITION_TYPE_TRIGGER 2 -#define CONDITION_TYPE_TRIGGER_NAME 3 -#define CONDITION_TYPE_TRIGGER_SEVERITY 4 -/* #define CONDITION_TYPE_TRIGGER_VALUE 5 deprecated */ -#define CONDITION_TYPE_TIME_PERIOD 6 -#define CONDITION_TYPE_DHOST_IP 7 -#define CONDITION_TYPE_DSERVICE_TYPE 8 -#define CONDITION_TYPE_DSERVICE_PORT 9 -#define CONDITION_TYPE_DSTATUS 10 -#define CONDITION_TYPE_DUPTIME 11 -#define CONDITION_TYPE_DVALUE 12 -#define CONDITION_TYPE_HOST_TEMPLATE 13 -#define CONDITION_TYPE_EVENT_ACKNOWLEDGED 14 -/* #define CONDITION_TYPE_APPLICATION 15 deprecated */ -#define CONDITION_TYPE_SUPPRESSED 16 -#define CONDITION_TYPE_DRULE 18 -#define CONDITION_TYPE_DCHECK 19 -#define CONDITION_TYPE_PROXY 20 -#define CONDITION_TYPE_DOBJECT 21 -#define CONDITION_TYPE_HOST_NAME 22 -#define CONDITION_TYPE_EVENT_TYPE 23 -#define CONDITION_TYPE_HOST_METADATA 24 -#define CONDITION_TYPE_EVENT_TAG 25 -#define CONDITION_TYPE_EVENT_TAG_VALUE 26 -#define CONDITION_TYPE_SERVICE 27 -#define CONDITION_TYPE_SERVICE_NAME 28 - -/* condition operators */ -#define CONDITION_OPERATOR_EQUAL 0 -#define CONDITION_OPERATOR_NOT_EQUAL 1 -#define CONDITION_OPERATOR_LIKE 2 -#define CONDITION_OPERATOR_NOT_LIKE 3 -#define CONDITION_OPERATOR_IN 4 -#define CONDITION_OPERATOR_MORE_EQUAL 5 -#define CONDITION_OPERATOR_LESS_EQUAL 6 -#define CONDITION_OPERATOR_NOT_IN 7 -#define CONDITION_OPERATOR_REGEXP 8 -#define CONDITION_OPERATOR_NOT_REGEXP 9 -#define CONDITION_OPERATOR_YES 10 -#define CONDITION_OPERATOR_NO 11 -#define CONDITION_OPERATOR_EXIST 12 -#define CONDITION_OPERATOR_NOT_EXIST 13 - -/* maintenance tag operators */ -#define ZBX_MAINTENANCE_TAG_OPERATOR_EQUAL 0 -#define ZBX_MAINTENANCE_TAG_OPERATOR_LIKE 2 - -/* service problem tag operators */ -#define ZBX_SERVICE_TAG_OPERATOR_EQUAL 0 -#define ZBX_SERVICE_TAG_OPERATOR_LIKE 2 - -/* maintenance tag evaluation types */ -#define MAINTENANCE_TAG_EVAL_TYPE_AND_OR 0 -#define MAINTENANCE_TAG_EVAL_TYPE_OR 2 - -/* event type action condition values */ -#define EVENT_TYPE_ITEM_NOTSUPPORTED 0 -/* #define EVENT_TYPE_ITEM_NORMAL 1 deprecated */ -#define EVENT_TYPE_LLDRULE_NOTSUPPORTED 2 -/* #define EVENT_TYPE_LLDRULE_NORMAL 3 deprecated */ -#define EVENT_TYPE_TRIGGER_UNKNOWN 4 -/* #define EVENT_TYPE_TRIGGER_NORMAL 5 deprecated */ - typedef enum { SYSMAP_ELEMENT_TYPE_HOST = 0, @@ -400,13 +307,6 @@ typedef enum } zbx_graph_yaxis_types_t; -/* special item key used for ICMP pings */ -#define SERVER_ICMPPING_KEY "icmpping" -/* special item key used for ICMP ping latency */ -#define SERVER_ICMPPINGSEC_KEY "icmppingsec" -/* special item key used for ICMP ping loss packages */ -#define SERVER_ICMPPINGLOSS_KEY "icmppingloss" - /* runtime control options */ #define ZBX_CONFIG_CACHE_RELOAD "config_cache_reload" #define ZBX_SERVICE_CACHE_RELOAD "service_cache_reload" @@ -855,6 +755,8 @@ zbx_script_t; #define HOUSEKEEPER_STARTUP_DELAY 30 /* in minutes */ +#define ZBX_DEFAULT_INTERVAL SEC_PER_MIN + #define GET_SENDER_TIMEOUT 60 #ifndef MAX @@ -952,34 +854,6 @@ typedef enum } zbx_task_t; -/* runtime control commands */ -#define ZBX_RTC_UNKNOWN 0 -#define ZBX_RTC_LOG_LEVEL_INCREASE 1 -#define ZBX_RTC_LOG_LEVEL_DECREASE 2 -#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 -#define ZBX_RTC_SECRETS_RELOAD 11 -#define ZBX_RTC_SERVICE_CACHE_RELOAD 12 -#define ZBX_RTC_TRIGGER_HOUSEKEEPER_EXECUTE 13 -#define ZBX_RTC_HA_STATUS 14 -#define ZBX_RTC_HA_REMOVE_NODE 15 -#define ZBX_RTC_HA_SET_FAILOVER_DELAY 16 -#define ZBX_RTC_USER_PARAMETERS_RELOAD 17 -#define ZBX_RTC_PROXY_CONFIG_CACHE_RELOAD 18 -#define ZBX_RTC_PROXYPOLLER_PROCESS 19 - -/* internal rtc messages */ -#define ZBX_RTC_SUBSCRIBE 100 -#define ZBX_RTC_SHUTDOWN 101 -#define ZBX_RTC_CONFIG_CACHE_RELOAD_WAIT 102 - -/* runtime control notifications, must be less than 10000 */ -#define ZBX_RTC_CONFIG_SYNC_NOTIFY 9999 - -#define ZBX_IPC_RTC_MAX 9999 - typedef enum { HTTPTEST_AUTH_NONE = 0, @@ -1152,16 +1026,6 @@ zbx_uint64_t zbx_htole_uint64(zbx_uint64_t data); zbx_uint32_t zbx_letoh_uint32(zbx_uint32_t data); zbx_uint32_t zbx_htole_uint32(zbx_uint32_t data); -int is_hostname_char(unsigned char c); -int is_key_char(unsigned char c); -int is_function_char(unsigned char c); -int is_macro_char(unsigned char c); -int is_discovery_macro(const char *name); -int parse_key(const char **exp); -int parse_host_key(char *exp, char **host, char **key); -void make_hostname(char *host); -int zbx_check_hostname(const char *hostname, char **error); - unsigned char get_interface_type_by_item_type(unsigned char type); #define ZBX_SESSION_ACTIVE 0 diff --git a/include/zbxcrypto.h b/include/zbxcrypto.h index cdfeb5ee6f6..21367788ee9 100644 --- a/include/zbxcrypto.h +++ b/include/zbxcrypto.h @@ -21,12 +21,14 @@ #define ZABBIX_ZBXCRYPTO_H #include "zbxtypes.h" +#include "zbxhash.h" int zbx_hex2bin(const unsigned char *p_hex, unsigned char *buf, int buf_len); int zbx_bin2hex(const unsigned char *bin, size_t bin_len, char *out, size_t out_len); +#define ZBX_SESSION_TOKEN_SIZE (ZBX_MD5_DIGEST_SIZE * 2) + char *zbx_create_token(zbx_uint64_t seed); -size_t zbx_get_token_len(void); char *zbx_gen_uuid4(const char *seed); typedef enum diff --git a/include/zbxdb.h b/include/zbxdb.h index 9e37007aa0e..928e133b2fe 100644 --- a/include/zbxdb.h +++ b/include/zbxdb.h @@ -181,8 +181,8 @@ int zbx_db_strlen_n(const char *text_loc, size_t maxlen); #define ZBX_POSTGRESQL_MIN_VERSION_FRIENDLY "10.9" #define ZBX_POSTGRESQL_MIN_SUPPORTED_VERSION 130000 #define ZBX_POSTGRESQL_MIN_SUPPORTED_VERSION_FRIENDLY "13.0" -#define ZBX_POSTGRESQL_MAX_VERSION 149999 -#define ZBX_POSTGRESQL_MAX_VERSION_FRIENDLY "14.x" +#define ZBX_POSTGRESQL_MAX_VERSION 159999 +#define ZBX_POSTGRESQL_MAX_VERSION_FRIENDLY "15.x" #define ZBX_ORACLE_MIN_VERSION 1201000200 #define ZBX_ORACLE_MIN_VERSION_FRIENDLY "Database 12c Release 12.01.00.02.x" @@ -206,8 +206,8 @@ int zbx_db_strlen_n(const char *text_loc, size_t maxlen); #define ZBX_TIMESCALE_MIN_SUPPORTED_VERSION 20001 #define ZBX_TIMESCALE_MIN_SUPPORTED_VERSION_FRIENDLY "2.0.1" #define ZBX_TIMESCALE_MIN_VERSION_WITH_LICENSE_PARAM_SUPPORT 20000 -#define ZBX_TIMESCALE_MAX_VERSION 20799 -#define ZBX_TIMESCALE_MAX_VERSION_FRIENDLY "2.7" +#define ZBX_TIMESCALE_MAX_VERSION 20899 +#define ZBX_TIMESCALE_MAX_VERSION_FRIENDLY "2.8" #define ZBX_TIMESCALE_LICENSE_APACHE "apache" #define ZBX_TIMESCALE_LICENSE_APACHE_FRIENDLY "TimescaleDB Apache 2 Edition" #define ZBX_TIMESCALE_LICENSE_COMMUNITY "timescale" diff --git a/include/zbxdbhigh.h b/include/zbxdbhigh.h index 3a97e8e7326..d9db6416ad6 100644 --- a/include/zbxdbhigh.h +++ b/include/zbxdbhigh.h @@ -185,6 +185,12 @@ zbx_host_template_link_type; # define ZBX_SQL_STRVAL_NE(str) "<>", str #endif +#ifdef HAVE_MYSQL +# define ZBX_SQL_CONCAT() "concat(%s,%s)" +#else +# define ZBX_SQL_CONCAT() "%s||%s" +#endif + #define ZBX_SQL_NULLCMP(f1, f2) "((" f1 " is null and " f2 " is null) or " f1 "=" f2 ")" #define ZBX_DBROW2UINT64(uint, row) if (SUCCEED == DBis_null(row)) \ @@ -219,6 +225,7 @@ typedef struct char *expression; char *recovery_expression; char *url; + char *url_name; char *comments; char *correlation_tag; char *opdata; @@ -840,4 +847,40 @@ int DBselect_ids_names(const char *sql, zbx_vector_uint64_t *ids, zbx_vector_str int zbx_db_check_version_info(struct zbx_db_version_info_t *info, int allow_unsupported); void zbx_db_version_info_clear(struct zbx_db_version_info_t *version_info); +/* condition evaluation types */ +#define ZBX_ACTION_CONDITION_EVAL_TYPE_AND_OR 0 +#define ZBX_ACTION_CONDITION_EVAL_TYPE_AND 1 +#define ZBX_ACTION_CONDITION_EVAL_TYPE_OR 2 +#define ZBX_ACTION_CONDITION_EVAL_TYPE_EXPRESSION 3 + +/* condition types */ +#define ZBX_CONDITION_TYPE_HOST_GROUP 0 +#define ZBX_CONDITION_TYPE_HOST 1 +#define ZBX_CONDITION_TYPE_TRIGGER 2 +#define ZBX_CONDITION_TYPE_TRIGGER_NAME 3 +#define ZBX_CONDITION_TYPE_TRIGGER_SEVERITY 4 +/* #define ZBX_CONDITION_TYPE_TRIGGER_VALUE 5 deprecated */ +#define ZBX_CONDITION_TYPE_TIME_PERIOD 6 +#define ZBX_CONDITION_TYPE_DHOST_IP 7 +#define ZBX_CONDITION_TYPE_DSERVICE_TYPE 8 +#define ZBX_CONDITION_TYPE_DSERVICE_PORT 9 +#define ZBX_CONDITION_TYPE_DSTATUS 10 +#define ZBX_CONDITION_TYPE_DUPTIME 11 +#define ZBX_CONDITION_TYPE_DVALUE 12 +#define ZBX_CONDITION_TYPE_HOST_TEMPLATE 13 +#define ZBX_CONDITION_TYPE_EVENT_ACKNOWLEDGED 14 +/* #define ZBX_CONDITION_TYPE_APPLICATION 15 deprecated */ +#define ZBX_CONDITION_TYPE_SUPPRESSED 16 +#define ZBX_CONDITION_TYPE_DRULE 18 +#define ZBX_CONDITION_TYPE_DCHECK 19 +#define ZBX_CONDITION_TYPE_PROXY 20 +#define ZBX_CONDITION_TYPE_DOBJECT 21 +#define ZBX_CONDITION_TYPE_HOST_NAME 22 +#define ZBX_CONDITION_TYPE_EVENT_TYPE 23 +#define ZBX_CONDITION_TYPE_HOST_METADATA 24 +#define ZBX_CONDITION_TYPE_EVENT_TAG 25 +#define ZBX_CONDITION_TYPE_EVENT_TAG_VALUE 26 +#define ZBX_CONDITION_TYPE_SERVICE 27 +#define ZBX_CONDITION_TYPE_SERVICE_NAME 28 + #endif /* ZABBIX_DBHIGH_H */ diff --git a/include/zbxexpr.h b/include/zbxexpr.h index 5a3c1dc1f82..6d5d639ff66 100644 --- a/include/zbxexpr.h +++ b/include/zbxexpr.h @@ -22,6 +22,16 @@ #include "zbxcommon.h" +int zbx_is_hostname_char(unsigned char c); +int zbx_is_key_char(unsigned char c); +int zbx_is_function_char(unsigned char c); +int zbx_is_macro_char(unsigned char c); +int zbx_is_discovery_macro(const char *name); +int zbx_parse_key(const char **exp); +int zbx_parse_host_key(char *exp, char **host, char **key); +void zbx_make_hostname(char *host); +int zbx_check_hostname(const char *hostname, char **error); + int zbx_function_validate(const char *expr, size_t *par_l, size_t *par_r, char *error, int max_error_len); int zbx_function_validate_parameters(const char *expr, size_t *length); int zbx_user_macro_parse(const char *macro, int *macro_r, int *context_l, int *context_r, @@ -214,4 +224,21 @@ int zbx_check_time_period(const char *period, time_t time, const char *tz, int * int zbx_get_report_nextcheck(int now, unsigned char cycle, unsigned char weekdays, int start_time, const char *tz); /* interval END */ + +/* condition operators */ +#define ZBX_CONDITION_OPERATOR_EQUAL 0 +#define ZBX_CONDITION_OPERATOR_NOT_EQUAL 1 +#define ZBX_CONDITION_OPERATOR_LIKE 2 +#define ZBX_CONDITION_OPERATOR_NOT_LIKE 3 +#define ZBX_CONDITION_OPERATOR_IN 4 +#define ZBX_CONDITION_OPERATOR_MORE_EQUAL 5 +#define ZBX_CONDITION_OPERATOR_LESS_EQUAL 6 +#define ZBX_CONDITION_OPERATOR_NOT_IN 7 +#define ZBX_CONDITION_OPERATOR_REGEXP 8 +#define ZBX_CONDITION_OPERATOR_NOT_REGEXP 9 +#define ZBX_CONDITION_OPERATOR_YES 10 +#define ZBX_CONDITION_OPERATOR_NO 11 +#define ZBX_CONDITION_OPERATOR_EXIST 12 +#define ZBX_CONDITION_OPERATOR_NOT_EXIST 13 + #endif /* ZABBIX_EXPR_H */ diff --git a/include/zbxha.h b/include/zbxha.h index 5cf2082735c..c7d58ecb3dc 100644 --- a/include/zbxha.h +++ b/include/zbxha.h @@ -20,6 +20,8 @@ #ifndef ZABBIX_ZBXHA_H #define ZABBIX_ZBXHA_H +#include "zbx_rtc_constants.h" + #define ZBX_IPC_SERVICE_HA "haservice" #define ZBX_IPC_SERVICE_HA_PAUSE 1 @@ -49,8 +51,6 @@ #define ZBX_HA_DEFAULT_FAILOVER_DELAY SEC_PER_MIN -#define ZBX_HA_IS_CLUSTER() (NULL != CONFIG_HA_NODE_NAME && '\0' != *CONFIG_HA_NODE_NAME) - int zbx_ha_get_nodes(char **nodes, char **error); int zbx_ha_remove_node(const char *node, char **result, char **error); int zbx_ha_set_failover_delay(int delay, char **error); diff --git a/include/zbxjson.h b/include/zbxjson.h index 575ea730f68..28ed6fd68a6 100644 --- a/include/zbxjson.h +++ b/include/zbxjson.h @@ -196,6 +196,10 @@ #define ZBX_PROTO_TAG_PROXY_HOSTIDS "proxy_hostids" #define ZBX_PROTO_TAG_SUPPRESS_UNTIL "suppress_until" #define ZBX_PROTO_TAG_CONFIG_REVISION "config_revision" +#define ZBX_PROTO_TAG_FULL_SYNC "full_sync" +#define ZBX_PROTO_TAG_MACRO_SECRETS "macro.secrets" +#define ZBX_PROTO_TAG_REMOVED_HOSTIDS "del_hostids" +#define ZBX_PROTO_TAG_REMOVED_MACRO_HOSTIDS "del_macro_hostids" #define ZBX_PROTO_VALUE_FAILED "failed" #define ZBX_PROTO_VALUE_SUCCESS "success" diff --git a/include/zbxnum.h b/include/zbxnum.h index 9c9e5dc851f..0d343549c55 100644 --- a/include/zbxnum.h +++ b/include/zbxnum.h @@ -45,6 +45,8 @@ zbx_is_uint_n_range(str, ZBX_SIZE_T_MAX, value, sizeof(unsigned int), min, max) int zbx_is_uint_n_range(const char *str, size_t n, void *value, size_t size, zbx_uint64_t min, zbx_uint64_t max); +int zbx_is_int(const char *str, int *value); + int zbx_is_hex_n_range(const char *str, size_t n, void *value, size_t size, zbx_uint64_t min, zbx_uint64_t max); int zbx_is_hex_string(const char *str); diff --git a/include/zbxrtc.h b/include/zbxrtc.h index ab44c05d245..bff203c56c0 100644 --- a/include/zbxrtc.h +++ b/include/zbxrtc.h @@ -20,7 +20,11 @@ #ifndef ZABBIX_ZBXRTC_H #define ZABBIX_ZBXRTC_H +#include "zbxalgo.h" #include "zbxipcservice.h" +#include "zbxthreads.h" + +#define ZBX_IPC_SERVICE_RTC "rtc" typedef struct { @@ -49,20 +53,27 @@ typedef struct } zbx_rtc_t; +typedef int (*zbx_rtc_process_request_ex_func_t)(zbx_rtc_t *, int, const unsigned char *, char **); + /* provider API */ int zbx_rtc_init(zbx_rtc_t *rtc ,char **error); -void zbx_rtc_dispatch(zbx_rtc_t *rtc, zbx_ipc_client_t *client, zbx_ipc_message_t *message); -int zbx_rtc_wait_config_sync(zbx_rtc_t *rtc); +void zbx_rtc_dispatch(zbx_rtc_t *rtc, zbx_ipc_client_t *client, zbx_ipc_message_t *message, + zbx_rtc_process_request_ex_func_t cb_proc_req); +int zbx_rtc_wait_config_sync(zbx_rtc_t *rtc, zbx_rtc_process_request_ex_func_t cb_proc_req); void zbx_rtc_shutdown_subs(zbx_rtc_t *rtc); -void zbx_rtc_reset(zbx_rtc_t *rtc); /* client API */ -int zbx_rtc_process(const char *option, char **error); -int zbx_rtc_open(zbx_ipc_async_socket_t *asocket, int timeout, char **error); void zbx_rtc_notify_config_sync(zbx_ipc_async_socket_t *rtc); void zbx_rtc_subscribe(zbx_ipc_async_socket_t *rtc, unsigned char proc_type, int proc_num); -int zbx_rtc_wait(zbx_ipc_async_socket_t *rtc, zbx_uint32_t *cmd, unsigned char **data, int timeout); +int zbx_rtc_wait(zbx_ipc_async_socket_t *rtc, const zbx_thread_info_t *info, zbx_uint32_t *cmd, + unsigned char **data, int timeout); int zbx_rtc_reload_config_cache(char **error); +int zbx_rtc_parse_options(const char *opt, zbx_uint32_t *code, char **data, char **error); +void zbx_rtc_notify(zbx_rtc_t *rtc, unsigned char process_type, int process_num, zbx_uint32_t code, + const unsigned char *data, zbx_uint32_t size); + +int zbx_rtc_async_exchange(char **data, zbx_uint32_t code, char **error); + #endif diff --git a/include/zbxself.h b/include/zbxself.h index 9fd1a4dac64..015c3bb831e 100644 --- a/include/zbxself.h +++ b/include/zbxself.h @@ -24,10 +24,10 @@ #define ZBX_PROCESS_STATE_BUSY 1 #define ZBX_PROCESS_STATE_COUNT 2 /* number of process states */ -#define ZBX_AGGR_FUNC_ONE 0 -#define ZBX_AGGR_FUNC_AVG 1 -#define ZBX_AGGR_FUNC_MAX 2 -#define ZBX_AGGR_FUNC_MIN 3 +#define ZBX_SELFMON_AGGR_FUNC_ONE 0 +#define ZBX_SELFMON_AGGR_FUNC_AVG 1 +#define ZBX_SELFMON_AGGR_FUNC_MAX 2 +#define ZBX_SELFMON_AGGR_FUNC_MIN 3 #define ZBX_SELFMON_DELAY 1 @@ -47,16 +47,18 @@ zbx_process_info_t; int get_process_type_forks(unsigned char proc_type); #ifndef _WINDOWS -int init_selfmon_collector(char **error); -void free_selfmon_collector(void); -void update_selfmon_counter(unsigned char state); -void collect_selfmon_stats(void); -void get_selfmon_stats(unsigned char proc_type, unsigned char aggr_func, int proc_num, unsigned char state, +#include "zbxthreads.h" + +ZBX_THREAD_ENTRY(zbx_selfmon_thread, args); + +int zbx_init_selfmon_collector(char **error); +void zbx_free_selfmon_collector(void); +void zbx_update_selfmon_counter(const zbx_thread_info_t *info, unsigned char state); +void zbx_collect_selfmon_stats(void); +void zbx_get_selfmon_stats(unsigned char proc_type, unsigned char aggr_func, int proc_num, unsigned char state, double *value); int zbx_get_all_process_stats(zbx_process_info_t *stats); -void zbx_sleep_loop(int sleeptime); -void zbx_wakeup(void); -int zbx_sleep_get_remainder(void); +void zbx_sleep_loop(const zbx_thread_info_t *info, int sleeptime); #endif #endif /* ZABBIX_ZBXSELF_H */ diff --git a/include/zbxsysinfo.h b/include/zbxsysinfo.h index 15a6b7ac248..2449fb01a81 100644 --- a/include/zbxsysinfo.h +++ b/include/zbxsysinfo.h @@ -171,7 +171,7 @@ extern int CONFIG_UNSAFE_USER_PARAMETERS; #define ZBX_DSTAT_W_OPER 4 #define ZBX_DSTAT_W_BYTE 5 #define ZBX_DSTAT_MAX 6 -int get_diskstat(const char *devname, zbx_uint64_t *dstat); +int zbx_get_diskstat(const char *devname, zbx_uint64_t *dstat); /* flags for process */ #define ZBX_PROCESS_LOCAL_COMMAND 0x1 @@ -185,48 +185,43 @@ typedef enum } zbx_key_access_rule_type_t; -void init_metrics(void); -int add_metric(ZBX_METRIC *metric, char *error, size_t max_error_len); -int add_metric_local(ZBX_METRIC *metric, char *error, size_t max_error_len); -void free_metrics_ext(ZBX_METRIC **metrics); -void free_metrics(void); - -void init_key_access_rules(void); -void finalize_key_access_rules_configuration(void); -int add_key_access_rule(const char *parameter, char *pattern, zbx_key_access_rule_type_t type); -int check_key_access_rules(const char *metric); -int check_request_access_rules(AGENT_REQUEST *request); -void free_key_access_rules(void); - -int process(const char *in_command, unsigned flags, AGENT_RESULT *result); - -void set_user_parameter_dir(const char *path); -int add_user_parameter(const char *itemkey, char *command, char *error, size_t max_error_len); -void remove_user_parameters(void); -void get_metrics_copy(ZBX_METRIC **metrics); -void set_metrics(ZBX_METRIC *metrics); -int add_user_module(const char *key, int (*function)(void)); -void test_parameters(void); -void test_parameter(const char *key); - -void init_result(AGENT_RESULT *result); -void zbx_log_free(zbx_log_t *log); -void free_result(AGENT_RESULT *result); +void zbx_init_metrics(void); +int zbx_add_metric(ZBX_METRIC *metric, char *error, size_t max_error_len); +void zbx_free_metrics_ext(ZBX_METRIC **metrics); +void zbx_free_metrics(void); -void init_request(AGENT_REQUEST *request); -void free_request(AGENT_REQUEST *request); +void zbx_init_key_access_rules(void); +void zbx_finalize_key_access_rules_configuration(void); -int parse_item_key(const char *itemkey, AGENT_REQUEST *request); +int zbx_add_key_access_rule(const char *parameter, char *pattern, zbx_key_access_rule_type_t type); +int zbx_check_key_access_rules(const char *metric); +int zbx_check_request_access_rules(AGENT_REQUEST *request); +void zbx_free_key_access_rules(void); -void unquote_key_param(char *param); -int quote_key_param(char **param, int forced); +int zbx_execute_agent_check(const char *in_command, unsigned flags, AGENT_RESULT *result); -int set_result_type(AGENT_RESULT *result, int value_type, char *c); -void set_result_meta(AGENT_RESULT *result, zbx_uint64_t lastlogsize, int mtime); +void zbx_set_user_parameter_dir(const char *path); +int zbx_add_user_parameter(const char *itemkey, char *command, char *error, size_t max_error_len); +void zbx_remove_user_parameters(void); +void zbx_get_metrics_copy(ZBX_METRIC **metrics); +void zbx_set_metrics(ZBX_METRIC *metrics); +void zbx_test_parameters(void); +void zbx_test_parameter(const char *key); -#ifdef HAVE_KSTAT_H -zbx_uint64_t get_kstat_numeric_value(const kstat_named_t *kn); -#endif +void zbx_init_agent_result(AGENT_RESULT *result); +void zbx_log_free(zbx_log_t *log); +void zbx_free_agent_result(AGENT_RESULT *result); + +void zbx_init_agent_request(AGENT_REQUEST *request); +void zbx_free_agent_request(AGENT_REQUEST *request); + +int zbx_parse_item_key(const char *itemkey, AGENT_REQUEST *request); + +void zbx_unquote_key_param(char *param); +int zbx_quote_key_param(char **param, int forced); + +int zbx_set_agent_result_type(AGENT_RESULT *result, int value_type, char *c); +void zbx_set_agent_result_meta(AGENT_RESULT *result, zbx_uint64_t lastlogsize, int mtime); /* external system functions */ @@ -303,42 +298,6 @@ int REGISTRY_GET(AGENT_REQUEST *request, AGENT_RESULT *result); int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result); #endif -#if defined(_WINDOWS) || defined(__MINGW32__) -typedef int (*zbx_metric_func_t)(AGENT_REQUEST *request, AGENT_RESULT *result, HANDLE timeout_event); -#else -typedef int (*zbx_metric_func_t)(AGENT_REQUEST *request, AGENT_RESULT *result); -#endif - -typedef struct -{ - const char *mode; - int (*function)(const char *devname, AGENT_RESULT *result); -} -MODE_FUNCTION; - -typedef struct -{ - zbx_uint64_t total; - zbx_uint64_t not_used; - zbx_uint64_t used; - double pfree; - double pused; -} -zbx_fs_metrics_t; - -typedef struct -{ - char fsname[MAX_STRING_LEN]; - char fstype[MAX_STRING_LEN]; - zbx_fs_metrics_t bytes; - zbx_fs_metrics_t inodes; - char *options; -} -zbx_mpoint_t; - -int zbx_execute_threaded_metric(zbx_metric_func_t metric_func, AGENT_REQUEST *request, AGENT_RESULT *result); -void zbx_mpoints_free(zbx_mpoint_t *mpoint); - /* the fields used by proc queries */ #define ZBX_SYSINFO_PROC_NONE 0x0000 #define ZBX_SYSINFO_PROC_PID 0x0001 @@ -350,20 +309,7 @@ void zbx_mpoints_free(zbx_mpoint_t *mpoint); #define ZBX_MUTEX_ALL_ALLOW 0 #define ZBX_MUTEX_THREAD_DENIED 1 #define ZBX_MUTEX_LOGGING_DENIED 2 -zbx_uint32_t get_thread_global_mutex_flag(void); -#endif - -#ifndef _WINDOWS -int hostname_handle_params(AGENT_REQUEST *request, AGENT_RESULT *result, char *hostname); - -typedef struct -{ - zbx_uint64_t flag; - const char *name; -} -zbx_mntopt_t; - -char *zbx_format_mntopt_string(zbx_mntopt_t mntopts[], int flags); +zbx_uint32_t zbx_get_thread_global_mutex_flag(void); #endif void zbx_add_alias(const char *name, const char *value); diff --git a/include/zbxthreads.h b/include/zbxthreads.h index 536c4a6af9c..da695fedbcc 100644 --- a/include/zbxthreads.h +++ b/include/zbxthreads.h @@ -84,7 +84,13 @@ typedef struct int server_num; int process_num; unsigned char process_type; - void *args; +} +zbx_thread_info_t; + +typedef struct +{ + zbx_thread_info_t info; + void *args; #if defined(_WINDOWS) || defined(__MINGW32__) ZBX_THREAD_ENTRY_POINTER(entry); #endif diff --git a/include/zbxtime.h b/include/zbxtime.h index 678156523a7..a383d774845 100644 --- a/include/zbxtime.h +++ b/include/zbxtime.h @@ -81,4 +81,6 @@ int zbx_calculate_sleeptime(int nextcheck, int max_sleeptime); char *zbx_age2str(int age); char *zbx_date2str(time_t date, const char *tz); char *zbx_time2str(time_t time, const char *tz); +int zbx_iso8601_utc(const char *str, time_t *time); + #endif /* ZABBIX_TIME_H */ diff --git a/include/zbxxml.h b/include/zbxxml.h index 7cc1bb22a34..7cf062cb8fd 100644 --- a/include/zbxxml.h +++ b/include/zbxxml.h @@ -52,6 +52,7 @@ int zbx_xml_node_read_values(xmlDoc *xdoc, xmlNode *node, const char *xpath, zbx int zbx_xml_try_read_value(const char *data, size_t len, const char *xpath, xmlDoc **xdoc, char **value, char **error); int zbx_xml_doc_read_num(xmlDoc *xdoc, const char *xpath, int *num); +int zbx_xml_node_read_num(xmlDoc *xdoc, xmlNode *node, const char *xpath, int *num); char *zbx_xml_node_read_value(xmlDoc *xdoc, xmlNode *node, const char *xpath); char *zbx_xml_doc_read_value(xmlDoc *xdoc, const char *xpath); xmlNode *zbx_xml_node_get(xmlDoc *xdoc, xmlNode *node, const char *xpath); |