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:
authorArtjoms Rimdjonoks <artjoms.rimdjonoks@zabbix.com>2021-08-06 07:51:58 +0300
committerArtjoms Rimdjonoks <artjoms.rimdjonoks@zabbix.com>2021-08-06 17:19:17 +0300
commit373a6eca9148831bf6fb15e7e7416706e443d59c (patch)
treee50727234a99f9a80b4dbfd3218064e69c14244c
parent5d354dcb9addccd210e2d6ee2943c2a2b036828e (diff)
........S. [ZBXNEXT-6817] added initial code for items audit
-rw-r--r--src/libs/Makefile.am4
-rw-r--r--src/libs/zbxaudit/Makefile.am4
-rw-r--r--src/libs/zbxaudit/audit.h5
-rw-r--r--src/libs/zbxaudit/audit_item.c164
-rw-r--r--src/libs/zbxaudit/audit_item.h31
-rw-r--r--src/libs/zbxdbhigh/template.h132
-rw-r--r--src/libs/zbxdbhigh/template_item.c134
-rw-r--r--src/zabbix_server/Makefile.am5
-rw-r--r--tests/libs/zbxdbcache/Makefile.am1
-rw-r--r--tests/libs/zbxdbhigh/Makefile.am2
-rwxr-xr-xtests/libs/zbxserver/Makefile.am3
11 files changed, 351 insertions, 134 deletions
diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am
index d0ce97a248a..4c8b07dd871 100644
--- a/src/libs/Makefile.am
+++ b/src/libs/Makefile.am
@@ -35,8 +35,8 @@ DIST_SUBDIRS = \
zbxdiag \
zbxtrends \
zbxavailability \
- zbxaudit \
zbxservice \
+ zbxaudit \
zbxeval
if SERVER
@@ -61,8 +61,8 @@ SERVER_SUBDIRS = \
zbxdiag \
zbxtrends \
zbxavailability \
- zbxaudit \
zbxservice \
+ zbxaudit \
zbxeval
else
if PROXY
diff --git a/src/libs/zbxaudit/Makefile.am b/src/libs/zbxaudit/Makefile.am
index 2f5ed74d92b..6bff91983eb 100644
--- a/src/libs/zbxaudit/Makefile.am
+++ b/src/libs/zbxaudit/Makefile.am
@@ -6,4 +6,6 @@ libzbxaudit_a_SOURCES = \
audit.c \
audit.h \
audit_host.c \
- audit_host.h
+ audit_host.h \
+ audit_item.c \
+ audit_item.h
diff --git a/src/libs/zbxaudit/audit.h b/src/libs/zbxaudit/audit.h
index 1fd8ade9f33..2543ac6e88f 100644
--- a/src/libs/zbxaudit/audit.h
+++ b/src/libs/zbxaudit/audit.h
@@ -36,8 +36,11 @@
#define AUDIT_DETAILS_KEY_LEN 100
#define AUDIT_RESOURCE_HOST 4
-#define AUDIT_RESOURCE_HOST_PROTOTYPE 37
+#define AUDIT_RESOURCE_ITEM 15
+#define AUDIT_RESOURCE_DISCOVERY_RULE 23
#define AUDIT_RESOURCE_SCRIPT 25
+#define AUDIT_RESOURCE_ITEM_PROTOTYPE 36
+#define AUDIT_RESOURCE_HOST_PROTOTYPE 37
#define RETURN_IF_AUDIT_OFF() \
if (ZBX_AUDITLOG_ENABLED != zbx_get_audit_mode()) \
diff --git a/src/libs/zbxaudit/audit_item.c b/src/libs/zbxaudit/audit_item.c
new file mode 100644
index 00000000000..b1bc91a5614
--- /dev/null
+++ b/src/libs/zbxaudit/audit_item.c
@@ -0,0 +1,164 @@
+/*
+** 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.
+**/
+
+#include "dbcache.h"
+
+#include "log.h"
+//#include "audit_item.h"
+#include "audit_item.h"
+
+static int item_flag_to_resource_type(int flag)
+{
+ if (ZBX_FLAG_DISCOVERY_NORMAL == flag || ZBX_FLAG_DISCOVERY_CREATED == flag)
+ {
+ return AUDIT_RESOURCE_ITEM;
+ }
+ else if (ZBX_FLAG_DISCOVERY_PROTOTYPE == flag)
+ {
+ return AUDIT_RESOURCE_ITEM_PROTOTYPE;
+ }
+ else if (ZBX_FLAG_DISCOVERY_RULE == flag)
+ {
+ return AUDIT_RESOURCE_DISCOVERY_RULE;
+ }
+ else
+ {
+ zabbix_log(LOG_LEVEL_DEBUG, "unexpected audit detected: ->%d<-", flag);
+ THIS_SHOULD_NEVER_HAPPEN;
+ exit(EXIT_FAILURE);
+ }
+}
+
+#define PREPARE_AUDIT_ITEM(resource, audit_resource_flag) \
+void zbx_audit_##resource##_create_entry(int audit_action, zbx_uint64_t itemid, const char *name) \
+{ \
+ zbx_audit_entry_t local_audit_item_entry, **found_audit_item_entry; \
+ zbx_audit_entry_t *local_audit_item_entry_x = &local_audit_item_entry; \
+ \
+ RETURN_IF_AUDIT_OFF(); \
+ \
+ local_audit_item_entry.id = itemid; \
+ \
+ found_audit_item_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(), \
+ &(local_audit_item_entry_x)); \
+ if (NULL == found_audit_item_entry) \
+ { \
+ zbx_audit_entry_t *local_audit_item_entry_insert; \
+ \
+ local_audit_item_entry_insert = (zbx_audit_entry_t*)zbx_malloc(NULL, sizeof(zbx_audit_entry_t));\
+ local_audit_item_entry_insert->id = itemid; \
+ local_audit_item_entry_insert->name = zbx_strdup(NULL, name); \
+ local_audit_item_entry_insert->audit_action = audit_action; \
+ local_audit_item_entry_insert->resource_type = audit_resource_flag; \
+ zbx_json_init(&(local_audit_item_entry_insert->details_json), ZBX_JSON_STAT_BUF_LEN); \
+ zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_item_entry_insert, \
+ sizeof(local_audit_item_entry_insert)); \
+ } \
+} \
+
+PREPARE_AUDIT_ITEM(item, AUDIT_RESOURCE_ITEM)
+
+void zbx_audit_item_add_data(zbx_uint64_t itemid, const zbx_template_item_t *item, zbx_uint64_t hostid)
+{
+ int resource_type;
+
+ RETURN_IF_AUDIT_OFF();
+
+ resource_type = item_flag_to_resource_type(item->flags);
+
+#define ONLY_ITEM (AUDIT_RESOURCE_ITEM == resource_type)
+#define ONLY_ITEM_PROTOTYPE (AUDIT_RESOURCE_ITEM_PROTOTYPE == resource_type)
+#define ONLY_LLD_RULE (AUDIT_RESOURCE_DISCOVERY_RULE == resource_type)
+#define ONLY_ITEM_AND_ITEM_PROTOTYPE (AUDIT_RESOURCE_ITEM == resource_type || \
+ AUDIT_RESOURCE_ITEM_PROTOTYPE == resource_type)
+#define IT_OR_ITP(s) ONLY_ITEM ? "item."#s : \
+ (ONLY_ITEM_PROTOTYPE ? "itemprototype."#s : "discoveryrule."#s)
+#define ADD_JSON_S(x) zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP(x), item->x)
+#define ADD_JSON_UI(x) zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP(x), item->x)
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP(itemid), itemid);
+ ADD_JSON_S(delay);
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP(hostid), hostid);
+ /* ruleid is REQUIRED for item prototype */
+ ADD_JSON_UI(interfaceid);
+ ADD_JSON_S(key); // API HAS 'key_' , but SQL 'key'
+ ADD_JSON_S(name);
+ ADD_JSON_UI(type);
+ ADD_JSON_S(url);
+ if ONLY_ITEM_AND_ITEM_PROTOTYPE ADD_JSON_UI(value_type);
+ ADD_JSON_UI(allow_traps);
+ ADD_JSON_UI(authtype);
+ ADD_JSON_S(description);
+ /* error - only for item and LLD RULE */
+ if ONLY_ITEM ADD_JSON_UI(flags);
+ ADD_JSON_UI(follow_redirects);
+ ADD_JSON_S(headers);
+ if ONLY_ITEM_AND_ITEM_PROTOTYPE ADD_JSON_S(history);
+ ADD_JSON_S(http_proxy);
+ if ONLY_ITEM ADD_JSON_UI(inventory_link);
+ ADD_JSON_S(ipmi_sensor);
+ ADD_JSON_S(jmx_endpoint);
+ if ONLY_LLD_RULE ADD_JSON_S(lifetime);
+ /* lastclock - only for item */
+ /* last ns - only for item */
+ /* lastvalue - only for item */
+ if ONLY_ITEM_AND_ITEM_PROTOTYPE ADD_JSON_S(logtimefmt);
+ ADD_JSON_UI(master_itemid);
+ ADD_JSON_UI(output_format);
+ ADD_JSON_S(params);
+ /* parameters , handled later - for both item and item prototype and LLD RULE */
+ ADD_JSON_S(password);
+ ADD_JSON_UI(post_type);
+ ADD_JSON_S(posts);
+ /* prevvalue - only for item */
+ ADD_JSON_S(privatekey);
+ ADD_JSON_S(publickey);
+ ADD_JSON_S(query_fields);
+ ADD_JSON_UI(request_method);
+ ADD_JSON_UI(retrieve_mode);
+ ADD_JSON_S(snmp_oid);
+ ADD_JSON_S(ssl_cert_file);
+ ADD_JSON_S(ssl_key_file);
+ ADD_JSON_S(ssl_key_password);
+ /* state - only for item and LLD RULE */
+ ADD_JSON_UI(status);
+ ADD_JSON_S(status_codes);
+ ADD_JSON_UI(templateid);
+ ADD_JSON_S(timeout);
+ ADD_JSON_S(trapper_hosts);
+ if ONLY_ITEM_AND_ITEM_PROTOTYPE ADD_JSON_S(trends);
+ if ONLY_ITEM_AND_ITEM_PROTOTYPE ADD_JSON_S(units);
+ ADD_JSON_S(username);
+ if ONLY_ITEM_AND_ITEM_PROTOTYPE ADD_JSON_UI(valuemapid);
+ ADD_JSON_UI(verify_host);
+ ADD_JSON_UI(verify_peer);
+ /* discover - only for item */
+ /* ITEM API FINISHED */
+
+ /* application - handled later
+ preprocessing - handled later */
+
+ if ONLY_LLD_RULE
+ {
+ ADD_JSON_S(formula);
+ ADD_JSON_UI(evaltype);
+ ADD_JSON_UI(discover);
+ }
+#undef ADD_JSON_UI
+#undef ADD_JSON_S
+}
diff --git a/src/libs/zbxaudit/audit_item.h b/src/libs/zbxaudit/audit_item.h
new file mode 100644
index 00000000000..5fb450e1bf8
--- /dev/null
+++ b/src/libs/zbxaudit/audit_item.h
@@ -0,0 +1,31 @@
+/*
+** 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_AUDIT_ITEM_H
+#define ZABBIX_AUDIT_ITEM_H
+
+#include "common.h"
+#include "audit.h"
+
+#include "../zbxdbhigh/template.h"
+
+void zbx_audit_item_create_entry(int audit_action, zbx_uint64_t itemid, const char *name);
+void zbx_audit_item_add_data(zbx_uint64_t itemid, const zbx_template_item_t *item, zbx_uint64_t hostid);
+
+#endif /* ZABBIX_AUDIT_ITEM_H */
diff --git a/src/libs/zbxdbhigh/template.h b/src/libs/zbxdbhigh/template.h
index 44268194dbc..f032ea5a909 100644
--- a/src/libs/zbxdbhigh/template.h
+++ b/src/libs/zbxdbhigh/template.h
@@ -17,7 +17,139 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#ifndef ZABBIX_TEMPLATE_H
+#define ZABBIX_TEMPLATE_H
+
#include "zbxtypes.h"
#include "zbxalgo.h"
+typedef struct _zbx_template_item_preproc_t zbx_template_item_preproc_t;
+ZBX_PTR_VECTOR_DECL(item_preproc_ptr, zbx_template_item_preproc_t *)
+
+typedef struct _zbx_template_item_tag_t zbx_template_item_tag_t;
+ZBX_PTR_VECTOR_DECL(item_tag_ptr, zbx_template_item_tag_t *)
+
+typedef struct _zbx_template_item_param_t zbx_template_item_param_t;
+ZBX_PTR_VECTOR_DECL(item_param_ptr, zbx_template_item_param_t *)
+
+typedef struct _zbx_template_lld_macro_t zbx_template_lld_macro_t;
+ZBX_PTR_VECTOR_DECL(lld_macro_ptr, zbx_template_lld_macro_t *)
+
+typedef struct
+{
+ zbx_uint64_t itemid;
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_RESET_FLAG __UINT64_C(0x000000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_INTERFACEID __UINT64_C(0x000000000001)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TEMPLATEID __UINT64_C(0x000000000002)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_NAME __UINT64_C(0x000000000004)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TYPE __UINT64_C(0x000000000008)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VALUE_TYPE __UINT64_C(0x000000000010)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_DELAY __UINT64_C(0x000000000020)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_HISTORY __UINT64_C(0x000000000040)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TRENDS __UINT64_C(0x000000000080)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_STATUS __UINT64_C(0x000000000100)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TRAPPER_HOSTS __UINT64_C(0x000000000200)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_UNITS __UINT64_C(0x000000000400)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_FORMULA __UINT64_C(0x000000000800)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_LOGTIMEFMT __UINT64_C(0x000000001000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VALUEMAPID __UINT64_C(0x000000002000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PARAMS __UINT64_C(0x000000004000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_IPMI_SENSOR __UINT64_C(0x000000008000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SNMP_OID __UINT64_C(0x000000010000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_AUTHTYPE __UINT64_C(0x000000020000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_USERNAME __UINT64_C(0x000000040000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PASSWORD __UINT64_C(0x000000080000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PUBLICKEY __UINT64_C(0x000000100000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PRIVATEKEY __UINT64_C(0x000000200000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_FLAGS __UINT64_C(0x000000400000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_DESCRIPTION __UINT64_C(0x000000800000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_INVENTORY_LINK __UINT64_C(0x000001000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_LIFETIME __UINT64_C(0x000002000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_EVALTYPE __UINT64_C(0x000004000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_JMX_ENDPOINT __UINT64_C(0x000008000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_MASTER_ITEMID __UINT64_C(0x000010000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TIMEOUT __UINT64_C(0x000020000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_URL __UINT64_C(0x000040000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_QUERY_FIELDS __UINT64_C(0x000080000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_POSTS __UINT64_C(0x000100000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_STATUS_CODES __UINT64_C(0x000200000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_FOLLOW_REDIRECTS __UINT64_C(0x000400000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_POST_TYPE __UINT64_C(0x000800000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_HTTP_PROXY __UINT64_C(0x001000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_HEADERS __UINT64_C(0x002000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_RETRIEVE_MODE __UINT64_C(0x004000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_REQUEST_METHOD __UINT64_C(0x008000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_OUTPUT_FORMAT __UINT64_C(0x010000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SSL_CERT_FILE __UINT64_C(0x020000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SSL_KEY_FILE __UINT64_C(0x040000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SSL_KEY_PASSWORD __UINT64_C(0x080000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VERIFY_PEER __UINT64_C(0x100000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VERIFY_HOST __UINT64_C(0x200000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_ALLOW_TRAPS __UINT64_C(0x400000000000)
+#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_DISCOVER __UINT64_C(0x800000000000)
+
+ zbx_uint64_t upd_flags;
+ zbx_uint64_t valuemapid;
+ zbx_uint64_t interfaceid;
+ zbx_uint64_t templateid;
+ zbx_uint64_t master_itemid;
+ zbx_uint64_t master_itemid_orig;
+ char *name;
+ char *key;
+ char *delay;
+ char *history;
+ char *trends;
+ char *trapper_hosts;
+ char *units;
+ char *formula;
+ char *logtimefmt;
+ char *params;
+ char *ipmi_sensor;
+ char *snmp_oid;
+ char *username;
+ char *password;
+ char *publickey;
+ char *privatekey;
+ char *description;
+ char *lifetime;
+ char *jmx_endpoint;
+ char *timeout;
+ char *url;
+ char *query_fields;
+ char *posts;
+ char *status_codes;
+ char *http_proxy;
+ char *headers;
+ char *ssl_cert_file;
+ char *ssl_key_file;
+ char *ssl_key_password;
+ unsigned char verify_peer;
+ unsigned char verify_host;
+ unsigned char follow_redirects;
+ unsigned char post_type;
+ unsigned char retrieve_mode;
+ unsigned char request_method;
+ unsigned char output_format;
+ unsigned char type;
+ unsigned char value_type;
+ unsigned char status;
+ unsigned char authtype;
+ unsigned char flags;
+ unsigned char inventory_link;
+ unsigned char evaltype;
+ unsigned char allow_traps;
+ unsigned char discover;
+ zbx_vector_ptr_t dependent_items;
+ zbx_vector_item_preproc_ptr_t item_preprocs;
+ zbx_vector_item_preproc_ptr_t template_preprocs;
+ zbx_vector_item_tag_ptr_t item_tags;
+ zbx_vector_item_tag_ptr_t template_tags;
+ zbx_vector_item_param_ptr_t item_params;
+ zbx_vector_item_param_ptr_t template_params;
+ zbx_vector_lld_macro_ptr_t item_lld_macros;
+ zbx_vector_lld_macro_ptr_t template_lld_macros;
+}
+zbx_template_item_t;
+
void DBcopy_template_items(zbx_uint64_t hostid, const zbx_vector_uint64_t *templateids);
+#endif
diff --git a/src/libs/zbxdbhigh/template_item.c b/src/libs/zbxdbhigh/template_item.c
index 545adfe590a..27fcdb043cd 100644
--- a/src/libs/zbxdbhigh/template_item.c
+++ b/src/libs/zbxdbhigh/template_item.c
@@ -26,8 +26,10 @@
#include "template.h"
#include "../zbxalgo/vectorimpl.h"
-typedef struct _zbx_template_item_preproc_t zbx_template_item_preproc_t;
-ZBX_PTR_VECTOR_DECL(item_preproc_ptr, zbx_template_item_preproc_t *)
+#include "../../libs/zbxaudit/audit_item.h"
+
+/* typedef struct _zbx_template_item_preproc_t zbx_template_item_preproc_t; */
+/* ZBX_PTR_VECTOR_DECL(item_preproc_ptr, zbx_template_item_preproc_t *) */
struct _zbx_template_item_preproc_t
{
@@ -56,9 +58,6 @@ struct _zbx_template_item_preproc_t
ZBX_PTR_VECTOR_IMPL(item_preproc_ptr, zbx_template_item_preproc_t *)
-typedef struct _zbx_template_item_tag_t zbx_template_item_tag_t;
-ZBX_PTR_VECTOR_DECL(item_tag_ptr, zbx_template_item_tag_t *)
-
struct _zbx_template_item_tag_t
{
zbx_uint64_t itemtagid;
@@ -79,9 +78,6 @@ struct _zbx_template_item_tag_t
ZBX_PTR_VECTOR_IMPL(item_tag_ptr, zbx_template_item_tag_t *)
-typedef struct _zbx_template_item_param_t zbx_template_item_param_t;
-ZBX_PTR_VECTOR_DECL(item_param_ptr, zbx_template_item_param_t *)
-
struct _zbx_template_item_param_t
{
zbx_uint64_t item_parameterid;
@@ -102,9 +98,6 @@ struct _zbx_template_item_param_t
ZBX_PTR_VECTOR_IMPL(item_param_ptr, zbx_template_item_param_t *)
-typedef struct _zbx_template_lld_macro_t zbx_template_lld_macro_t;
-ZBX_PTR_VECTOR_DECL(lld_macro_ptr, zbx_template_lld_macro_t *)
-
struct _zbx_template_lld_macro_t
{
zbx_uint64_t lld_macro_pathid;
@@ -125,122 +118,6 @@ struct _zbx_template_lld_macro_t
ZBX_PTR_VECTOR_IMPL(lld_macro_ptr, zbx_template_lld_macro_t *)
-typedef struct
-{
- zbx_uint64_t itemid;
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_RESET_FLAG __UINT64_C(0x000000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_INTERFACEID __UINT64_C(0x000000000001)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TEMPLATEID __UINT64_C(0x000000000002)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_NAME __UINT64_C(0x000000000004)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TYPE __UINT64_C(0x000000000008)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VALUE_TYPE __UINT64_C(0x000000000010)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_DELAY __UINT64_C(0x000000000020)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_HISTORY __UINT64_C(0x000000000040)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TRENDS __UINT64_C(0x000000000080)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_STATUS __UINT64_C(0x000000000100)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TRAPPER_HOSTS __UINT64_C(0x000000000200)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_UNITS __UINT64_C(0x000000000400)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_FORMULA __UINT64_C(0x000000000800)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_LOGTIMEFMT __UINT64_C(0x000000001000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VALUEMAPID __UINT64_C(0x000000002000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PARAMS __UINT64_C(0x000000004000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_IPMI_SENSOR __UINT64_C(0x000000008000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SNMP_OID __UINT64_C(0x000000010000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_AUTHTYPE __UINT64_C(0x000000020000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_USERNAME __UINT64_C(0x000000040000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PASSWORD __UINT64_C(0x000000080000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PUBLICKEY __UINT64_C(0x000000100000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_PRIVATEKEY __UINT64_C(0x000000200000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_FLAGS __UINT64_C(0x000000400000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_DESCRIPTION __UINT64_C(0x000000800000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_INVENTORY_LINK __UINT64_C(0x000001000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_LIFETIME __UINT64_C(0x000002000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_EVALTYPE __UINT64_C(0x000004000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_JMX_ENDPOINT __UINT64_C(0x000008000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_MASTER_ITEMID __UINT64_C(0x000010000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_TIMEOUT __UINT64_C(0x000020000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_URL __UINT64_C(0x000040000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_QUERY_FIELDS __UINT64_C(0x000080000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_POSTS __UINT64_C(0x000100000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_STATUS_CODES __UINT64_C(0x000200000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_FOLLOW_REDIRECTS __UINT64_C(0x000400000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_POST_TYPE __UINT64_C(0x000800000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_HTTP_PROXY __UINT64_C(0x001000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_HEADERS __UINT64_C(0x002000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_RETRIEVE_MODE __UINT64_C(0x004000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_REQUEST_METHOD __UINT64_C(0x008000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_OUTPUT_FORMAT __UINT64_C(0x010000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SSL_CERT_FILE __UINT64_C(0x020000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SSL_KEY_FILE __UINT64_C(0x040000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_SSL_KEY_PASSWORD __UINT64_C(0x080000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VERIFY_PEER __UINT64_C(0x100000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_VERIFY_HOST __UINT64_C(0x200000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_ALLOW_TRAPS __UINT64_C(0x400000000000)
-#define ZBX_FLAG_TEMPLATE_ITEM_UPDATE_DISCOVER __UINT64_C(0x800000000000)
-
- zbx_uint64_t upd_flags;
- zbx_uint64_t valuemapid;
- zbx_uint64_t interfaceid;
- zbx_uint64_t templateid;
- zbx_uint64_t master_itemid;
- zbx_uint64_t master_itemid_orig;
- char *name;
- char *key;
- char *delay;
- char *history;
- char *trends;
- char *trapper_hosts;
- char *units;
- char *formula;
- char *logtimefmt;
- char *params;
- char *ipmi_sensor;
- char *snmp_oid;
- char *username;
- char *password;
- char *publickey;
- char *privatekey;
- char *description;
- char *lifetime;
- char *jmx_endpoint;
- char *timeout;
- char *url;
- char *query_fields;
- char *posts;
- char *status_codes;
- char *http_proxy;
- char *headers;
- char *ssl_cert_file;
- char *ssl_key_file;
- char *ssl_key_password;
- unsigned char verify_peer;
- unsigned char verify_host;
- unsigned char follow_redirects;
- unsigned char post_type;
- unsigned char retrieve_mode;
- unsigned char request_method;
- unsigned char output_format;
- unsigned char type;
- unsigned char value_type;
- unsigned char status;
- unsigned char authtype;
- unsigned char flags;
- unsigned char inventory_link;
- unsigned char evaltype;
- unsigned char allow_traps;
- unsigned char discover;
- zbx_vector_ptr_t dependent_items;
- zbx_vector_item_preproc_ptr_t item_preprocs;
- zbx_vector_item_preproc_ptr_t template_preprocs;
- zbx_vector_item_tag_ptr_t item_tags;
- zbx_vector_item_tag_ptr_t template_tags;
- zbx_vector_item_param_ptr_t item_params;
- zbx_vector_item_param_ptr_t template_params;
- zbx_vector_lld_macro_ptr_t item_lld_macros;
- zbx_vector_lld_macro_ptr_t template_lld_macros;
-}
-zbx_template_item_t;
-
/* lld rule condition */
typedef struct
{
@@ -1179,6 +1056,9 @@ static void save_template_item(zbx_uint64_t hostid, zbx_uint64_t *itemid, zbx_te
zbx_db_insert_add_values(db_insert_irtdata, *itemid);
+ zbx_audit_item_create_entry(AUDIT_ACTION_ADD, *itemid, item->name);
+ zbx_audit_item_add_data(*itemid, item, hostid);
+
item->itemid = (*itemid)++;
}
dependent:
diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am
index dc7bcdcf5f4..f14b87dd70c 100644
--- a/src/zabbix_server/Makefile.am
+++ b/src/zabbix_server/Makefile.am
@@ -24,8 +24,8 @@ SUBDIRS = \
availability \
lld \
reporter \
- service
-
+ service
+
sbin_PROGRAMS = zabbix_server
noinst_LIBRARIES = libzbxserver.a
@@ -113,6 +113,7 @@ zabbix_server_LDADD = \
$(top_builddir)/src/libs/zbxserver/libzbxserver_server.a \
$(top_builddir)/src/libs/zbxvault/libzbxvault.a \
$(top_builddir)/src/libs/zbxavailability/libzbxavailability.a \
+ $(top_builddir)/src/libs/zbxaudit/libzbxaudit.a \
$(top_builddir)/src/libs/zbxservice/libzbxservice.a
if HAVE_IPMI
diff --git a/tests/libs/zbxdbcache/Makefile.am b/tests/libs/zbxdbcache/Makefile.am
index 3fc847bd7e8..8ff359b9a6f 100644
--- a/tests/libs/zbxdbcache/Makefile.am
+++ b/tests/libs/zbxdbcache/Makefile.am
@@ -72,6 +72,7 @@ CACHE_LIBS = \
$(top_srcdir)/tests/libzbxmocktest.a \
$(top_srcdir)/src/libs/zbxvault/libzbxvault.a \
$(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a \
+ $(top_srcdir)/src/libs/zbxaudit/libzbxaudit.a \
$(top_srcdir)/tests/libzbxmockdata.a
COMMON_WRAP_FUNCS = \
diff --git a/tests/libs/zbxdbhigh/Makefile.am b/tests/libs/zbxdbhigh/Makefile.am
index 4470dd97cce..c7db63c6e16 100644
--- a/tests/libs/zbxdbhigh/Makefile.am
+++ b/tests/libs/zbxdbhigh/Makefile.am
@@ -41,6 +41,7 @@ COMMON_LIB = \
$(top_srcdir)/src/libs/zbxconf/libzbxconf.a \
$(top_srcdir)/src/libs/zbxvault/libzbxvault.a \
$(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a \
+ $(top_srcdir)/src/libs/zbxaudit/libzbxaudit.a \
$(top_srcdir)/tests/libzbxmocktest.a \
$(top_srcdir)/tests/libzbxmockdata.a
@@ -86,6 +87,7 @@ SERVER_COMMON_LIB = \
$(top_srcdir)/src/libs/zbxservice/libzbxservice.a \
$(top_srcdir)/src/zabbix_server/service/libservice.a \
$(top_srcdir)/src/libs/zbxipcservice/libzbxipcservice.a \
+ $(top_srcdir)/src/libs/zbxaudit/libzbxaudit.a \
$(top_srcdir)/src/libs/zbxtrends/libzbxtrends.a \
$(COMMON_LIB)
diff --git a/tests/libs/zbxserver/Makefile.am b/tests/libs/zbxserver/Makefile.am
index 3d877ef0976..311a00b857f 100755
--- a/tests/libs/zbxserver/Makefile.am
+++ b/tests/libs/zbxserver/Makefile.am
@@ -83,7 +83,8 @@ COMMON_LIB_FILES = \
$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
$(top_srcdir)/src/libs/zbxdbhigh/libzbxdbhigh.a \
$(top_srcdir)/src/libs/zbxvault/libzbxvault.a \
- $(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a
+ $(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a \
+ $(top_srcdir)/src/libs/zbxaudit/libzbxaudit.a
COMMON_COMPILER_FLAGS = -I@top_srcdir@/tests