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>2021-10-19 10:59:54 +0300
committerAndris Zeila <andris.zeila@zabbix.com>2021-10-19 10:59:54 +0300
commit1f512918f4175dd1c21d634c4476ea5ba94ce1fa (patch)
tree80c2a030ff3b879a267347e2db7fdc188424861d /src/libs/zbxaudit
parent646b3bc1315055ddebbb93cfe50dfd98f2de44b9 (diff)
parentc8fab6d8ab863c196370d3d145d72106ff4e33c6 (diff)
.......... [ZBXNEXT-6923] merged branch 'master' of ssh://git.zabbix.lan:7999/zbx/zabbix into feature/ZBXNEXT-6923-5.5
Diffstat (limited to 'src/libs/zbxaudit')
-rw-r--r--src/libs/zbxaudit/audit.c218
-rw-r--r--src/libs/zbxaudit/audit.h58
-rw-r--r--src/libs/zbxaudit/audit_graph.c133
-rw-r--r--src/libs/zbxaudit/audit_graph.h13
-rw-r--r--src/libs/zbxaudit/audit_ha.c10
-rw-r--r--src/libs/zbxaudit/audit_host.c388
-rw-r--r--src/libs/zbxaudit/audit_host.h16
-rw-r--r--src/libs/zbxaudit/audit_httptest.c148
-rw-r--r--src/libs/zbxaudit/audit_httptest.h5
-rw-r--r--src/libs/zbxaudit/audit_item.c461
-rw-r--r--src/libs/zbxaudit/audit_settings.c3
-rw-r--r--src/libs/zbxaudit/audit_trigger.c139
-rw-r--r--src/libs/zbxaudit/audit_trigger.h13
13 files changed, 1020 insertions, 585 deletions
diff --git a/src/libs/zbxaudit/audit.c b/src/libs/zbxaudit/audit.c
index 061f53bd15c..0ae7b0907e9 100644
--- a/src/libs/zbxaudit/audit.c
+++ b/src/libs/zbxaudit/audit.c
@@ -40,22 +40,25 @@ zbx_hashset_t *zbx_get_audit_hashset(void)
return &zbx_audit;
}
-zbx_audit_entry_t *zbx_audit_entry_init(zbx_uint64_t id, const char *name, int audit_action, int resource_type)
+zbx_audit_entry_t *zbx_audit_entry_init(zbx_uint64_t id, const int id_table, const char *name, int audit_action,
+ int resource_type)
{
zbx_audit_entry_t *audit_entry;
audit_entry = (zbx_audit_entry_t*)zbx_malloc(NULL, sizeof(zbx_audit_entry_t));
audit_entry->id = id;
audit_entry->cuid = NULL;
+ audit_entry->id_table = id_table;
audit_entry->name = zbx_strdup(NULL, name);
audit_entry->audit_action = audit_action;
audit_entry->resource_type = resource_type;
+ zbx_new_cuid(audit_entry->audit_cuid);
zbx_json_init(&(audit_entry->details_json), ZBX_JSON_STAT_BUF_LEN);
return audit_entry;
}
-zbx_audit_entry_t *zbx_audit_entry_init_cuid(const char *cuid, const char *name, int audit_action,
+zbx_audit_entry_t *zbx_audit_entry_init_cuid(const char *cuid, const int id_table, const char *name, int audit_action,
int resource_type)
{
zbx_audit_entry_t *audit_entry;
@@ -63,9 +66,11 @@ zbx_audit_entry_t *zbx_audit_entry_init_cuid(const char *cuid, const char *name,
audit_entry = (zbx_audit_entry_t*)zbx_malloc(NULL, sizeof(zbx_audit_entry_t));
audit_entry->id = 0;
audit_entry->cuid = zbx_strdup(NULL, cuid);
+ audit_entry->id_table = id_table;
audit_entry->name = zbx_strdup(NULL, name);
audit_entry->audit_action = audit_action;
audit_entry->resource_type = resource_type;
+ zbx_new_cuid(audit_entry->audit_cuid);
zbx_json_init(&(audit_entry->details_json), ZBX_JSON_STAT_BUF_LEN);
return audit_entry;
@@ -168,10 +173,10 @@ int zbx_auditlog_global_script(unsigned char script_type, unsigned char script_e
zbx_uint64_t proxy_hostid, zbx_uint64_t userid, const char *username, const char *clientip,
const char *output, const char *error)
{
- int ret = SUCCEED;
- char auditid_cuid[CUID_LEN], execute_on_s[MAX_ID_LEN + 1], hostid_s[MAX_ID_LEN + 1],
- eventid_s[MAX_ID_LEN + 1], proxy_hostid_s[MAX_ID_LEN + 1];
-
+ int ret = SUCCEED;
+ char auditid_cuid[CUID_LEN], execute_on_s[MAX_ID_LEN + 1], hostid_s[MAX_ID_LEN + 1],
+ eventid_s[MAX_ID_LEN + 1], proxy_hostid_s[MAX_ID_LEN + 1];
+ char *details_esc;
struct zbx_json details_json;
zbx_config_t cfg;
@@ -209,27 +214,24 @@ int zbx_auditlog_global_script(unsigned char script_type, unsigned char script_e
append_str_json(&details_json, AUDIT_DETAILS_ACTION_ADD, "script.command", script_command_orig);
if (NULL != output)
- {
- char *output_esc;
-
- output_esc = zbx_strdup(NULL, output);
- zbx_json_escape(&output_esc);
- append_str_json(&details_json, AUDIT_DETAILS_ACTION_ADD, "script.output", output_esc);
- zbx_free(output_esc);
- }
+ append_str_json(&details_json, AUDIT_DETAILS_ACTION_ADD, "script.output", output);
if (NULL != error)
append_str_json(&details_json, AUDIT_DETAILS_ACTION_ADD, "script.error", error);
+ details_esc = DBdyn_escape_string(details_json.buffer);
+
if (ZBX_DB_OK > DBexecute("insert into auditlog (auditid,userid,username,clock,action,ip,resourceid,"
"resourcename,resourcetype,recordsetid,details) values ('%s'," ZBX_FS_UI64 ",'%s',%d,'%d','%s',"
ZBX_FS_UI64 ",'%s',%d,'%s','%s')", auditid_cuid, userid, username, (int)time(NULL),
AUDIT_ACTION_EXECUTE, clientip, hostid, hostname, AUDIT_RESOURCE_SCRIPT, auditid_cuid,
- details_json.buffer))
+ details_esc))
{
ret = FAIL;
}
+ zbx_free(details_esc);
+
zbx_json_free(&details_json);
out:
zabbix_log(LOG_LEVEL_TRACE, "End of %s():%s", __func__, zbx_result_string(ret));
@@ -239,15 +241,15 @@ out:
static unsigned zbx_audit_hash_func(const void *data)
{
- const zbx_audit_entry_t * const *audit_entry = (const zbx_audit_entry_t * const *)data;
zbx_hash_t hash;
+ const zbx_audit_entry_t * const *audit_entry = (const zbx_audit_entry_t * const *)data;
hash = ZBX_DEFAULT_UINT64_HASH_FUNC(&(*audit_entry)->id);
if (NULL != (*audit_entry)->cuid)
hash = ZBX_DEFAULT_STRING_HASH_ALGO((*audit_entry)->cuid, strlen((*audit_entry)->cuid), hash);
- return hash;
+ return ZBX_DEFAULT_UINT64_HASH_ALGO(&((*audit_entry)->id_table), sizeof((*audit_entry)->id_table), hash);
}
static int zbx_audit_compare_func(const void *d1, const void *d2)
@@ -256,6 +258,7 @@ static int zbx_audit_compare_func(const void *d1, const void *d2)
const zbx_audit_entry_t * const *audit_entry_2 = (const zbx_audit_entry_t * const *)d2;
ZBX_RETURN_IF_NOT_EQUAL((*audit_entry_1)->id, (*audit_entry_2)->id);
+ ZBX_RETURN_IF_NOT_EQUAL((*audit_entry_1)->id_table, (*audit_entry_2)->id_table);
return zbx_strcmp_null((*audit_entry_1)->cuid, (*audit_entry_2)->cuid);
}
@@ -299,7 +302,7 @@ int zbx_audit_initialized(void)
void zbx_audit_flush(void)
{
- char audit_cuid[CUID_LEN], recsetid_cuid[CUID_LEN];
+ char recsetid_cuid[CUID_LEN];
zbx_hashset_iter_t iter;
zbx_audit_entry_t **audit_entry;
zbx_db_insert_t db_insert_audit;
@@ -314,15 +317,18 @@ void zbx_audit_flush(void)
while (NULL != (audit_entry = (zbx_audit_entry_t **)zbx_hashset_iter_next(&iter)))
{
- zbx_new_cuid(audit_cuid);
if (AUDIT_ACTION_DELETE == (*audit_entry)->audit_action ||
0 != strcmp((*audit_entry)->details_json.buffer, "{}"))
{
- zbx_db_insert_add_values(&db_insert_audit, audit_cuid, AUDIT_USERID, AUDIT_USERNAME,
- (int)time(NULL), (*audit_entry)->audit_action, AUDIT_IP, (*audit_entry)->id,
- (*audit_entry)->name, (*audit_entry)->resource_type,
- recsetid_cuid, 0 == strcmp((*audit_entry)->details_json.buffer, "{}") ? "" :
- (*audit_entry)->details_json.buffer);
+ char *details_esc;
+
+ details_esc = DBdyn_escape_string((*audit_entry)->details_json.buffer);
+
+ zbx_db_insert_add_values(&db_insert_audit, (*audit_entry)->audit_cuid, AUDIT_USERID,
+ AUDIT_USERNAME, (int)time(NULL), (*audit_entry)->audit_action, AUDIT_IP,
+ (*audit_entry)->id, (*audit_entry)->name, (*audit_entry)->resource_type,
+ recsetid_cuid, 0 == strcmp(details_esc, "{}") ? "" : details_esc);
+ zbx_free(details_esc);
}
}
@@ -334,7 +340,7 @@ void zbx_audit_flush(void)
int zbx_audit_flush_once(void)
{
- char audit_cuid[CUID_LEN], recsetid_cuid[CUID_LEN];
+ char recsetid_cuid[CUID_LEN];
int ret = ZBX_DB_OK;
zbx_hashset_iter_t iter;
zbx_audit_entry_t **audit_entry;
@@ -347,7 +353,7 @@ int zbx_audit_flush_once(void)
while (NULL != (audit_entry = (zbx_audit_entry_t **)zbx_hashset_iter_next(&iter)))
{
- char id[ZBX_MAX_UINT64_LEN + 1], *pfield, *pvalue, *name_esc;
+ char id[ZBX_MAX_UINT64_LEN + 1], *pfield, *pvalue, *name_esc, *details_esc;
if (AUDIT_ACTION_DELETE != (*audit_entry)->audit_action &&
0 == strcmp((*audit_entry)->details_json.buffer, "{}"))
@@ -355,8 +361,6 @@ int zbx_audit_flush_once(void)
continue;
}
- zbx_new_cuid(audit_cuid);
-
if (0 != (*audit_entry)->id)
{
zbx_snprintf(id, sizeof(id), ZBX_FS_UI64, (*audit_entry)->id);
@@ -370,15 +374,16 @@ int zbx_audit_flush_once(void)
}
name_esc = DBdyn_escape_string((*audit_entry)->name);
+ details_esc = DBdyn_escape_string((*audit_entry)->details_json.buffer);
ret = DBexecute_once("insert into auditlog (auditid,userid,username,"
"clock,action,ip,%s,resourcename,resourcetype,recordsetid,details) values"
" ('%s',%d,'%s','%d','%d','%s','%s','%s',%d,'%s','%s')",
- pfield, audit_cuid, AUDIT_USERID, AUDIT_USERNAME, (int)time(NULL),
+ pfield, (*audit_entry)->audit_cuid, AUDIT_USERID, AUDIT_USERNAME, (int)time(NULL),
(*audit_entry)->audit_action, AUDIT_IP, pvalue, name_esc, (*audit_entry)->resource_type,
- recsetid_cuid, 0 == strcmp((*audit_entry)->details_json.buffer, "{}") ? "" :
- (*audit_entry)->details_json.buffer);
+ recsetid_cuid, 0 == strcmp(details_esc, "{}") ? "" : details_esc);
+ zbx_free(details_esc);
zbx_free(name_esc);
if (ZBX_DB_OK > ret)
@@ -390,15 +395,65 @@ int zbx_audit_flush_once(void)
return ret;
}
-void zbx_audit_update_json_append_string(const zbx_uint64_t id, const char *audit_op, const char *key,
- const char *value)
+static int audit_field_default(const char *table_name, const char *field_name, const char *value, uint64_t id)
+{
+ static ZBX_THREAD_LOCAL char cached_table_name[ZBX_TABLENAME_LEN_MAX];
+ static ZBX_THREAD_LOCAL const ZBX_TABLE *table = NULL;
+ const ZBX_FIELD *field;
+
+ if (NULL == table_name)
+ return FAIL;
+
+ /* Often 'table_name' stays the same and only 'field_name' changes in successive calls of this function. */
+ /* Here a simple caching of DBget_table() result is implemented. We rely on static array 'cached_table_name' */
+ /* initialization with zero bytes, i.e. with empty string. */
+
+ if ('\0' == cached_table_name[0] || 0 != strcmp(cached_table_name, table_name))
+ {
+ if (NULL == (table = DBget_table(table_name)))
+ {
+ zabbix_log(LOG_LEVEL_CRIT, "%s(): cannot find table '%s'", __func__, table_name);
+ THIS_SHOULD_NEVER_HAPPEN;
+ return FAIL;
+ }
+
+ zbx_strlcpy(cached_table_name, table_name, sizeof(cached_table_name));
+ }
+
+ if (NULL == (field = DBget_field(table, field_name)))
+ {
+ zabbix_log(LOG_LEVEL_CRIT, "%s(): table '%s', cannot find field '%s'", __func__, table_name,
+ field_name);
+ THIS_SHOULD_NEVER_HAPPEN;
+ return FAIL;
+ }
+
+ if (NULL != field->default_value)
+ {
+ if (NULL != value && (0 == strcmp(value, field->default_value) ||
+ (ZBX_TYPE_FLOAT == field->type && SUCCEED == zbx_double_compare(atof(value),
+ atof(field->default_value)))))
+ {
+ return SUCCEED;
+ }
+ }
+ else if (NULL == value || (ZBX_TYPE_ID == field->type && 0 == id))
+ return SUCCEED;
+
+ return FAIL;
+}
+
+void zbx_audit_update_json_append_string(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, const char *value, const char *table, const char *field)
{
zbx_audit_entry_t local_audit_entry, **found_audit_entry;
zbx_audit_entry_t *local_audit_entry_x = &local_audit_entry;
- local_audit_entry.id = id;
- local_audit_entry.cuid = NULL;
+ if (SUCCEED == audit_field_default(table, field, value, 0))
+ return;
+ local_audit_entry.id = id;
+ local_audit_entry.id_table = id_table;
found_audit_entry = (zbx_audit_entry_t**)zbx_hashset_search(&zbx_audit, &(local_audit_entry_x));
if (NULL == found_audit_entry)
@@ -410,15 +465,41 @@ void zbx_audit_update_json_append_string(const zbx_uint64_t id, const char *audi
append_str_json(&((*found_audit_entry)->details_json), audit_op, key, value);
}
-void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const char *audit_op, const char *key,
- uint64_t value)
+void zbx_audit_update_json_append_string_secret(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, const char *value, const char *table, const char *field)
{
zbx_audit_entry_t local_audit_entry, **found_audit_entry;
zbx_audit_entry_t *local_audit_entry_x = &local_audit_entry;
+ if (SUCCEED == audit_field_default(table, field, value, 0))
+ return;
+
local_audit_entry.id = id;
- local_audit_entry.cuid = NULL;
+ local_audit_entry.id_table = id_table;
+ found_audit_entry = (zbx_audit_entry_t**)zbx_hashset_search(&zbx_audit, &(local_audit_entry_x));
+
+ if (NULL == found_audit_entry)
+ {
+ THIS_SHOULD_NEVER_HAPPEN;
+ exit(EXIT_FAILURE);
+ }
+
+ append_str_json(&((*found_audit_entry)->details_json), audit_op, key, ZBX_MACRO_SECRET_MASK);
+}
+
+void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, uint64_t value, const char *table, const char *field)
+{
+ char buffer[MAX_ID_LEN];
+ zbx_audit_entry_t local_audit_entry, **found_audit_entry;
+ zbx_audit_entry_t *local_audit_entry_x = &local_audit_entry;
+
+ zbx_snprintf(buffer, sizeof(buffer), ZBX_FS_UI64, value);
+ if (SUCCEED == audit_field_default(table, field, buffer, value))
+ return;
+ local_audit_entry.id = id;
+ local_audit_entry.id_table = id_table;
found_audit_entry = (zbx_audit_entry_t**)zbx_hashset_search(&zbx_audit, &(local_audit_entry_x));
if (NULL == found_audit_entry)
@@ -435,8 +516,7 @@ void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const char *audi
zbx_audit_entry_t *local_audit_entry_x = &local_audit_entry; \
\
local_audit_entry.id = id; \
- local_audit_entry.cuid = NULL; \
- \
+ local_audit_entry.id_table = id_table; \
found_audit_entry = (zbx_audit_entry_t**)zbx_hashset_search(&zbx_audit, \
&(local_audit_entry_x)); \
if (NULL == found_audit_entry) \
@@ -445,64 +525,90 @@ void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const char *audi
exit(EXIT_FAILURE); \
} \
-void zbx_audit_update_json_append_no_value(const zbx_uint64_t id, const char *audit_op, const char *key)
+void zbx_audit_update_json_append_no_value(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key)
{
PREPARE_UPDATE_JSON_APPEND_OP();
append_json_no_value(&((*found_audit_entry)->details_json), audit_op, key);
}
-void zbx_audit_update_json_append_int(const zbx_uint64_t id, const char *audit_op, const char *key, int value)
+void zbx_audit_update_json_append_int(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, int value, const char *table, const char *field)
{
- PREPARE_UPDATE_JSON_APPEND_OP();
- append_int_json(&((*found_audit_entry)->details_json), audit_op, key, value);
+ char buffer[MAX_ID_LEN];
+
+ zbx_snprintf(buffer, sizeof(buffer), "%d", value);
+
+ if (SUCCEED == audit_field_default(table, field, buffer, 0))
+ {
+ return;
+ }
+ else
+ {
+ PREPARE_UPDATE_JSON_APPEND_OP();
+ append_int_json(&((*found_audit_entry)->details_json), audit_op, key, value);
+ }
}
-void zbx_audit_update_json_append_double(const zbx_uint64_t id, const char *audit_op, const char *key, double value)
+void zbx_audit_update_json_append_double(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, double value, const char *table, const char *field)
{
- PREPARE_UPDATE_JSON_APPEND_OP();
- append_double_json(&((*found_audit_entry)->details_json), audit_op, key, value);
+ char buffer[MAX_ID_LEN];
+
+ zbx_snprintf(buffer, sizeof(buffer), ZBX_FS_DBL, value);
+
+ if (SUCCEED == audit_field_default(table, field, buffer, 0))
+ {
+ return;
+ }
+ else
+ {
+ PREPARE_UPDATE_JSON_APPEND_OP();
+ append_double_json(&((*found_audit_entry)->details_json), audit_op, key, value);
+ }
}
-void zbx_audit_update_json_update_string(const zbx_uint64_t id, const char *key, const char *value_old,
- const char *value_new)
+void zbx_audit_update_json_update_string(const zbx_uint64_t id, const int id_table, const char *key,
+ const char *value_old, const char *value_new)
{
PREPARE_UPDATE_JSON_APPEND_OP();
update_str_json(&((*found_audit_entry)->details_json), key, value_old, value_new);
}
-void zbx_audit_update_json_update_uint64(const zbx_uint64_t id, const char *key, uint64_t value_old,
- uint64_t value_new)
+void zbx_audit_update_json_update_uint64(const zbx_uint64_t id, const int id_table, const char *key,
+ uint64_t value_old, uint64_t value_new)
{
PREPARE_UPDATE_JSON_APPEND_OP();
update_uint64_json(&((*found_audit_entry)->details_json), key, value_old, value_new);
}
-void zbx_audit_update_json_update_int(const zbx_uint64_t id, const char *key, int value_old,
+void zbx_audit_update_json_update_int(const zbx_uint64_t id, const int id_table, const char *key, int value_old,
int value_new)
{
PREPARE_UPDATE_JSON_APPEND_OP();
update_int_json(&((*found_audit_entry)->details_json), key, value_old, value_new);
}
-void zbx_audit_update_json_update_double(const zbx_uint64_t id, const char *key, double value_old,
- double value_new)
+void zbx_audit_update_json_update_double(const zbx_uint64_t id, const int id_table, const char *key,
+ double value_old, double value_new)
{
PREPARE_UPDATE_JSON_APPEND_OP();
update_double_json(&((*found_audit_entry)->details_json), key, value_old, value_new);
}
-void zbx_audit_update_json_delete(const zbx_uint64_t id, const char *audit_op, const char *key)
+void zbx_audit_update_json_delete(const zbx_uint64_t id, const int id_table, const char *audit_op, const char *key)
{
PREPARE_UPDATE_JSON_APPEND_OP();
delete_json(&((*found_audit_entry)->details_json), audit_op, key);
}
-zbx_audit_entry_t *zbx_audit_get_entry(zbx_uint64_t id, const char *cuid)
+zbx_audit_entry_t *zbx_audit_get_entry(zbx_uint64_t id, const char *cuid, int id_table)
{
zbx_audit_entry_t local_audit_entry, *plocal_audit_entry = &local_audit_entry, **paudit_entry;
local_audit_entry.id = id;
local_audit_entry.cuid = (char *)cuid;
+ local_audit_entry.id_table = id_table;
if (NULL == (paudit_entry = (zbx_audit_entry_t**)zbx_hashset_search(&zbx_audit, &plocal_audit_entry)))
{
diff --git a/src/libs/zbxaudit/audit.h b/src/libs/zbxaudit/audit.h
index 89f9adcfff2..3c742f96cfc 100644
--- a/src/libs/zbxaudit/audit.h
+++ b/src/libs/zbxaudit/audit.h
@@ -31,8 +31,6 @@
#define AUDIT_DETAILS_ACTION_UPDATE "update"
#define AUDIT_DETAILS_ACTION_DELETE "delete"
-#define AUDIT_SECRET_MASK "******"
-
#define AUDIT_DETAILS_KEY_LEN 100
#define AUDIT_RESOURCE_HOST 4
@@ -53,6 +51,15 @@
#define AUDIT_RESOURCE_HA_NODE 47
+#define AUDIT_HOST_ID 1
+#define AUDIT_HOSTGRP_ID 2
+#define AUDIT_ITEM_ID 3
+#define AUDIT_TRIGGER_ID 4
+#define AUDIT_GRAPH_ID 5
+#define AUDIT_HTTPTEST_ID 6
+#define AUDIT_HA_NODE_ID 7
+#define AUDIT_CONFIG_ID 8
+
#define RETURN_IF_AUDIT_OFF() \
if (ZBX_AUDITLOG_ENABLED != zbx_get_audit_mode()) \
return \
@@ -64,17 +71,19 @@ typedef struct zbx_audit_entry
{
zbx_uint64_t id;
char *cuid;
+ int id_table;
char *name;
struct zbx_json details_json;
int audit_action;
int resource_type;
+ char audit_cuid[CUID_LEN];
}
zbx_audit_entry_t;
-zbx_audit_entry_t *zbx_audit_entry_init(zbx_uint64_t id, const char *name, int audit_action, int resource_type);
-zbx_audit_entry_t *zbx_audit_entry_init_cuid(const char *cuid, const char *name, int audit_action,
+zbx_audit_entry_t *zbx_audit_entry_init(zbx_uint64_t id, const int id_table, const char *name, int audit_action,
int resource_type);
-
+zbx_audit_entry_t *zbx_audit_entry_init_cuid(const char *cuid, const int id_table,const char *name,
+ int audit_action, int resource_type);
int zbx_auditlog_global_script(unsigned char script_type, unsigned char script_execute_on,
const char *script_command_orig, zbx_uint64_t hostid, const char *hostname, zbx_uint64_t eventid,
@@ -86,22 +95,29 @@ void zbx_audit_clean(void);
void zbx_audit_flush(void);
int zbx_audit_flush_once(void);
int zbx_audit_initialized(void);
-void zbx_audit_update_json_append_string(const zbx_uint64_t id, const char *audit_op, const char *key,
- const char *value);
-void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const char *audit_op, const char *key,
- uint64_t value);
-void zbx_audit_update_json_append_no_value(const zbx_uint64_t id, const char *audit_op, const char *key);
-void zbx_audit_update_json_append_int(const zbx_uint64_t id, const char *audit_op, const char *key, int value);
-void zbx_audit_update_json_append_double(const zbx_uint64_t id, const char *audit_op, const char *key, double value);
-void zbx_audit_update_json_update_string(const zbx_uint64_t id, const char *key, const char *value_old,
- const char *value_new);
-void zbx_audit_update_json_update_uint64(const zbx_uint64_t id, const char *key, uint64_t value_old,
- uint64_t value_new);
-void zbx_audit_update_json_update_int(const zbx_uint64_t id, const char *key, int value_old, int value_new);
-void zbx_audit_update_json_update_double(const zbx_uint64_t id, const char *key, double value_old, double value_new);
-void zbx_audit_update_json_delete(const zbx_uint64_t id, const char *audit_op, const char *key);
-
-zbx_audit_entry_t *zbx_audit_get_entry(zbx_uint64_t id, const char *cuid);
+void zbx_audit_update_json_append_string(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, const char *value, const char *table, const char *field);
+void zbx_audit_update_json_append_string_secret(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, const char *value, const char *table, const char *field);
+void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, uint64_t value, const char *table, const char *field);
+void zbx_audit_update_json_append_no_value(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key);
+void zbx_audit_update_json_append_int(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, int value, const char *table, const char *field);
+void zbx_audit_update_json_append_double(const zbx_uint64_t id, const int id_table, const char *audit_op,
+ const char *key, double value, const char *table, const char *field);
+void zbx_audit_update_json_update_string(const zbx_uint64_t id, const int id_table, const char *key,
+ const char *value_old, const char *value_new);
+void zbx_audit_update_json_update_uint64(const zbx_uint64_t id, const int id_table, const char *key,
+ uint64_t value_old, uint64_t value_new);
+void zbx_audit_update_json_update_int(const zbx_uint64_t id, const int id_table, const char *key, int value_old,
+ int value_new);
+void zbx_audit_update_json_update_double(const zbx_uint64_t id, const int id_table, const char *key,
+ double value_old, double value_new);
+void zbx_audit_update_json_delete(const zbx_uint64_t id, const int id_table, const char *audit_op, const char *key);
+
+zbx_audit_entry_t *zbx_audit_get_entry(zbx_uint64_t id, const char *cuid, int id_table);
void zbx_audit_entry_append_int(zbx_audit_entry_t *entry, int audit_op, const char *key, ...);
void zbx_audit_entry_append_string(zbx_audit_entry_t *entry, int audit_op, const char *key, ...);
diff --git a/src/libs/zbxaudit/audit_graph.c b/src/libs/zbxaudit/audit_graph.c
index 3d7d1efc232..b4971eda8b8 100644
--- a/src/libs/zbxaudit/audit_graph.c
+++ b/src/libs/zbxaudit/audit_graph.c
@@ -52,6 +52,7 @@ void zbx_audit_graph_create_entry(int audit_action, zbx_uint64_t graphid, const
resource_type = graph_flag_to_resource_type(flags);
local_audit_graph_entry.id = graphid;
+ local_audit_graph_entry.id_table = AUDIT_GRAPH_ID;
found_audit_graph_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(),
&(local_audit_graph_entry_x));
@@ -60,25 +61,26 @@ void zbx_audit_graph_create_entry(int audit_action, zbx_uint64_t graphid, const
{
zbx_audit_entry_t *local_audit_graph_entry_insert;
- local_audit_graph_entry_insert = zbx_audit_entry_init(graphid, name, audit_action, resource_type);
+ local_audit_graph_entry_insert = zbx_audit_entry_init(graphid, AUDIT_GRAPH_ID, name, audit_action,
+ resource_type);
zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_graph_entry_insert,
sizeof(local_audit_graph_entry_insert));
if (AUDIT_ACTION_ADD == audit_action)
{
- zbx_audit_update_json_append_uint64(graphid, AUDIT_DETAILS_ACTION_ADD, GR_OR_GRP(graphid),
- graphid);
+ zbx_audit_update_json_append_uint64(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD,
+ GR_OR_GRP(graphid), graphid, "graphs", "graphid");
}
}
}
-void zbx_audit_graph_update_json_add_data(zbx_uint64_t graphid, const char *graph_copy_name, int width, int height,
+void zbx_audit_graph_update_json_add_data(zbx_uint64_t graphid, const char *name, int width, int height,
double yaxismin, double yaxismax, zbx_uint64_t templateid, int show_work_period, int show_triggers,
int graphtype, int show_legend, int show_3d, double percent_left, double percent_right, int ymin_type,
int ymax_type, zbx_uint64_t ymin_itemid, zbx_uint64_t ymax_itemid, int flags, int discover)
{
- char audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_graph_copy_name[AUDIT_DETAILS_KEY_LEN],
+ char audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_name[AUDIT_DETAILS_KEY_LEN],
audit_key_width[AUDIT_DETAILS_KEY_LEN], audit_key_height[AUDIT_DETAILS_KEY_LEN],
audit_key_yaxismin[AUDIT_DETAILS_KEY_LEN], audit_key_yaxismax[AUDIT_DETAILS_KEY_LEN],
audit_key_templateid[AUDIT_DETAILS_KEY_LEN], audit_key_show_work_period[AUDIT_DETAILS_KEY_LEN],
@@ -97,7 +99,7 @@ void zbx_audit_graph_update_json_add_data(zbx_uint64_t graphid, const char *grap
zbx_snprintf(audit_key, sizeof(audit_key), (AUDIT_RESOURCE_GRAPH == resource_type) ? "graph" :
"graphprototype");
#define AUDIT_KEY_SNPRINTF(r) zbx_snprintf(audit_key_##r, sizeof(audit_key_##r), GR_OR_GRP(r));
- AUDIT_KEY_SNPRINTF(graph_copy_name)
+ AUDIT_KEY_SNPRINTF(name)
AUDIT_KEY_SNPRINTF(width)
AUDIT_KEY_SNPRINTF(height)
AUDIT_KEY_SNPRINTF(yaxismin)
@@ -117,43 +119,51 @@ void zbx_audit_graph_update_json_add_data(zbx_uint64_t graphid, const char *grap
AUDIT_KEY_SNPRINTF(flags)
AUDIT_KEY_SNPRINTF(discover)
#undef AUDIT_KEY_SNPRINTF
- zbx_audit_update_json_append_no_value(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key);
-#define ADD_STR(r) zbx_audit_update_json_append_string(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_UINT64(r) zbx_audit_update_json_append_uint64(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_INT(r) zbx_audit_update_json_append_int(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_DOUBLE(r) zbx_audit_update_json_append_double(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
- ADD_STR(graph_copy_name)
- ADD_INT(width)
- ADD_INT(height)
- ADD_DOUBLE(yaxismin)
- ADD_DOUBLE(yaxismax)
- ADD_UINT64(templateid)
- ADD_INT(show_work_period)
- ADD_INT(show_triggers)
- ADD_INT(graphtype)
- ADD_INT(show_legend)
- ADD_INT(show_3d)
- ADD_DOUBLE(percent_left)
- ADD_DOUBLE(percent_right)
- ADD_INT(ymin_type)
- ADD_INT(ymax_type)
- ADD_UINT64(ymin_itemid)
- ADD_UINT64(ymax_itemid)
- ADD_INT(flags)
- ADD_INT(discover)
+ zbx_audit_update_json_append_no_value(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+#define ADD_STR(r, t, f) zbx_audit_update_json_append_string(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_UINT64(r, t, f) zbx_audit_update_json_append_uint64(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_INT(r, t, f) zbx_audit_update_json_append_int(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_DOUBLE(r, t, f) zbx_audit_update_json_append_double(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define AUDIT_TABLE_NAME "graphs"
+ ADD_STR(name, AUDIT_TABLE_NAME, "name")
+ ADD_INT(width, AUDIT_TABLE_NAME, "width")
+ ADD_INT(height, AUDIT_TABLE_NAME, "height")
+ ADD_DOUBLE(yaxismin, AUDIT_TABLE_NAME, "yaxismin")
+ ADD_DOUBLE(yaxismax, AUDIT_TABLE_NAME, "yaxismax")
+ ADD_UINT64(templateid, AUDIT_TABLE_NAME, "templateid")
+ ADD_INT(show_work_period, AUDIT_TABLE_NAME, "show_work_period")
+ ADD_INT(show_triggers, AUDIT_TABLE_NAME, "show_triggers")
+ ADD_INT(graphtype, AUDIT_TABLE_NAME, "graphtype")
+ ADD_INT(show_legend, AUDIT_TABLE_NAME, "show_legend")
+ ADD_INT(show_3d, AUDIT_TABLE_NAME, "show_3d")
+ ADD_DOUBLE(percent_left, AUDIT_TABLE_NAME, "percent_left")
+ ADD_DOUBLE(percent_right, AUDIT_TABLE_NAME, "percent_right")
+ ADD_INT(ymin_type, AUDIT_TABLE_NAME, "ymin_type")
+ ADD_INT(ymax_type, AUDIT_TABLE_NAME, "ymax_type")
+ ADD_UINT64(ymin_itemid, AUDIT_TABLE_NAME, "ymin_itemid")
+ ADD_UINT64(ymax_itemid, AUDIT_TABLE_NAME, "ymax_itemid")
+ ADD_INT(flags, AUDIT_TABLE_NAME, "flags")
+ if (AUDIT_RESOURCE_GRAPH_PROTOTYPE == resource_type)
+ ADD_INT(discover, AUDIT_TABLE_NAME, "discover")
#undef ADD_STR
#undef ADD_UINT64
#undef ADD_INT
#undef ADD_DOUBLE
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_graph_update_json_add_gitems(zbx_uint64_t graphid, int flags, zbx_uint64_t gitemid, int drawtype,
- int sortorder, const char *color, int yaxisside, int calc_fnc, int type)
+ int sortorder, const char *color, int yaxisside, int calc_fnc, int type, zbx_uint64_t itemid)
{
char audit_key_[AUDIT_DETAILS_KEY_LEN], audit_key_drawtype[AUDIT_DETAILS_KEY_LEN],
audit_key_sortorder[AUDIT_DETAILS_KEY_LEN],
audit_key_color[AUDIT_DETAILS_KEY_LEN], audit_key_yaxisside[AUDIT_DETAILS_KEY_LEN],
- audit_key_calc_fnc[AUDIT_DETAILS_KEY_LEN], audit_key_type[AUDIT_DETAILS_KEY_LEN];
+ audit_key_calc_fnc[AUDIT_DETAILS_KEY_LEN], audit_key_type[AUDIT_DETAILS_KEY_LEN],
+ audit_key_itemid[AUDIT_DETAILS_KEY_LEN];
int resource_type;
RETURN_IF_AUDIT_OFF();
@@ -170,18 +180,26 @@ void zbx_audit_graph_update_json_add_gitems(zbx_uint64_t graphid, int flags, zbx
AUDIT_KEY_GITEMS_SNPRINTF(yaxisside, .)
AUDIT_KEY_GITEMS_SNPRINTF(calc_fnc, .)
AUDIT_KEY_GITEMS_SNPRINTF(type, .)
-
- zbx_audit_update_json_append_no_value(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key_);
-#define ADD_STR(r) zbx_audit_update_json_append_string(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_INT(r) zbx_audit_update_json_append_int(graphid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
- ADD_INT(drawtype)
- ADD_INT(sortorder)
- ADD_STR(color);
- ADD_INT(yaxisside)
- ADD_INT(calc_fnc)
- ADD_INT(type)
+ AUDIT_KEY_GITEMS_SNPRINTF(itemid, .)
+
+ zbx_audit_update_json_append_no_value(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_);
+#define ADD_STR(r, t, f) zbx_audit_update_json_append_string(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_INT(r, t, f) zbx_audit_update_json_append_int(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_UINT64(r, t, f) zbx_audit_update_json_append_uint64(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define AUDIT_TABLE_NAME "graphs_items"
+ ADD_INT(drawtype, AUDIT_TABLE_NAME, "drawtype")
+ ADD_INT(sortorder, AUDIT_TABLE_NAME, "sortorder")
+ ADD_STR(color, AUDIT_TABLE_NAME, "color");
+ ADD_INT(yaxisside, AUDIT_TABLE_NAME, "yaxisside")
+ ADD_INT(calc_fnc, AUDIT_TABLE_NAME, "calc_fnc")
+ ADD_INT(type, AUDIT_TABLE_NAME, "type")
+ ADD_UINT64(itemid, AUDIT_TABLE_NAME, "itemid")
#undef ADD_STR
#undef ADD_INT
+#undef AUDIT_TABLE_NAME
}
#define PREPARE_AUDIT_GRAPH_UPDATE(resource, type1, type2) \
@@ -197,7 +215,7 @@ void zbx_audit_graph_update_json_update_##resource(zbx_uint64_t graphid, int fla
\
zbx_snprintf(buf, sizeof(buf), GR_OR_GRP(resource)); \
\
- zbx_audit_update_json_update_##type2(graphid, buf, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(graphid, AUDIT_GRAPH_ID, buf, resource##_old, resource##_new); \
}
PREPARE_AUDIT_GRAPH_UPDATE(name, const char*, string)
@@ -214,10 +232,10 @@ PREPARE_AUDIT_GRAPH_UPDATE(percent_left, double, double)
PREPARE_AUDIT_GRAPH_UPDATE(percent_right, double, double)
PREPARE_AUDIT_GRAPH_UPDATE(ymin_type, int, int)
PREPARE_AUDIT_GRAPH_UPDATE(ymax_type, int, int)
-PREPARE_AUDIT_GRAPH_UPDATE(ymin_itemid, uint64_t, uint64)
-PREPARE_AUDIT_GRAPH_UPDATE(ymax_itemid, uint64_t, uint64)
+PREPARE_AUDIT_GRAPH_UPDATE(ymin_itemid, zbx_uint64_t, uint64)
+PREPARE_AUDIT_GRAPH_UPDATE(ymax_itemid, zbx_uint64_t, uint64)
PREPARE_AUDIT_GRAPH_UPDATE(discover, int, int)
-PREPARE_AUDIT_GRAPH_UPDATE(templateid, uint64_t, uint64)
+PREPARE_AUDIT_GRAPH_UPDATE(templateid, zbx_uint64_t, uint64)
#undef PREPARE_AUDIT_GRAPH_UPDATE
#undef GR_OR_GRP
@@ -233,7 +251,7 @@ void zbx_audit_graph_update_json_update_gitem_create_entry(zbx_uint64_t graphid,
AUDIT_KEY_GITEMS_SNPRINTF(,)
- zbx_audit_update_json_append_no_value(graphid, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
+ zbx_audit_update_json_append_no_value(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
}
#define PREPARE_AUDIT_GRAPH_UPDATE(resource, type1, type2) \
@@ -249,8 +267,10 @@ void zbx_audit_graph_update_json_update_gitem_update_##resource(zbx_uint64_t gra
\
AUDIT_KEY_GITEMS_SNPRINTF(resource, .) \
\
- zbx_audit_update_json_update_##type2(graphid, audit_key_##resource, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(graphid, AUDIT_GRAPH_ID, audit_key_##resource, resource##_old, \
+ resource##_new); \
}
+PREPARE_AUDIT_GRAPH_UPDATE(itemid, zbx_uint64_t, uint64)
PREPARE_AUDIT_GRAPH_UPDATE(drawtype,int, int)
PREPARE_AUDIT_GRAPH_UPDATE(sortorder, int, int)
PREPARE_AUDIT_GRAPH_UPDATE(color, const char*, string)
@@ -261,6 +281,23 @@ PREPARE_AUDIT_GRAPH_UPDATE(type, int, int)
#undef PREPARE_AUDIT_GRAPH_UPDATE
#undef AUDIT_KEY_GITEMS_SNPRINTF
+void zbx_audit_graph_update_json_delete_gitems(zbx_uint64_t graphid, int flags, zbx_uint64_t gitemid)
+{
+ char audit_key[AUDIT_DETAILS_KEY_LEN];
+ int resource_type;
+
+ RETURN_IF_AUDIT_OFF();
+
+ resource_type = graph_flag_to_resource_type(flags);
+
+ if (AUDIT_RESOURCE_GRAPH == resource_type)
+ zbx_snprintf(audit_key, sizeof(audit_key), "graph.gitems[" ZBX_FS_UI64 "]", gitemid);
+ else
+ zbx_snprintf(audit_key, sizeof(audit_key), "graphprototype.gitems[" ZBX_FS_UI64 "]", gitemid);
+
+ zbx_audit_update_json_append_no_value(graphid, AUDIT_GRAPH_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key);
+}
+
void zbx_audit_DBselect_delete_for_graph(const char *sql, zbx_vector_uint64_t *ids)
{
DB_RESULT result;
diff --git a/src/libs/zbxaudit/audit_graph.h b/src/libs/zbxaudit/audit_graph.h
index e602b5f94fb..09bc9c5dd16 100644
--- a/src/libs/zbxaudit/audit_graph.h
+++ b/src/libs/zbxaudit/audit_graph.h
@@ -27,13 +27,13 @@
void zbx_audit_graph_create_entry(int audit_action, zbx_uint64_t graphid, const char *name, int flags);
-void zbx_audit_graph_update_json_add_data(zbx_uint64_t graphid, const char *graph_copy_name, int width, int height,
+void zbx_audit_graph_update_json_add_data(zbx_uint64_t graphid, const char *name, int width, int height,
double yaxismin, double yaxismax, zbx_uint64_t templateid, int show_work_period, int show_triggers,
int graphtype, int show_legend, int show_3d, double percent_left, double percent_right, int ymin_type,
int ymax_type, zbx_uint64_t ymin_itemid, zbx_uint64_t ymax_itemid, int flags, int discover);
void zbx_audit_graph_update_json_add_gitems(zbx_uint64_t graphid, int flags, zbx_uint64_t gitemid, int drawtype,
- int sortorder, const char *color, int yaxisside, int calc_fnc, int type);
+ int sortorder, const char *color, int yaxisside, int calc_fnc, int type, zbx_uint64_t itemid);
#define PREPARE_AUDIT_GRAPH_UPDATE(resource, type1) \
void zbx_audit_graph_update_json_update_##resource(zbx_uint64_t graphid, int flags, \
@@ -53,10 +53,10 @@ PREPARE_AUDIT_GRAPH_UPDATE(percent_left, double)
PREPARE_AUDIT_GRAPH_UPDATE(percent_right, double)
PREPARE_AUDIT_GRAPH_UPDATE(ymin_type, int)
PREPARE_AUDIT_GRAPH_UPDATE(ymax_type, int)
-PREPARE_AUDIT_GRAPH_UPDATE(ymin_itemid, uint64_t)
-PREPARE_AUDIT_GRAPH_UPDATE(ymax_itemid, uint64_t)
+PREPARE_AUDIT_GRAPH_UPDATE(ymin_itemid, zbx_uint64_t)
+PREPARE_AUDIT_GRAPH_UPDATE(ymax_itemid, zbx_uint64_t)
PREPARE_AUDIT_GRAPH_UPDATE(discover, int)
-PREPARE_AUDIT_GRAPH_UPDATE(templateid, uint64_t)
+PREPARE_AUDIT_GRAPH_UPDATE(templateid, zbx_uint64_t)
#undef PREPARE_AUDIT_GRAPH_UPDATE
void zbx_audit_graph_update_json_update_gitem_create_entry(zbx_uint64_t graphid, int flags, zbx_uint64_t gitemid);
@@ -64,6 +64,7 @@ void zbx_audit_graph_update_json_update_gitem_create_entry(zbx_uint64_t graphid,
#define PREPARE_AUDIT_GRAPH_UPDATE(resource, type1) \
void zbx_audit_graph_update_json_update_gitem_update_##resource(zbx_uint64_t graphid, int flags, \
zbx_uint64_t gitemid, type1 resource##_old, type1 resource##_new);
+PREPARE_AUDIT_GRAPH_UPDATE(itemid, zbx_uint64_t)
PREPARE_AUDIT_GRAPH_UPDATE(drawtype, int)
PREPARE_AUDIT_GRAPH_UPDATE(sortorder, int)
PREPARE_AUDIT_GRAPH_UPDATE(color, const char*)
@@ -72,6 +73,8 @@ PREPARE_AUDIT_GRAPH_UPDATE(calc_fnc, int)
PREPARE_AUDIT_GRAPH_UPDATE(type, int)
#undef PREPARE_AUDIT_GRAPH_UPDATE
+void zbx_audit_graph_update_json_delete_gitems(zbx_uint64_t graphid, int flags, zbx_uint64_t gitemid);
+
void zbx_audit_DBselect_delete_for_graph(const char *sql, zbx_vector_uint64_t *ids);
#endif /* ZABBIX_AUDIT_GRAPH_H */
diff --git a/src/libs/zbxaudit/audit_ha.c b/src/libs/zbxaudit/audit_ha.c
index 511f0123716..26fd7f2290e 100644
--- a/src/libs/zbxaudit/audit_ha.c
+++ b/src/libs/zbxaudit/audit_ha.c
@@ -30,12 +30,14 @@ void zbx_audit_ha_create_entry(int audit_action, const char *nodeid, const char
local_audit_entry.id = 0;
local_audit_entry.cuid = (char *)nodeid;
+ local_audit_entry.id_table = AUDIT_HA_NODE_ID;
if (NULL == zbx_hashset_search(zbx_get_audit_hashset(), &plocal_audit_entry))
{
zbx_audit_entry_t *new_entry;
- new_entry = zbx_audit_entry_init_cuid(nodeid, name, audit_action, AUDIT_RESOURCE_HA_NODE);
+ new_entry = zbx_audit_entry_init_cuid(nodeid, AUDIT_HA_NODE_ID, name, audit_action,
+ AUDIT_RESOURCE_HA_NODE);
zbx_hashset_insert(zbx_get_audit_hashset(), &new_entry, sizeof(new_entry));
}
}
@@ -46,7 +48,7 @@ void zbx_audit_ha_add_create_fields(const char *nodeid, const char *name, int st
RETURN_IF_AUDIT_OFF();
- entry = zbx_audit_get_entry(0, nodeid);
+ entry = zbx_audit_get_entry(0, nodeid, AUDIT_HA_NODE_ID);
zbx_audit_entry_append_string(entry, AUDIT_ACTION_ADD, ZBX_AUDIT_HA_NODEID, nodeid);
zbx_audit_entry_append_string(entry, AUDIT_ACTION_ADD, ZBX_AUDIT_HA_NAME, name);
@@ -60,7 +62,7 @@ void zbx_audit_ha_update_field_string(const char *nodeid, const char *key, const
RETURN_IF_AUDIT_OFF();
- entry = zbx_audit_get_entry(0, nodeid);
+ entry = zbx_audit_get_entry(0, nodeid, AUDIT_HA_NODE_ID);
zbx_audit_entry_append_string(entry, AUDIT_ACTION_UPDATE, key, old_value, new_value);
}
@@ -70,7 +72,7 @@ void zbx_audit_ha_update_field_int(const char *nodeid, const char *key, int old_
RETURN_IF_AUDIT_OFF();
- entry = zbx_audit_get_entry(0, nodeid);
+ entry = zbx_audit_get_entry(0, nodeid, AUDIT_HA_NODE_ID);
zbx_audit_entry_append_int(entry, AUDIT_ACTION_UPDATE, key, old_value, new_value);
}
diff --git a/src/libs/zbxaudit/audit_host.c b/src/libs/zbxaudit/audit_host.c
index 625c95aca18..730fe4797e8 100644
--- a/src/libs/zbxaudit/audit_host.c
+++ b/src/libs/zbxaudit/audit_host.c
@@ -62,24 +62,27 @@ void zbx_audit_##funcname##_update_json_add_snmp_interface(zbx_uint64_t hostid,
zbx_uint64_t privprotocol, const char *contextname, zbx_uint64_t interfaceid) \
{ \
PREPARE_UPDATE_JSON_SNMP_INTERFACE_OP(auditentry) \
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_version, version); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_bulk, bulk); \
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_community, community);\
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_securityname, \
- securityname); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_securitylevel, \
- securitylevel); \
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_authpassphrase, \
- authpassphrase); \
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_privpassphrase, \
- privpassphrase); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_authprotocol, \
- authprotocol); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_privprotocol, \
- privprotocol); \
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_contextname, \
- contextname); \
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_version, \
+ version, "interface_snmp", "version"); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_bulk, \
+ bulk, "interface_snmp", "bulk"); \
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_community, community, "interface_snmp", "community"); \
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_securityname, securityname, "interface_snmp", "securityname"); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_securitylevel, securitylevel, "interface_snmp", "securitylevel"); \
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_authpassphrase, authpassphrase, "interface_snmp", "authpassphrase"); \
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_privpassphrase, privpassphrase, "interface_snmp", "privpassphrase"); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_authprotocol, authprotocol, "interface_snmp", "authprotocol"); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_privprotocol, privprotocol, "interface_snmp", "privprotocol"); \
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_contextname, contextname, "interface_snmp", "contextname"); \
} \
\
void zbx_audit_##funcname##_update_json_update_snmp_interface(zbx_uint64_t hostid, zbx_uint64_t version_old, \
@@ -92,50 +95,75 @@ void zbx_audit_##funcname##_update_json_update_snmp_interface(zbx_uint64_t hosti
const char *contextname_new, zbx_uint64_t interfaceid) \
{ \
PREPARE_UPDATE_JSON_SNMP_INTERFACE_OP(funcname) \
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_UPDATE, audit_key); \
- zbx_audit_update_json_update_uint64(hostid, audit_key_version, version_old, version_new); \
- zbx_audit_update_json_update_uint64(hostid, audit_key_bulk, bulk_old, bulk_new); \
- zbx_audit_update_json_update_string(hostid, audit_key_community, community_old, community_new); \
- zbx_audit_update_json_update_string(hostid, audit_key_securityname, securityname_old, securityname_new);\
- zbx_audit_update_json_update_uint64(hostid, audit_key_securitylevel, securitylevel_old, \
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_UPDATE, audit_key); \
+ zbx_audit_update_json_update_uint64(hostid, AUDIT_HOST_ID, audit_key_version, version_old, version_new);\
+ zbx_audit_update_json_update_uint64(hostid, AUDIT_HOST_ID, audit_key_bulk, bulk_old, bulk_new); \
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, audit_key_community, community_old, \
+ community_new); \
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, audit_key_securityname, securityname_old, \
+ securityname_new); \
+ zbx_audit_update_json_update_uint64(hostid, AUDIT_HOST_ID, audit_key_securitylevel, securitylevel_old, \
securitylevel_new); \
- zbx_audit_update_json_update_string(hostid, audit_key_authpassphrase, authpassphrase_old, \
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, audit_key_authpassphrase, authpassphrase_old,\
authpassphrase_new); \
- zbx_audit_update_json_update_string(hostid, audit_key_privpassphrase, privpassphrase_old, \
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, audit_key_privpassphrase, privpassphrase_old,\
privpassphrase_new); \
- zbx_audit_update_json_update_uint64(hostid, audit_key_authprotocol, authprotocol_old, authprotocol_new);\
- zbx_audit_update_json_update_uint64(hostid, audit_key_privprotocol, privprotocol_old, privprotocol_new);\
- zbx_audit_update_json_update_string(hostid, audit_key_contextname, contextname_old, contextname_new); \
+ zbx_audit_update_json_update_uint64(hostid, AUDIT_HOST_ID, audit_key_authprotocol, authprotocol_old, \
+ authprotocol_new); \
+ zbx_audit_update_json_update_uint64(hostid, AUDIT_HOST_ID, audit_key_privprotocol, privprotocol_old, \
+ privprotocol_new); \
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, audit_key_contextname, contextname_old, \
+ contextname_new); \
} \
PREPARE_AUDIT_SNMP_INTERFACE(host, host)
PREPARE_AUDIT_SNMP_INTERFACE(host_prototype, hostprototype)
-void zbx_audit_host_update_json_add_proxy_hostid_and_hostname(zbx_uint64_t hostid, zbx_uint64_t proxy_hostid,
- const char *hostname)
+void zbx_audit_host_update_json_add_proxy_hostid_and_hostname_and_inventory_mode(zbx_uint64_t hostid,
+ zbx_uint64_t proxy_hostid, const char *hostname, int inventory_mode)
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, "host.proxy_hostid", proxy_hostid);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.host", hostname);
+#define AUDIT_TABLE_NAME "hosts"
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.proxy_hostid",
+ proxy_hostid, AUDIT_TABLE_NAME, "proxy_hostid");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.host", hostname,
+ AUDIT_TABLE_NAME, "host");
+
+ /*
+ * Currently there are 3 valid values for inventory_mode: HOST_INVENTORY_DISABLED (-1), the default value
+ * HOST_INVENTORY_MANUAL (0), and HOST_INVENTORY_AUTOMATIC (1). In database we write only 2 of them:
+ * HOST_INVENTORY_MANUAL and HOST_INVENTORY_AUTOMATIC. From the other side in auditlog we must write all of
+ * them except the default, i.e. HOST_INVENTORY_DISABLED and HOST_INVENTORY_AUTOMATIC.
+ */
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.inventory_mode",
+ inventory_mode, "host_inventory", "inventory_mode");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_update_json_add_tls_and_psk(zbx_uint64_t hostid, int tls_connect, int tls_accept,
- const char *psk_identity, const char *psk)
+ const char *tls_psk_identity, const char *tls_psk)
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_connect", tls_connect);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_accept", tls_accept);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.psk_identity", psk_identity);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.psk", psk);
+#define AUDIT_TABLE_NAME "hosts"
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.tls_connect",
+ tls_connect, AUDIT_TABLE_NAME, "tls_connect");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.tls_accept", tls_accept,
+ AUDIT_TABLE_NAME, "tls_accept");
+ zbx_audit_update_json_append_string_secret(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD,
+ "host.tls_psk_identity", tls_psk_identity, AUDIT_TABLE_NAME, "tls_psk_identity");
+ zbx_audit_update_json_append_string_secret(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.tls_psk",
+ tls_psk, AUDIT_TABLE_NAME, "tls_psk");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_update_json_add_inventory_mode(zbx_uint64_t hostid, int inventory_mode)
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.inventory_mode", inventory_mode);
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.inventory_mode",
+ inventory_mode, "host_inventory", "inventory_mode");
}
void zbx_audit_host_update_json_update_inventory_mode(zbx_uint64_t hostid, int inventory_mode_old,
@@ -143,7 +171,8 @@ void zbx_audit_host_update_json_update_inventory_mode(zbx_uint64_t hostid, int i
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_update_int(hostid, "host.inventory_mode", inventory_mode_old, inventory_mode_new);
+ zbx_audit_update_json_update_int(hostid, AUDIT_HOST_ID, "host.inventory_mode", inventory_mode_old,
+ inventory_mode_new);
}
void zbx_audit_host_update_json_update_host_status(zbx_uint64_t hostid, int host_status_old,
@@ -151,7 +180,7 @@ void zbx_audit_host_update_json_update_host_status(zbx_uint64_t hostid, int host
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_update_int(hostid, "host.status", host_status_old, host_status_new);
+ zbx_audit_update_json_update_int(hostid, AUDIT_HOST_ID, "host.status", host_status_old, host_status_new);
}
void zbx_audit_host_prototype_update_json_update_interface_details_create_entry(zbx_uint64_t hostid,
@@ -163,7 +192,7 @@ void zbx_audit_host_prototype_update_json_update_interface_details_create_entry(
zbx_snprintf(buf, sizeof(buf), "hostprototype.interfaces[" ZBX_FS_UI64 "].details", interfaceid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_UPDATE, buf);
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_UPDATE, buf);
}
@@ -177,7 +206,8 @@ void zbx_audit_##funcname##_update_json_update_interface_##interface_resource(zb
\
zbx_snprintf(buf, sizeof(buf), #auditentry".interfaces[" ZBX_FS_UI64 "].details."#interface_resource, \
interfaceid); \
- zbx_audit_update_json_update_##type2(hostid, buf, interface_resource##_old, interface_resource##_new); \
+ zbx_audit_update_json_update_##type2(hostid, AUDIT_HOST_ID, buf, interface_resource##_old, \
+ interface_resource##_new); \
} \
#define PREPARE_AUDIT_HOST(funcname, auditentry, audit_resource_flag) \
@@ -190,22 +220,22 @@ void zbx_audit_##funcname##_create_entry(int audit_action, zbx_uint64_t hostid,
\
local_audit_host_entry.id = hostid; \
local_audit_host_entry.cuid = NULL; \
- \
+ local_audit_host_entry.id_table = AUDIT_HOST_ID; \
found_audit_host_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(), \
&(local_audit_host_entry_x)); \
if (NULL == found_audit_host_entry) \
{ \
zbx_audit_entry_t *local_audit_host_entry_insert; \
\
- local_audit_host_entry_insert = zbx_audit_entry_init(hostid, name, audit_action, \
+ local_audit_host_entry_insert = zbx_audit_entry_init(hostid, AUDIT_HOST_ID, name, audit_action, \
audit_resource_flag); \
zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_host_entry_insert, \
sizeof(local_audit_host_entry_insert)); \
\
if (AUDIT_ACTION_ADD == audit_action) \
{ \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, \
- #auditentry".hostid", hostid); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ #auditentry".hostid", hostid, "hosts", "hostid"); \
} \
} \
} \
@@ -235,13 +265,19 @@ void zbx_audit_##funcname##_update_json_add_interfaces(zbx_uint64_t hostid, zbx_
zbx_snprintf(audit_key_port, sizeof(audit_key_port), #auditentry".interfaces[" ZBX_FS_UI64 \
"].port", interfaceid); \
\
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_main, main_); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_type, type); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_useip, useip); \
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_ip, ip); \
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_dns, dns); \
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_port, port); \
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_main, \
+ main_, "interface", "main"); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_type, \
+ type, "interface", "type"); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_useip, \
+ useip, "interface", "useip"); \
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_ip, ip, \
+ "interface", "ip"); \
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_dns, dns,\
+ "interface", "dns"); \
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_port, port, \
+ "interface", "port"); \
} \
\
PREPARE_AUDIT_HOST_INTERFACE(funcname, auditentry, useip, zbx_uint64_t, uint64) \
@@ -273,7 +309,8 @@ void zbx_audit_host_update_json_update_##resource(zbx_uint64_t hostid, type1 old
{ \
RETURN_IF_AUDIT_OFF(); \
\
- zbx_audit_update_json_update_##type2(hostid, "host."#resource, old_##resource, new_##resource); \
+ zbx_audit_update_json_update_##type2(hostid, AUDIT_HOST_ID, "host."#resource, old_##resource, \
+ new_##resource); \
}
PREPARE_AUDIT_HOST_UPDATE(host, const char*, string)
@@ -300,7 +337,7 @@ void zbx_audit_host_update_json_delete_interface(zbx_uint64_t hostid, zbx_uint64
zbx_snprintf(buf, sizeof(buf), "host.interfaces[" ZBX_FS_UI64 "]", interfaceid);
- zbx_audit_update_json_delete(hostid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_host_update_json_add_hostmacro(zbx_uint64_t hostid, zbx_uint64_t macroid,
@@ -319,11 +356,17 @@ void zbx_audit_host_update_json_add_hostmacro(zbx_uint64_t hostid, zbx_uint64_t
"].description", macroid);
zbx_snprintf(audit_key_type, sizeof(audit_key_type), "host.macros[" ZBX_FS_UI64 "].type", macroid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, macro);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_description, description);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_type, type);
+#define AUDIT_TABLE_NAME "hostmacro"
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name, macro,
+ AUDIT_TABLE_NAME, "macro");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_description,
+ description, AUDIT_TABLE_NAME, "description");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_type, type,
+ AUDIT_TABLE_NAME, "type");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_update_json_update_hostmacro_create_entry(zbx_uint64_t hostid,
@@ -335,20 +378,20 @@ void zbx_audit_host_update_json_update_hostmacro_create_entry(zbx_uint64_t hosti
zbx_snprintf(buf, sizeof(buf), "host.macros[" ZBX_FS_UI64 "]", hostmacroid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_UPDATE, buf);
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_UPDATE, buf);
}
-#define PREPARE_AUDIT_HOST_UPDATE_HOSTMACRO(resource, type1, type2) \
-void zbx_audit_host_update_json_update_hostmacro_##resource(zbx_uint64_t hostid, \
+#define PREPARE_AUDIT_HOST_UPDATE_HOSTMACRO(resource, type1, type2) \
+void zbx_audit_host_update_json_update_hostmacro_##resource(zbx_uint64_t hostid, \
zbx_uint64_t hostmacroid, type1 old_##resource, type1 new_##resource) \
{ \
char buf[AUDIT_DETAILS_KEY_LEN]; \
\
RETURN_IF_AUDIT_OFF(); \
\
- zbx_snprintf(buf, sizeof(buf), "host.macros[" ZBX_FS_UI64 "]."#resource, hostmacroid); \
+ zbx_snprintf(buf, sizeof(buf), "host.macros[" ZBX_FS_UI64 "]."#resource, hostmacroid); \
\
- zbx_audit_update_json_update_##type2(hostid, buf, old_##resource, new_##resource); \
+ zbx_audit_update_json_update_##type2(hostid, AUDIT_HOST_ID, buf, old_##resource, new_##resource); \
} \
PREPARE_AUDIT_HOST_UPDATE_HOSTMACRO(value, const char*, string)
@@ -364,7 +407,7 @@ void zbx_audit_host_update_json_delete_hostmacro(zbx_uint64_t hostid, zbx_uint64
zbx_snprintf(buf, sizeof(buf), "host.macros[" ZBX_FS_UI64 "]", hostmacroid);
- zbx_audit_update_json_delete(hostid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_hostgroup_update_json_add_group(zbx_uint64_t hostid, zbx_uint64_t hostgroupid, zbx_uint64_t groupid)
@@ -378,19 +421,25 @@ void zbx_audit_hostgroup_update_json_add_group(zbx_uint64_t hostid, zbx_uint64_t
zbx_snprintf(audit_key_hostid, sizeof(audit_key_hostid), "host.groups[" ZBX_FS_UI64 "].hostid", hostgroupid);
zbx_snprintf(audit_key_groupid, sizeof(audit_key_groupid), "host.groups[" ZBX_FS_UI64 "].groupid", hostgroupid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_hostid, hostid);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_groupid, groupid);
+#define AUDIT_TABLE_NAME "hosts_groups"
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_hostid, hostid,
+ AUDIT_TABLE_NAME, "hostid");
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_groupid, groupid,
+ AUDIT_TABLE_NAME, "groupid");
+#undef AUDIT_TABLE_NAME
}
-void zbx_audit_hostgroup_update_json_delete_group(zbx_uint64_t hostid, zbx_uint64_t hostgroupid, zbx_uint64_t groupid)
+void zbx_audit_hostgroup_update_json_delete_group(zbx_uint64_t hostid, zbx_uint64_t hostgroupid,
+ zbx_uint64_t groupid)
{
char audit_key[AUDIT_DETAILS_KEY_LEN];
RETURN_IF_AUDIT_OFF();
zbx_snprintf(audit_key, sizeof(audit_key), "host.groups[" ZBX_FS_UI64 "]", hostgroupid);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_DELETE, audit_key, groupid);
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key, groupid,
+ NULL, NULL);
}
void zbx_audit_host_hostgroup_delete(zbx_uint64_t hostid, const char* hostname, zbx_vector_uint64_t *hostgroupids,
@@ -406,8 +455,8 @@ void zbx_audit_host_hostgroup_delete(zbx_uint64_t hostid, const char* hostname,
for (i = 0; i < groupids->values_num; i++)
{
zbx_snprintf(buf, sizeof(buf), "host.groups[" ZBX_FS_UI64 "].groupid", hostgroupids->values[i]);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_DELETE, buf,
- groupids->values[i]);
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, buf,
+ groupids->values[i], NULL, NULL);
}
}
@@ -421,26 +470,39 @@ void zbx_audit_host_del(zbx_uint64_t hostid, const char *hostname)
void zbx_audit_host_update_json_add_details(zbx_uint64_t hostid, const char *host, zbx_uint64_t proxy_hostid,
int ipmi_authtype, int ipmi_privilege, const char *ipmi_username, const char *ipmi_password,
int status, int flags, int tls_connect, int tls_accept, const char *tls_issuer, const char *tls_subject,
- const char *tls_psk_identity, const char *tls_psk, int custom_interfaces)
-{
- RETURN_IF_AUDIT_OFF();
-
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.host", host);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, "host.proxy_hostid", proxy_hostid);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_authtype", ipmi_authtype);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_privilege", ipmi_privilege);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_username", ipmi_username);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_password", ipmi_password);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.status", status);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.flags", flags);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_connect", tls_connect);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_accept", tls_accept);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_issuer", tls_issuer);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_subject", tls_subject);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_psk_identity",
- tls_psk_identity);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_psk", tls_psk);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.custom_interfaces", custom_interfaces);
+ const char *tls_psk_identity, const char *tls_psk, int custom_interfaces, int inventory_mode)
+{
+ RETURN_IF_AUDIT_OFF();
+
+#define AUDIT_TABLE_NAME "hosts"
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.host", host,
+ AUDIT_TABLE_NAME, "host");
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.proxy_hostid",
+ proxy_hostid, AUDIT_TABLE_NAME, "proxy_hostid");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_authtype",
+ ipmi_authtype, AUDIT_TABLE_NAME, "ipmi_authtype");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_privilege",
+ ipmi_privilege, AUDIT_TABLE_NAME, "ipmi_privilege");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_username",
+ ipmi_username, AUDIT_TABLE_NAME, "ipmi_username");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.ipmi_password",
+ ipmi_password, AUDIT_TABLE_NAME, "ipmi_password");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.status", status,
+ AUDIT_TABLE_NAME, "status");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.flags", flags,
+ AUDIT_TABLE_NAME, "flags");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.tls_issuer",
+ tls_issuer, AUDIT_TABLE_NAME, "tls_issuer");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.tls_subject",
+ tls_subject, AUDIT_TABLE_NAME, "tls_subject");
+
+ zbx_audit_host_update_json_add_tls_and_psk(hostid, tls_connect, tls_accept, tls_psk_identity, tls_psk);
+
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.custom_interfaces",
+ custom_interfaces, AUDIT_TABLE_NAME, "custom_interfaces");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "host.inventory_mode",
+ inventory_mode, "host_inventory", "inventory_mode");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_update_json_add_tag(zbx_uint64_t hostid, zbx_uint64_t tagid, const char* tag,
@@ -455,9 +517,13 @@ void zbx_audit_host_update_json_add_tag(zbx_uint64_t hostid, zbx_uint64_t tagid,
zbx_snprintf(audit_key_tag, sizeof(audit_key_tag), "host.tags[" ZBX_FS_UI64 "].tag", tagid);
zbx_snprintf(audit_key_value, sizeof(audit_key_value), "host.tags[" ZBX_FS_UI64 "].value", tagid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "host_tag"
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag,
+ AUDIT_TABLE_NAME, "tag");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_update_json_update_tag_create_entry(zbx_uint64_t hostid, zbx_uint64_t tagid)
@@ -468,7 +534,7 @@ void zbx_audit_host_update_json_update_tag_create_entry(zbx_uint64_t hostid, zbx
zbx_snprintf(buf, sizeof(buf), "host.tags[" ZBX_FS_UI64 "]", tagid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_UPDATE, buf);
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_UPDATE, buf);
}
void zbx_audit_host_update_json_update_tag_tag(zbx_uint64_t hostid, zbx_uint64_t tagid,
@@ -480,7 +546,7 @@ void zbx_audit_host_update_json_update_tag_tag(zbx_uint64_t hostid, zbx_uint64_t
zbx_snprintf(buf, AUDIT_DETAILS_KEY_LEN, "host.tags[" ZBX_FS_UI64 "].tag", tagid);
- zbx_audit_update_json_update_string(hostid, buf, tag_old, tag_new);
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, buf, tag_old, tag_new);
}
void zbx_audit_host_update_json_update_tag_value(zbx_uint64_t hostid, zbx_uint64_t tagid,
@@ -492,7 +558,7 @@ void zbx_audit_host_update_json_update_tag_value(zbx_uint64_t hostid, zbx_uint64
zbx_snprintf(buf, AUDIT_DETAILS_KEY_LEN, "host.tags[" ZBX_FS_UI64 "].value", tagid);
- zbx_audit_update_json_update_string(hostid, buf, value_old, value_new);
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, buf, value_old, value_new);
}
void zbx_audit_host_update_json_delete_tag(zbx_uint64_t hostid, zbx_uint64_t tagid)
@@ -503,7 +569,7 @@ void zbx_audit_host_update_json_delete_tag(zbx_uint64_t hostid, zbx_uint64_t tag
zbx_snprintf(buf, AUDIT_DETAILS_KEY_LEN, "host.tags[" ZBX_FS_UI64 "]", tagid);
- zbx_audit_update_json_delete(hostid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_host_prototype_del(zbx_uint64_t hostid, const char *hostname)
@@ -514,17 +580,24 @@ void zbx_audit_host_prototype_del(zbx_uint64_t hostid, const char *hostname)
}
void zbx_audit_host_prototype_update_json_add_details(zbx_uint64_t hostid, zbx_uint64_t templateid,
- const char *name, int status, int discover, int custom_interfaces)
+ const char *name, int status, int discover, int custom_interfaces, int inventory_mode)
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, "hostprototype.templateid",
- templateid);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "hostprototype.name", name);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "hostprototype.status", status);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "hostprototype.discover", discover);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "hostprototype.custom_interfaces",
- custom_interfaces);
+#define AUDIT_TABLE_NAME "hosts"
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "hostprototype.templateid",
+ templateid, AUDIT_TABLE_NAME, "templateid");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "hostprototype.name", name,
+ AUDIT_TABLE_NAME, "name");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "hostprototype.status", status,
+ AUDIT_TABLE_NAME, "status");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, "hostprototype.discover",
+ discover, AUDIT_TABLE_NAME, "discover");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD,
+ "hostprototype.custom_interfaces", custom_interfaces, AUDIT_TABLE_NAME, "custom_interfaces");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD,
+ "hostprototype.inventory_mode", inventory_mode, "host_inventory", "inventory_mode");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_prototype_update_json_update_templateid(zbx_uint64_t hostid, zbx_uint64_t templateid_orig,
@@ -532,7 +605,8 @@ void zbx_audit_host_prototype_update_json_update_templateid(zbx_uint64_t hostid,
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_update_uint64(hostid, "hostprototype.templateid", templateid_orig, templateid);
+ zbx_audit_update_json_update_uint64(hostid, AUDIT_HOST_ID, "hostprototype.templateid", templateid_orig,
+ templateid);
}
#define PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE(resource, type1, type2) \
@@ -541,13 +615,15 @@ void zbx_audit_host_prototype_update_json_update_##resource(zbx_uint64_t hostid,
{ \
RETURN_IF_AUDIT_OFF(); \
\
- zbx_audit_update_json_update_##type2(hostid, "hostprototype."#resource, old_##resource, new_##resource);\
+ zbx_audit_update_json_update_##type2(hostid, AUDIT_HOST_ID, "hostprototype."#resource, old_##resource, \
+ new_##resource); \
} \
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE(name, const char*, string)
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE(status, int, int)
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE(discover, int, int)
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE(custom_interfaces, int, int)
+PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE(inventory_mode, int, int)
#undef PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE
void zbx_audit_host_prototype_update_json_add_group_details(zbx_uint64_t hostid, zbx_uint64_t group_prototypeid,
@@ -559,6 +635,7 @@ void zbx_audit_host_prototype_update_json_add_group_details(zbx_uint64_t hostid,
RETURN_IF_AUDIT_OFF();
+#define AUDIT_TABLE_NAME "group_prototype"
if (0 != strlen(name))
{
zbx_snprintf(audit_key, sizeof(audit_key), "hostprototype.groupPrototypes[" ZBX_FS_UI64 "]",
@@ -569,7 +646,8 @@ void zbx_audit_host_prototype_update_json_add_group_details(zbx_uint64_t hostid,
"].name", group_prototypeid);
zbx_snprintf(audit_key_templateid, sizeof(audit_key_templateid), "hostprototype.groupPrototypes["
ZBX_FS_UI64 "].templateid", group_prototypeid);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name);
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name,
+ name, AUDIT_TABLE_NAME, "name");
}
else if (0 != groupid)
{
@@ -581,12 +659,16 @@ void zbx_audit_host_prototype_update_json_add_group_details(zbx_uint64_t hostid,
"].groupid", group_prototypeid);
zbx_snprintf(audit_key_templateid, sizeof(audit_key_templateid), "hostprototype.groupLinks[" ZBX_FS_UI64
"].templateid", group_prototypeid);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_groupid, groupid);
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_groupid,
+ groupid, AUDIT_TABLE_NAME, "groupid");
}
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_hostid, hostid);
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_templateid, templateid);
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_hostid, hostid,
+ AUDIT_TABLE_NAME, "hostid");
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_templateid,
+ templateid, AUDIT_TABLE_NAME, "templateid");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_prototype_update_json_update_group_details(zbx_uint64_t hostid, zbx_uint64_t group_prototypeid,
@@ -614,8 +696,10 @@ void zbx_audit_host_prototype_update_json_update_group_details(zbx_uint64_t host
return;
}
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_UPDATE, audit_key);
- zbx_audit_update_json_update_uint64(hostid, audit_key_templateid, templateid_old, templateid_new);
+
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_UPDATE, audit_key);
+ zbx_audit_update_json_update_uint64(hostid, AUDIT_HOST_ID, audit_key_templateid, templateid_old,
+ templateid_new);
}
#define PREPARE_AUDIT_TEMPLATE_ADD(funcname, auditentry) \
@@ -633,10 +717,11 @@ void zbx_audit_##funcname##_update_json_add_parent_template(zbx_uint64_t hostid,
zbx_snprintf(audit_key_templateid, sizeof(audit_key_templateid), #auditentry".templates[" ZBX_FS_UI64 \
"].templateid", hosttemplateid); \
\
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_hostid, hostid); \
- zbx_audit_update_json_append_uint64(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_templateid, \
- templateid); \
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_hostid, \
+ hostid, "hosts", "hostid"); \
+ zbx_audit_update_json_append_uint64(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_templateid, templateid, "hosts", "templateid"); \
} \
#define PREPARE_AUDIT_TEMPLATE_DELETE(funcname, auditentry) \
@@ -650,7 +735,8 @@ void zbx_audit_##funcname##_update_json_delete_parent_template(zbx_uint64_t host
zbx_snprintf(audit_key_templateid, sizeof(audit_key_templateid), #auditentry".templates[" ZBX_FS_UI64 \
"]", hosttemplateid); \
\
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_DELETE, audit_key_templateid); \
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, \
+ audit_key_templateid); \
} \
PREPARE_AUDIT_TEMPLATE_ADD(host, host)
@@ -666,7 +752,7 @@ void zbx_audit_host_prototype_update_json_delete_interface(zbx_uint64_t hostid,
zbx_snprintf(buf, sizeof(buf), "hostprototype.interfaces[" ZBX_FS_UI64 "]", interfaceid);
- zbx_audit_update_json_delete(hostid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_host_prototype_update_json_add_hostmacro(zbx_uint64_t hostid, zbx_uint64_t macroid,
@@ -685,11 +771,17 @@ void zbx_audit_host_prototype_update_json_add_hostmacro(zbx_uint64_t hostid, zbx
"].description", macroid);
zbx_snprintf(audit_key_type, sizeof(audit_key_type), "hostprototype.macros[" ZBX_FS_UI64 "].type", macroid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, macro);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_description, description);
- zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_type, type);
+#define AUDIT_TABLE_NAME "hostmacro"
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name, macro,
+ AUDIT_TABLE_NAME, "macro");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_description,
+ description, AUDIT_TABLE_NAME, "description");
+ zbx_audit_update_json_append_int(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_type, type,
+ AUDIT_TABLE_NAME, "type");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_prototype_update_json_update_hostmacro_create_entry(zbx_uint64_t hostid,
@@ -701,7 +793,7 @@ void zbx_audit_host_prototype_update_json_update_hostmacro_create_entry(zbx_uint
zbx_snprintf(buf, sizeof(buf), "hostprototype.macros[" ZBX_FS_UI64 "]", hostmacroid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_UPDATE, buf);
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_UPDATE, buf);
}
#define PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE_HOSTMACRO(resource, type1, type2) \
@@ -714,7 +806,7 @@ void zbx_audit_host_prototype_update_json_update_hostmacro_##resource(zbx_uint64
\
zbx_snprintf(buf, sizeof(buf), "hostprototype.macros[" ZBX_FS_UI64 "]."#resource, hostmacroid); \
\
- zbx_audit_update_json_update_##type2(hostid, buf, old_##resource, new_##resource); \
+ zbx_audit_update_json_update_##type2(hostid, AUDIT_HOST_ID, buf, old_##resource, new_##resource); \
} \
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE_HOSTMACRO(value, const char*, string)
@@ -730,7 +822,7 @@ void zbx_audit_host_prototype_update_json_delete_hostmacro(zbx_uint64_t hostid,
zbx_snprintf(buf, sizeof(buf), "hostprototype.macros[" ZBX_FS_UI64 "]", hostmacroid);
- zbx_audit_update_json_delete(hostid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_host_prototype_update_json_add_tag(zbx_uint64_t hostid, zbx_uint64_t tagid, const char* tag,
@@ -745,9 +837,13 @@ void zbx_audit_host_prototype_update_json_add_tag(zbx_uint64_t hostid, zbx_uint6
zbx_snprintf(audit_key_tag, sizeof(audit_key_tag), "hostprototype.tags[" ZBX_FS_UI64 "].tag", tagid);
zbx_snprintf(audit_key_value, sizeof(audit_key_value), "hostprototype.tags[" ZBX_FS_UI64 "].value", tagid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag);
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "host_tag"
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag,
+ AUDIT_TABLE_NAME, "tag");
+ zbx_audit_update_json_append_string(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_host_prototype_update_json_update_tag_create_entry(zbx_uint64_t hostid, zbx_uint64_t tagid)
@@ -758,7 +854,7 @@ void zbx_audit_host_prototype_update_json_update_tag_create_entry(zbx_uint64_t h
zbx_snprintf(buf, sizeof(buf), "hostprototype.tags[" ZBX_FS_UI64 "]", tagid);
- zbx_audit_update_json_append_no_value(hostid, AUDIT_DETAILS_ACTION_UPDATE, buf);
+ zbx_audit_update_json_append_no_value(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_UPDATE, buf);
}
void zbx_audit_host_prototype_update_json_update_tag_tag(zbx_uint64_t hostid, zbx_uint64_t tagid,
@@ -770,7 +866,7 @@ void zbx_audit_host_prototype_update_json_update_tag_tag(zbx_uint64_t hostid, zb
zbx_snprintf(buf, sizeof(buf), "hostprototype.tags[" ZBX_FS_UI64 "].tag", tagid);
- zbx_audit_update_json_update_string(hostid, buf, tag_old, tag_new);
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, buf, tag_old, tag_new);
}
void zbx_audit_host_prototype_update_json_update_tag_value(zbx_uint64_t hostid, zbx_uint64_t tagid,
@@ -782,7 +878,7 @@ void zbx_audit_host_prototype_update_json_update_tag_value(zbx_uint64_t hostid,
zbx_snprintf(buf, sizeof(buf), "hostprototype.tags[" ZBX_FS_UI64 "].value", tagid);
- zbx_audit_update_json_update_string(hostid, buf, value_old, value_new);
+ zbx_audit_update_json_update_string(hostid, AUDIT_HOST_ID, buf, value_old, value_new);
}
void zbx_audit_host_prototype_update_json_delete_tag(zbx_uint64_t hostid, zbx_uint64_t tagid)
@@ -793,7 +889,7 @@ void zbx_audit_host_prototype_update_json_delete_tag(zbx_uint64_t hostid, zbx_ui
zbx_snprintf(buf, sizeof(buf), "hostprototype.tags[" ZBX_FS_UI64 "]", tagid);
- zbx_audit_update_json_delete(hostid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(hostid, AUDIT_HOST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_host_group_create_entry(int audit_action, zbx_uint64_t groupid, const char *name)
@@ -805,6 +901,7 @@ void zbx_audit_host_group_create_entry(int audit_action, zbx_uint64_t groupid, c
local_audit_group_entry.id = groupid;
local_audit_group_entry.cuid = NULL;
+ local_audit_group_entry.id_table = AUDIT_HOSTGRP_ID;
found_audit_group_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(),
&(local_audit_group_entry_x));
@@ -812,7 +909,7 @@ void zbx_audit_host_group_create_entry(int audit_action, zbx_uint64_t groupid, c
{
zbx_audit_entry_t *local_audit_group_entry_insert;
- local_audit_group_entry_insert = zbx_audit_entry_init(groupid, name, audit_action,
+ local_audit_group_entry_insert = zbx_audit_entry_init(groupid, AUDIT_HOSTGRP_ID, name, audit_action,
AUDIT_RESOURCE_HOST_GROUP);
zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_group_entry_insert,
sizeof(local_audit_group_entry_insert));
@@ -830,8 +927,12 @@ void zbx_audit_host_group_update_json_add_details(zbx_uint64_t groupid, const ch
{
RETURN_IF_AUDIT_OFF();
- zbx_audit_update_json_append_string(groupid, AUDIT_DETAILS_ACTION_ADD, "group.name", name);
- zbx_audit_update_json_append_int(groupid, AUDIT_DETAILS_ACTION_ADD, "group.flags", flags);
+#define AUDIT_TABLE_NAME "hstgrp"
+ zbx_audit_update_json_append_string(groupid, AUDIT_HOSTGRP_ID, AUDIT_DETAILS_ACTION_ADD, "group.name", name,
+ AUDIT_TABLE_NAME, "name");
+ zbx_audit_update_json_append_int(groupid, AUDIT_HOSTGRP_ID, AUDIT_DETAILS_ACTION_ADD, "group.flags", flags,
+ AUDIT_TABLE_NAME, "flags");
+#undef AUDIT_TABLE_NAME
}
#define PREPARE_AUDIT_HOST_GROUP_UPDATE(resource, type1, type2) \
@@ -840,7 +941,8 @@ void zbx_audit_host_group_update_json_update_##resource(zbx_uint64_t groupid, ty
{ \
RETURN_IF_AUDIT_OFF(); \
\
- zbx_audit_update_json_update_##type2(groupid, "group."#resource, old_##resource, new_##resource); \
+ zbx_audit_update_json_update_##type2(groupid, AUDIT_HOSTGRP_ID, "group."#resource, old_##resource, \
+ new_##resource); \
} \
PREPARE_AUDIT_HOST_GROUP_UPDATE(name, const char*, string)
diff --git a/src/libs/zbxaudit/audit_host.h b/src/libs/zbxaudit/audit_host.h
index f3e3fb8316f..ab448cae35d 100644
--- a/src/libs/zbxaudit/audit_host.h
+++ b/src/libs/zbxaudit/audit_host.h
@@ -41,10 +41,10 @@ void zbx_audit_##funcname##_update_json_update_snmp_interface(zbx_uint64_t hosti
PREPARE_AUDIT_SNMP_INTERFACE_H(host)
PREPARE_AUDIT_SNMP_INTERFACE_H(host_prototype)
-void zbx_audit_host_update_json_add_proxy_hostid_and_hostname(zbx_uint64_t hostid, zbx_uint64_t proxy_hostid,
- const char *hostname);
+void zbx_audit_host_update_json_add_proxy_hostid_and_hostname_and_inventory_mode(zbx_uint64_t hostid,
+ zbx_uint64_t proxy_hostid, const char *hostname, int inventory_mode);
void zbx_audit_host_update_json_add_tls_and_psk(zbx_uint64_t hostid, int tls_connect, int tls_accept,
- const char *psk_identity, const char *psk);
+ const char *tls_psk_identity, const char *tls_psk);
void zbx_audit_host_update_json_add_inventory_mode(zbx_uint64_t hostid, int inventory_mode);
void zbx_audit_host_update_json_update_inventory_mode(zbx_uint64_t hostid, int inventory_mode_old,
int inventory_mode_new);
@@ -83,7 +83,7 @@ PREPARE_AUDIT_HOST_INTERFACE_H(funcname, contextname, const char*) \
PREPARE_AUDIT_HOST_H(host, AUDIT_RESOURCE_HOST)
PREPARE_AUDIT_HOST_H(host_prototype, AUDIT_RESOURCE_HOST_PROTOTYPE)
-#define PREPARE_AUDIT_HOST_UPDATE_H(resource, type1) \
+#define PREPARE_AUDIT_HOST_UPDATE_H(resource, type1) \
void zbx_audit_host_update_json_update_##resource(zbx_uint64_t hostid, type1 old_##resource, \
type1 new_##resource); \
@@ -104,7 +104,6 @@ PREPARE_AUDIT_HOST_UPDATE_H(custom_interfaces, int)
#undef PREPARE_AUDIT_HOST_UPDATE_H
void zbx_audit_host_update_json_delete_interface(zbx_uint64_t hostid, zbx_uint64_t interfaceid);
-
void zbx_audit_host_update_json_add_hostmacro(zbx_uint64_t hostid, zbx_uint64_t macroid,
const char *macro, const char *value, const char *description, int type);
@@ -137,10 +136,10 @@ void zbx_audit_host_del(zbx_uint64_t hostid, const char *hostname);
void zbx_audit_host_update_json_add_details(zbx_uint64_t hostid, const char *host, zbx_uint64_t proxy_hostid,
int ipmi_authtype, int ipmi_privilege, const char *ipmi_username, const char *ipmi_password,
int status, int flags, int tls_connect, int tls_accept, const char *tls_issuer, const char *tls_subject,
- const char *tls_psk_identity, const char *tls_psk, int custom_interfaces);
+ const char *tls_psk_identity, const char *tls_psk, int custom_interfaces, int inventory_mode);
void zbx_audit_host_prototype_del(zbx_uint64_t hostid, const char *hostname);
void zbx_audit_host_prototype_update_json_add_details(zbx_uint64_t hostid, zbx_uint64_t templateid, const char *name,
- int status, int discover, int custom_interfaces);
+ int status, int discover, int custom_interfaces, int inventory_mode);
void zbx_audit_host_prototype_update_json_update_templateid(zbx_uint64_t hostid, zbx_uint64_t templateid_orig,
zbx_uint64_t templateid);
@@ -152,6 +151,7 @@ PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE_H(name, const char*)
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE_H(status, int)
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE_H(discover, int)
PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE_H(custom_interfaces, int)
+PREPARE_AUDIT_HOST_PROTOTYPE_UPDATE_H(inventory_mode, int)
void zbx_audit_host_prototype_update_json_add_group_details(zbx_uint64_t hostid, zbx_uint64_t group_prototypeid,
const char* name, zbx_uint64_t groupid, zbx_uint64_t templateid);
@@ -202,7 +202,7 @@ void zbx_audit_host_group_create_entry(int audit_action, zbx_uint64_t groupid, c
void zbx_audit_host_group_del(zbx_uint64_t groupid, const char *name);
void zbx_audit_host_group_update_json_add_details(zbx_uint64_t groupid, const char *name, int flags);
-#define PREPARE_AUDIT_HOST_GROUP_UPDATE_H(resource, type1) \
+#define PREPARE_AUDIT_HOST_GROUP_UPDATE_H(resource, type1) \
void zbx_audit_host_group_update_json_update_##resource(zbx_uint64_t groupid, type1 old_##resource, \
type1 new_##resource); \
diff --git a/src/libs/zbxaudit/audit_httptest.c b/src/libs/zbxaudit/audit_httptest.c
index 877c8f52205..4db08cec07b 100644
--- a/src/libs/zbxaudit/audit_httptest.c
+++ b/src/libs/zbxaudit/audit_httptest.c
@@ -31,6 +31,7 @@ void zbx_audit_httptest_create_entry(int audit_action, zbx_uint64_t httptestid,
local_audit_httptest_entry.id = httptestid;
local_audit_httptest_entry.cuid = NULL;
+ local_audit_httptest_entry.id_table = AUDIT_HTTPTEST_ID;
found_audit_httptest_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(),
&(local_audit_httptest_entry_x));
@@ -39,14 +40,8 @@ void zbx_audit_httptest_create_entry(int audit_action, zbx_uint64_t httptestid,
{
zbx_audit_entry_t *local_audit_httptest_entry_insert;
- local_audit_httptest_entry_insert = (zbx_audit_entry_t*)zbx_malloc(NULL,
- sizeof(zbx_audit_entry_t));
-
- local_audit_httptest_entry_insert->id = httptestid;
- local_audit_httptest_entry_insert->name = zbx_strdup(NULL, name);
- local_audit_httptest_entry_insert->audit_action = audit_action;
- local_audit_httptest_entry_insert->resource_type = AUDIT_RESOURCE_SCENARIO;
- zbx_json_init(&(local_audit_httptest_entry_insert->details_json), ZBX_JSON_STAT_BUF_LEN);
+ local_audit_httptest_entry_insert = zbx_audit_entry_init(httptestid, AUDIT_HTTPTEST_ID, name,
+ audit_action, AUDIT_RESOURCE_SCENARIO);
zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_httptest_entry_insert,
sizeof(local_audit_httptest_entry_insert));
@@ -55,8 +50,9 @@ void zbx_audit_httptest_create_entry(int audit_action, zbx_uint64_t httptestid,
void zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64_t templateid, const char *name,
const char *delay, unsigned char status, const char *agent, unsigned char authentication,
- const char *httpuser, const char *http_proxy, int retries, const char *ssl_cert_file,
- const char *ssl_key_file, int verify_peer, int verify_host, zbx_uint64_t hostid)
+ const char *httpuser, const char *httppassword, const char *http_proxy, int retries,
+ const char *ssl_cert_file, const char *ssl_key_file, const char *ssl_key_password, int verify_peer,
+ int verify_host, zbx_uint64_t hostid)
{
char audit_key_templateid[AUDIT_DETAILS_KEY_LEN], audit_key_name[AUDIT_DETAILS_KEY_LEN],
audit_key_delay[AUDIT_DETAILS_KEY_LEN], audit_key_status[AUDIT_DETAILS_KEY_LEN],
@@ -69,7 +65,9 @@ void zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64
RETURN_IF_AUDIT_OFF();
#define AUDIT_KEY_SNPRINTF(r) zbx_snprintf(audit_key_##r, sizeof(audit_key_##r), "httptest."#r);
- zbx_audit_update_json_append_uint64(httptestid, AUDIT_DETAILS_ACTION_ADD, "httptest.httptestid", httptestid);
+#define AUDIT_TABLE_NAME "httptest"
+ zbx_audit_update_json_append_uint64(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ "httptest.httptestid", httptestid, AUDIT_TABLE_NAME, "httptestid");
AUDIT_KEY_SNPRINTF(templateid)
AUDIT_KEY_SNPRINTF(name)
AUDIT_KEY_SNPRINTF(delay)
@@ -85,27 +83,31 @@ void zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64
AUDIT_KEY_SNPRINTF(verify_host)
AUDIT_KEY_SNPRINTF(hostid)
#undef AUDIT_KEY_SNPRINTF
-#define ADD_STR(r) zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_UINT64(r) zbx_audit_update_json_append_uint64(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_INT(r) zbx_audit_update_json_append_int(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
- ADD_UINT64(templateid)
- ADD_STR(name)
- ADD_STR(delay)
- ADD_INT(status)
- ADD_STR(agent)
- ADD_INT(authentication)
- ADD_STR(httpuser)
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, "httptest.httppassword",
- ZBX_MACRO_SECRET_MASK);
- ADD_STR(http_proxy)
- ADD_INT(retries)
- ADD_STR(ssl_cert_file)
- ADD_STR(ssl_key_file)
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, "httptest.ssl_key_password",
- ZBX_MACRO_SECRET_MASK);
- ADD_INT(verify_peer)
- ADD_INT(verify_host)
- ADD_UINT64(hostid)
+#define ADD_STR(r, t, f) zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_UINT64(r, t, f) zbx_audit_update_json_append_uint64(httptestid, AUDIT_HTTPTEST_ID, \
+ AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r, t, f);
+#define ADD_INT(r, t, f) zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+ ADD_UINT64(templateid, AUDIT_TABLE_NAME, "templateid")
+ ADD_STR(name, AUDIT_TABLE_NAME, "name")
+ ADD_STR(delay, AUDIT_TABLE_NAME, "delay")
+ ADD_INT(status, AUDIT_TABLE_NAME, "status")
+ ADD_STR(agent, AUDIT_TABLE_NAME, "agent")
+ ADD_INT(authentication, AUDIT_TABLE_NAME, "authentication")
+ ADD_STR(httpuser, AUDIT_TABLE_NAME, "http_user")
+ zbx_audit_update_json_append_string_secret(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ "httptest.httppassword", httppassword, AUDIT_TABLE_NAME, "http_password");
+ ADD_STR(http_proxy, AUDIT_TABLE_NAME, "http_proxy")
+ ADD_INT(retries, AUDIT_TABLE_NAME, "retries")
+ ADD_STR(ssl_cert_file, AUDIT_TABLE_NAME, "ssl_cert_file")
+ ADD_STR(ssl_key_file, AUDIT_TABLE_NAME, "ssl_key_file")
+ zbx_audit_update_json_append_string_secret(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ "httptest.ssl_key_password", ssl_key_password, AUDIT_TABLE_NAME, "ssl_key_password");
+ ADD_INT(verify_peer, AUDIT_TABLE_NAME, "verify_peer")
+ ADD_INT(verify_host, AUDIT_TABLE_NAME, "verify_host")
+ ADD_UINT64(hostid, AUDIT_TABLE_NAME, "hostid")
+#undef AUDIT_TABLE_NAME
#undef ADD_STR
#undef ADD_UINT64
#undef ADD_INT
@@ -121,7 +123,8 @@ void zbx_audit_httptest_update_json_update_##resource(zbx_uint64_t httptestid, t
\
zbx_snprintf(buf, sizeof(buf), "httptest."#resource); \
\
- zbx_audit_update_json_update_##type2(httptestid, buf, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(httptestid, AUDIT_HTTPTEST_ID, buf, resource##_old, \
+ resource##_new); \
}
PREPARE_AUDIT_HTTPTEST_UPDATE(templateid, zbx_uint64_t, uint64)
@@ -178,9 +181,13 @@ void zbx_audit_httptest_update_json_add_httptest_tag(zbx_uint64_t httptestid, zb
zbx_snprintf(audit_key_tag, sizeof(audit_key_tag), "httptest.tags[" ZBX_FS_UI64 "].tag", tagid);
zbx_snprintf(audit_key_value, sizeof(audit_key_value), "httptest.tags[" ZBX_FS_UI64 "].value", tagid);
- zbx_audit_update_json_append_no_value(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "httptest_tag"
+ zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_tag,
+ tag, AUDIT_TABLE_NAME, "tag");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value,
+ value, AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_httptest_update_json_delete_tags(zbx_uint64_t httptestid, zbx_uint64_t tagid)
@@ -191,7 +198,7 @@ void zbx_audit_httptest_update_json_delete_tags(zbx_uint64_t httptestid, zbx_uin
zbx_snprintf(buf, sizeof(buf), "httptest.tags[" ZBX_FS_UI64 "]", tagid);
- zbx_audit_update_json_append_no_value(httptestid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_httptest_update_json_add_httptest_httpstep(zbx_uint64_t httptestid, zbx_uint64_t httpstepid,
@@ -211,7 +218,8 @@ void zbx_audit_httptest_update_json_add_httptest_httpstep(zbx_uint64_t httptesti
zbx_snprintf(audit_key_name, sizeof(audit_key_name), "httptest.steps[" ZBX_FS_UI64 "].name", httpstepid);
zbx_snprintf(audit_key_no, sizeof(audit_key_no), "httptest.steps[" ZBX_FS_UI64 "].no", httpstepid);
zbx_snprintf(audit_key_url, sizeof(audit_key_url), "httptest.steps[" ZBX_FS_UI64 "].url", httpstepid);
- zbx_snprintf(audit_key_timeout, sizeof(audit_key_timeout), "httptest.steps[" ZBX_FS_UI64 "].timeout", httpstepid);
+ zbx_snprintf(audit_key_timeout, sizeof(audit_key_timeout), "httptest.steps[" ZBX_FS_UI64 "].timeout",
+ httpstepid);
zbx_snprintf(audit_key_posts, sizeof(audit_key_posts), "httptest.steps[" ZBX_FS_UI64 "].posts", httpstepid);
zbx_snprintf(audit_key_required, sizeof(audit_key_required), "httptest.steps[" ZBX_FS_UI64 "].required",
httpstepid);
@@ -224,22 +232,32 @@ void zbx_audit_httptest_update_json_add_httptest_httpstep(zbx_uint64_t httptesti
zbx_snprintf(audit_key_post_type, sizeof(audit_key_post_type), "httptest.steps[" ZBX_FS_UI64 "].post_type",
httpstepid);
- zbx_audit_update_json_append_no_value(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name);
- zbx_audit_update_json_append_int(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_no, no);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_url, url);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_timeout, timeout);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_posts, posts);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_required, required);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_status_codes, status_codes);
- zbx_audit_update_json_append_int(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_follow_redirects,
- follow_redirects);
- zbx_audit_update_json_append_int(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_retrieve_mode, retrieve_mode);
- zbx_audit_update_json_append_int(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_post_type, post_type);
+#define AUDIT_TABLE_NAME "httpstep"
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name,
+ name, AUDIT_TABLE_NAME, "name");
+ zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_no, no,
+ AUDIT_TABLE_NAME, "no");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_url,
+ url, AUDIT_TABLE_NAME, "url");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_timeout,
+ timeout, AUDIT_TABLE_NAME, "timeout");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_posts,
+ posts, AUDIT_TABLE_NAME, "posts");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ audit_key_required, required, AUDIT_TABLE_NAME, "required");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ audit_key_status_codes, status_codes, AUDIT_TABLE_NAME, "status_codes");
+ zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ audit_key_follow_redirects, follow_redirects, AUDIT_TABLE_NAME, "follow_redirects");
+ zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ audit_key_retrieve_mode, retrieve_mode, AUDIT_TABLE_NAME, "retrieve_mode");
+ zbx_audit_update_json_append_int(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD,
+ audit_key_post_type, post_type, AUDIT_TABLE_NAME, "post_type");
+#undef AUDIT_TABLE_NAME
}
#define PREPARE_AUDIT_HTTPSTEP_UPDATE(resource, type1, type2) \
-void zbx_audit_httptest_update_json_httpstep_update_##resource(zbx_uint64_t httptestid, \
+void zbx_audit_httptest_update_json_httpstep_update_##resource(zbx_uint64_t httptestid, \
zbx_uint64_t httpstepid, type1 resource##_old, type1 resource##_new) \
{ \
char buf[AUDIT_DETAILS_KEY_LEN]; \
@@ -248,7 +266,8 @@ void zbx_audit_httptest_update_json_httpstep_update_##resource(zbx_uint64_t http
\
zbx_snprintf(buf, sizeof(buf), "httptest.steps[" ZBX_FS_UI64 "]."#resource, httpstepid); \
\
- zbx_audit_update_json_update_##type2(httptestid, buf, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(httptestid, AUDIT_HTTPTEST_ID, buf, resource##_old, \
+ resource##_new); \
}
PREPARE_AUDIT_HTTPSTEP_UPDATE(url, const char*, string)
@@ -303,9 +322,13 @@ void zbx_audit_httptest_update_json_add_httptest_field(zbx_uint64_t httptestid,
zbx_snprintf(audit_key_value, sizeof(audit_key_value), "httptest.%s[" ZBX_FS_UI64 "].value", audit_key_type,
httptestfieldid);
- zbx_audit_update_json_append_no_value(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "httpstep_field"
+ zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name,
+ name, AUDIT_TABLE_NAME, "name");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value,
+ value, AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_httptest_update_json_delete_httptest_field(zbx_uint64_t httptestid, zbx_uint64_t fieldid, int type)
@@ -317,7 +340,7 @@ void zbx_audit_httptest_update_json_delete_httptest_field(zbx_uint64_t httptesti
zbx_snprintf(audit_key_type, sizeof(audit_key_type), "%s", field_type_to_name(type));
zbx_snprintf(audit_key, sizeof(audit_key), "httptest.%s[" ZBX_FS_UI64 "]",audit_key_type, fieldid);
- zbx_audit_update_json_append_no_value(httptestid, AUDIT_DETAILS_ACTION_DELETE, audit_key);
+ zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key);
}
void zbx_audit_httptest_update_json_add_httpstep_field(zbx_uint64_t httptestid, zbx_uint64_t httpstepid,
@@ -336,10 +359,13 @@ void zbx_audit_httptest_update_json_add_httpstep_field(zbx_uint64_t httptestid,
zbx_snprintf(audit_key_value, sizeof(audit_key_value),
"httptest.steps[" ZBX_FS_UI64 "].%s[" ZBX_FS_UI64 "].value", httpstepid, audit_key_type,
httpstepfieldid);
-
- zbx_audit_update_json_append_no_value(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name);
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "httpstep_field"
+ zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name,
+ name, AUDIT_TABLE_NAME, "name");
+ zbx_audit_update_json_append_string(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value,
+ value, AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_httptest_update_json_delete_httpstep_field(zbx_uint64_t httptestid, zbx_uint64_t httpstepid,
@@ -353,5 +379,5 @@ void zbx_audit_httptest_update_json_delete_httpstep_field(zbx_uint64_t httptesti
zbx_snprintf(audit_key, sizeof(audit_key), "httptest.steps[" ZBX_FS_UI64 "].%s[" ZBX_FS_UI64 "]",
httpstepid, audit_key_type, fieldid);
- zbx_audit_update_json_append_no_value(httptestid, AUDIT_DETAILS_ACTION_DELETE, audit_key);
+ zbx_audit_update_json_append_no_value(httptestid, AUDIT_HTTPTEST_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key);
}
diff --git a/src/libs/zbxaudit/audit_httptest.h b/src/libs/zbxaudit/audit_httptest.h
index 79de31a6073..2850da900cd 100644
--- a/src/libs/zbxaudit/audit_httptest.h
+++ b/src/libs/zbxaudit/audit_httptest.h
@@ -29,8 +29,9 @@ void zbx_audit_httptest_create_entry(int audit_action, zbx_uint64_t httptestid,
void zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64_t templateid, const char *name,
const char *delay, unsigned char status, const char *agent, unsigned char authentication,
- const char *httpuser, const char *http_proxy, int retries, const char *ssl_cert_file,
- const char *ssl_key_file, int verify_peer, int verify_host, zbx_uint64_t hostid);
+ const char *httpuser, const char *httppassword, const char *http_proxy, int retries,
+ const char *ssl_cert_file, const char *ssl_key_file, const char *ssl_key_password, int verify_peer,
+ int verify_host, zbx_uint64_t hostid);
#define PREPARE_AUDIT_HTTPTEST_UPDATE_H(resource, type1) \
void zbx_audit_httptest_update_json_update_##resource(zbx_uint64_t httptestid, type1 resource##_old, \
diff --git a/src/libs/zbxaudit/audit_item.c b/src/libs/zbxaudit/audit_item.c
index 30dff344caf..1eadbc106cc 100644
--- a/src/libs/zbxaudit/audit_item.c
+++ b/src/libs/zbxaudit/audit_item.c
@@ -57,14 +57,15 @@ void zbx_audit_item_create_entry(int audit_action, zbx_uint64_t itemid, const ch
local_audit_item_entry.id = itemid;
local_audit_item_entry.cuid = NULL;
-
+ local_audit_item_entry.id_table = AUDIT_ITEM_ID;
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_init(itemid, name, audit_action, resource_type);
+ local_audit_item_entry_insert = zbx_audit_entry_init(itemid, AUDIT_ITEM_ID, name, audit_action,
+ resource_type);
zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_item_entry_insert,
sizeof(local_audit_item_entry_insert));
@@ -86,123 +87,134 @@ void zbx_audit_item_update_json_add_data(zbx_uint64_t itemid, const zbx_template
#define ONLY_ITEM_AND_ITEM_PROTOTYPE (AUDIT_RESOURCE_ITEM == resource_type || \
AUDIT_RESOURCE_ITEM_PROTOTYPE == resource_type)
-#define ADD_JSON_S(x) zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(x),\
- item->x)
-#define ADD_JSON_UI(x) zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(x),\
- item->x)
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(itemid), itemid);
- ADD_JSON_S(delay);
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(hostid), hostid);
- 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);
+#define ADD_JSON_S(x, t, f) zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,\
+ IT_OR_ITP_OR_DR(x), item->x, t, f)
+#define ADD_JSON_UI(x, t, f) zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,\
+ IT_OR_ITP_OR_DR(x), item->x, t, f)
+#define AUDIT_TABLE_NAME "items"
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(itemid),
+ itemid, AUDIT_TABLE_NAME, "itemid");
+ ADD_JSON_S(delay, AUDIT_TABLE_NAME, "delay");
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(hostid),
+ hostid, AUDIT_TABLE_NAME, "hostid");
+ ADD_JSON_UI(interfaceid, AUDIT_TABLE_NAME, "interfaceid");
+ ADD_JSON_S(key, AUDIT_TABLE_NAME, "key_");
+ ADD_JSON_S(name, AUDIT_TABLE_NAME, "name");
+ ADD_JSON_UI(type, AUDIT_TABLE_NAME, "type");
+ ADD_JSON_S(url, AUDIT_TABLE_NAME, "url");
if ONLY_ITEM_AND_ITEM_PROTOTYPE
{
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ? "item.value_type" :
- "itemprototype.value_type", item->value_type);
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ?
+ "item.value_type" : "itemprototype.value_type", item->value_type, AUDIT_TABLE_NAME,
+ "value_type");
}
- ADD_JSON_UI(allow_traps);
- ADD_JSON_UI(authtype);
- ADD_JSON_S(description);
+ ADD_JSON_UI(allow_traps, AUDIT_TABLE_NAME, "allow_traps");
+ ADD_JSON_UI(authtype, AUDIT_TABLE_NAME, "authtype");
+ ADD_JSON_S(description, AUDIT_TABLE_NAME, "description");
if ONLY_ITEM
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, "item.flags", item->flags);
+ {
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, "item.flags",
+ item->flags, AUDIT_TABLE_NAME, "flags");
+ }
- ADD_JSON_UI(follow_redirects);
- ADD_JSON_S(headers);
+ ADD_JSON_UI(follow_redirects, AUDIT_TABLE_NAME, "follow_redirects");
+ ADD_JSON_S(headers, AUDIT_TABLE_NAME, "headers");
if ONLY_ITEM_AND_ITEM_PROTOTYPE
{
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ? "item.history" :
- "itemprototype.history", item->history);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ?
+ "item.history" : "itemprototype.history", item->history, AUDIT_TABLE_NAME, "history");
}
- ADD_JSON_S(http_proxy);
+ ADD_JSON_S(http_proxy, AUDIT_TABLE_NAME, "http_proxy");
if ONLY_ITEM
{
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, "item.inventory_link",
- item->inventory_link);
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ "item.inventory_link", item->inventory_link, AUDIT_TABLE_NAME, "inventory_link");
}
- ADD_JSON_S(ipmi_sensor);
- ADD_JSON_S(jmx_endpoint);
+ ADD_JSON_S(ipmi_sensor, AUDIT_TABLE_NAME, "ipmi_sensor");
+ ADD_JSON_S(jmx_endpoint, AUDIT_TABLE_NAME, "jmx_endpoint");
if ONLY_LLD_RULE
{
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, "discoveryrule.lifetime",
- item->lifetime);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ "discoveryrule.lifetime", item->lifetime, AUDIT_TABLE_NAME, "lifetime");
}
if ONLY_ITEM_AND_ITEM_PROTOTYPE
{
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ? "item.logtimefmt" :
- "itemprototype.logtimefmt", item->logtimefmt);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ?
+ "item.logtimefmt" : "itemprototype.logtimefmt", item->logtimefmt, AUDIT_TABLE_NAME,
+ "logtimefmt");
}
- ADD_JSON_UI(master_itemid);
- ADD_JSON_UI(output_format);
- ADD_JSON_S(params);
-
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(password),
- ZBX_MACRO_SECRET_MASK);
-
- ADD_JSON_UI(post_type);
- ADD_JSON_S(posts);
- 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);
-
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(ssl_key_password),
- ZBX_MACRO_SECRET_MASK);
-
- ADD_JSON_UI(status);
- ADD_JSON_S(status_codes);
- ADD_JSON_UI(templateid);
- ADD_JSON_S(timeout);
- ADD_JSON_S(trapper_hosts);
+ ADD_JSON_UI(master_itemid, AUDIT_TABLE_NAME, "master_itemid");
+ ADD_JSON_UI(output_format, AUDIT_TABLE_NAME, "output_format");
+ ADD_JSON_S(params, AUDIT_TABLE_NAME, "params");
+
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ IT_OR_ITP_OR_DR(password), item->password, AUDIT_TABLE_NAME, "password");
+
+ ADD_JSON_UI(post_type, AUDIT_TABLE_NAME, "post_type");
+ ADD_JSON_S(posts, AUDIT_TABLE_NAME, "posts");
+ ADD_JSON_S(privatekey, AUDIT_TABLE_NAME, "privatekey");
+ ADD_JSON_S(publickey, AUDIT_TABLE_NAME, "publickey");
+ ADD_JSON_S(query_fields, AUDIT_TABLE_NAME, "query_fields");
+ ADD_JSON_UI(request_method, AUDIT_TABLE_NAME, "request_method");
+ ADD_JSON_UI(retrieve_mode, AUDIT_TABLE_NAME, "retrieve_mode");
+ ADD_JSON_S(snmp_oid, AUDIT_TABLE_NAME, "snmp_oid");
+ ADD_JSON_S(ssl_cert_file, AUDIT_TABLE_NAME, "ssl_cert_file");
+ ADD_JSON_S(ssl_key_file, AUDIT_TABLE_NAME, "ssl_key_file");
+
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ IT_OR_ITP_OR_DR(ssl_key_password), item->ssl_key_password, AUDIT_TABLE_NAME,
+ "ssl_key_password");
+
+ ADD_JSON_UI(status, AUDIT_TABLE_NAME, "status");
+ ADD_JSON_S(status_codes, AUDIT_TABLE_NAME, "status_codes");
+ ADD_JSON_UI(templateid, AUDIT_TABLE_NAME, "templateid");
+ ADD_JSON_S(timeout, AUDIT_TABLE_NAME, "timeout");
+ ADD_JSON_S(trapper_hosts, AUDIT_TABLE_NAME, "trapper_hosts");
if ONLY_ITEM_AND_ITEM_PROTOTYPE
{
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ? "item.trends" :
- "itemprototype.trends", item->trends);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ? "item.units" :
- "itemprototype.units", item->units);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ?
+ "item.trends" : "itemprototype.trends", item->trends, AUDIT_TABLE_NAME, "trends");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ?
+ "item.units" : "itemprototype.units", item->units, AUDIT_TABLE_NAME, "units");
}
- ADD_JSON_S(username);
+ ADD_JSON_S(username, AUDIT_TABLE_NAME, "username");
if ONLY_ITEM_AND_ITEM_PROTOTYPE
{
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ? "item.valuemapid" :
- "itemprototype.valuemapid", item->valuemapid);
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, ONLY_ITEM ?
+ "item.valuemapid" : "itemprototype.valuemapid", item->valuemapid, AUDIT_TABLE_NAME,
+ "valuemapid");
}
- ADD_JSON_UI(verify_host);
- ADD_JSON_UI(verify_peer);
+ ADD_JSON_UI(verify_host, AUDIT_TABLE_NAME, "verify_host");
+ ADD_JSON_UI(verify_peer, AUDIT_TABLE_NAME, "verify_peer");
if ONLY_ITEM_PROTOTYPE
{
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, "itemprototype.discover",
- item->discover);
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ "itemprototype.discover", item->discover, AUDIT_TABLE_NAME, "discover");
}
if ONLY_LLD_RULE
{
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD,
- "discoveryrule.filter.formula", item->formula);
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD,
- "discoveryrule.filter.evaltype", item->evaltype);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ "discoveryrule.filter.formula", item->formula, AUDIT_TABLE_NAME, "formula");
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ "discoveryrule.filter.evaltype", item->evaltype, AUDIT_TABLE_NAME, "evaltype");
}
+#undef AUDIT_TABLE_NAME
#undef ADD_JSON_UI
#undef ADD_JSON_S
}
@@ -213,59 +225,68 @@ void zbx_audit_item_update_json_add_lld_data(zbx_uint64_t itemid, const zbx_lld_
RETURN_IF_AUDIT_OFF();
#define IT(s) "item."#s
-#define ADD_JSON_S(x) zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT(x), item->x)
-#define ADD_JSON_UI(x) zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT(x), item->x)
-#define ADD_JSON_P_S(x) zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT(x), item_prototype->x)
-#define ADD_JSON_P_UI(x) zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT(x),\
- item_prototype->x)
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT(itemid), itemid);
- ADD_JSON_S(delay);
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, IT(hostid), hostid);
- ADD_JSON_S(name);
- ADD_JSON_S(key);
- ADD_JSON_P_UI(type);
- ADD_JSON_P_UI(value_type);
- ADD_JSON_S(history);
- ADD_JSON_S(trends);
- ADD_JSON_UI(status);
- ADD_JSON_P_S(trapper_hosts);
- ADD_JSON_S(units);
- ADD_JSON_P_S(formula);
- ADD_JSON_P_S(logtimefmt);
- ADD_JSON_P_UI(valuemapid);
- ADD_JSON_S(params);
- ADD_JSON_S(ipmi_sensor);
- ADD_JSON_S(snmp_oid);
- ADD_JSON_P_UI(authtype);
- ADD_JSON_S(username);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT(password), ZBX_MACRO_SECRET_MASK);
- ADD_JSON_P_S(publickey);
- ADD_JSON_P_S(privatekey);
- ADD_JSON_S(description);
- ADD_JSON_P_UI(interfaceid);
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, "item.flags", ZBX_FLAG_DISCOVERY_CREATED);
- ADD_JSON_S(jmx_endpoint);
- ADD_JSON_UI(master_itemid);
- ADD_JSON_S(timeout);
- ADD_JSON_S(url);
- ADD_JSON_S(query_fields);
- ADD_JSON_S(posts);
- ADD_JSON_S(status_codes);
- ADD_JSON_P_UI(follow_redirects);
- ADD_JSON_P_UI(post_type);
- ADD_JSON_S(http_proxy);
- ADD_JSON_S(headers);
- ADD_JSON_P_UI(retrieve_mode);
- ADD_JSON_P_UI(request_method);
- ADD_JSON_P_UI(output_format);
- ADD_JSON_S(ssl_cert_file);
- ADD_JSON_S(ssl_key_file);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT(ssl_key_password),
- ZBX_MACRO_SECRET_MASK);
- ADD_JSON_P_UI(verify_peer);
- ADD_JSON_P_UI(verify_host);
- ADD_JSON_P_UI(allow_traps);
-
+#define ADD_JSON_S(x, t, f) zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, \
+ IT(x), item->x, t, f)
+#define ADD_JSON_UI(x, t, f) zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, \
+ IT(x), item->x, t, f)
+#define ADD_JSON_P_S(x, t, f) zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, \
+ IT(x), item_prototype->x, t, f)
+#define ADD_JSON_P_UI(x, t, f) zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, \
+ IT(x), item_prototype->x, t, f)
+#define AUDIT_TABLE_NAME "items"
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, IT(itemid), itemid, \
+ AUDIT_TABLE_NAME, "itemid");
+ ADD_JSON_S(delay, AUDIT_TABLE_NAME, "delay");
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, IT(hostid), hostid, \
+ AUDIT_TABLE_NAME, "hostid");
+ ADD_JSON_S(name, AUDIT_TABLE_NAME, "name");
+ ADD_JSON_S(key, AUDIT_TABLE_NAME, "key_");
+ ADD_JSON_P_UI(type, AUDIT_TABLE_NAME, "type");
+ ADD_JSON_P_UI(value_type, AUDIT_TABLE_NAME, "value_type");
+ ADD_JSON_S(history, AUDIT_TABLE_NAME, "history");
+ ADD_JSON_S(trends, AUDIT_TABLE_NAME, "trends");
+ ADD_JSON_UI(status, AUDIT_TABLE_NAME, "status");
+ ADD_JSON_P_S(trapper_hosts, AUDIT_TABLE_NAME, "trapper_hosts");
+ ADD_JSON_S(units, AUDIT_TABLE_NAME, "units");
+ ADD_JSON_P_S(formula, AUDIT_TABLE_NAME, "formula");
+ ADD_JSON_P_S(logtimefmt, AUDIT_TABLE_NAME, "logtimefmt");
+ ADD_JSON_P_UI(valuemapid, AUDIT_TABLE_NAME, "valuemapid");
+ ADD_JSON_S(params, AUDIT_TABLE_NAME, "params");
+ ADD_JSON_S(ipmi_sensor, AUDIT_TABLE_NAME, "ipmi_sensor");
+ ADD_JSON_S(snmp_oid, AUDIT_TABLE_NAME, "snmp_oid");
+ ADD_JSON_P_UI(authtype, AUDIT_TABLE_NAME, "authtype");
+ ADD_JSON_S(username, AUDIT_TABLE_NAME, "username");
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, IT(password),
+ item->password, AUDIT_TABLE_NAME, "password");
+ ADD_JSON_P_S(publickey, AUDIT_TABLE_NAME, "publickey");
+ ADD_JSON_P_S(privatekey, AUDIT_TABLE_NAME, "privatekey");
+ ADD_JSON_S(description, AUDIT_TABLE_NAME, "description");
+ ADD_JSON_P_UI(interfaceid, AUDIT_TABLE_NAME, "interfaceid");
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, "item.flags",
+ ZBX_FLAG_DISCOVERY_CREATED, AUDIT_TABLE_NAME, "flags");
+ ADD_JSON_S(jmx_endpoint, AUDIT_TABLE_NAME, "jmx_endpoint");
+ ADD_JSON_UI(master_itemid, AUDIT_TABLE_NAME, "master_itemid");
+ ADD_JSON_S(timeout, AUDIT_TABLE_NAME, "timeout");
+ ADD_JSON_S(url, AUDIT_TABLE_NAME, "url");
+ ADD_JSON_S(query_fields, AUDIT_TABLE_NAME, "query_fields");
+ ADD_JSON_S(posts, AUDIT_TABLE_NAME, "posts");
+ ADD_JSON_S(status_codes, AUDIT_TABLE_NAME, "status_codes");
+ ADD_JSON_P_UI(follow_redirects, AUDIT_TABLE_NAME, "follow_redirects");
+ ADD_JSON_P_UI(post_type, AUDIT_TABLE_NAME, "post_type");
+ ADD_JSON_S(http_proxy, AUDIT_TABLE_NAME, "http_proxy");
+ ADD_JSON_S(headers, AUDIT_TABLE_NAME, "headers");
+ ADD_JSON_P_UI(retrieve_mode, AUDIT_TABLE_NAME, "retrieve_mode");
+ ADD_JSON_P_UI(request_method, AUDIT_TABLE_NAME, "request_method");
+ ADD_JSON_P_UI(output_format, AUDIT_TABLE_NAME, "output_format");
+ ADD_JSON_S(ssl_cert_file, AUDIT_TABLE_NAME, "ssl_cert_file");
+ ADD_JSON_S(ssl_key_file, AUDIT_TABLE_NAME, "ssl_key_file");
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ IT(ssl_key_password), item->ssl_key_password, AUDIT_TABLE_NAME, "ssl_key_password");
+ ADD_JSON_P_UI(verify_peer, AUDIT_TABLE_NAME, "verify_peer");
+ ADD_JSON_P_UI(verify_host, AUDIT_TABLE_NAME, "verify_host");
+ ADD_JSON_P_UI(allow_traps, AUDIT_TABLE_NAME, "allow_traps");
+
+#undef AUDIT_TABLE_NAME
#undef ADD_JSON_UI
#undef ADD_JSON_S
#undef ADD_JSON_P_UI
@@ -282,7 +303,8 @@ void zbx_audit_item_update_json_update_##resource(zbx_uint64_t itemid, int flags
RETURN_IF_AUDIT_OFF(); \
\
resource_type = item_flag_to_resource_type(flags); \
- zbx_audit_update_json_update_##type2(itemid, IT_OR_ITP_OR_DR(resource), resource##_old, resource##_new);\
+ zbx_audit_update_json_update_##type2(itemid, AUDIT_ITEM_ID, IT_OR_ITP_OR_DR(resource), resource##_old, \
+ resource##_new); \
}
PREPARE_AUDIT_ITEM_UPDATE(interfaceid, zbx_uint64_t, uint64)
@@ -363,6 +385,7 @@ void zbx_audit_item_create_entry_for_delete(zbx_uint64_t id, const char *name, i
local_audit_item_entry.id = id;
local_audit_item_entry.cuid = NULL;
+ local_audit_item_entry.id_table = AUDIT_ITEM_ID;
found_audit_item_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(),
&(local_audit_item_entry_x));
@@ -370,7 +393,8 @@ void zbx_audit_item_create_entry_for_delete(zbx_uint64_t id, const char *name, i
{
zbx_audit_entry_t *local_audit_item_entry_insert;
- local_audit_item_entry_insert = zbx_audit_entry_init(id, name, AUDIT_ACTION_DELETE, resource_type);
+ local_audit_item_entry_insert = zbx_audit_entry_init(id, AUDIT_ITEM_ID, name, AUDIT_ACTION_DELETE,
+ resource_type);
zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_item_entry_insert,
sizeof(local_audit_item_entry_insert));
}
@@ -429,10 +453,15 @@ void zbx_audit_discovery_rule_update_json_add_filter_conditions(zbx_uint64_t ite
zbx_snprintf(audit_key_value, sizeof(audit_key_value),
"discoveryrule.filter[" ZBX_FS_UI64 "].conditions.value", rule_conditionid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_operator, op);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_macro, macro);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "item_condition"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_operator, op,
+ AUDIT_TABLE_NAME, "operator");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_macro, macro,
+ AUDIT_TABLE_NAME, "macro");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_discovery_rule_update_json_update_filter_conditions_create_entry(zbx_uint64_t itemid,
@@ -444,7 +473,7 @@ void zbx_audit_discovery_rule_update_json_update_filter_conditions_create_entry(
zbx_snprintf(buf, sizeof(buf), "discoveryrule.filter[" ZBX_FS_UI64 "].conditions", item_conditionid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_UPDATE, buf);
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_UPDATE, buf);
}
#define PREPARE_AUDIT_DISCOVERY_RULE_UPDATE(resource, type1, type2) \
@@ -458,7 +487,7 @@ void zbx_audit_discovery_rule_update_json_update_filter_conditions_##resource(zb
zbx_snprintf(buf, sizeof(buf), "discoveryrule.filter[" ZBX_FS_UI64 "].conditions."#resource, \
item_conditionid); \
\
- zbx_audit_update_json_update_##type2(itemid, buf, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(itemid, AUDIT_ITEM_ID, buf, resource##_old, resource##_new); \
}
PREPARE_AUDIT_DISCOVERY_RULE_UPDATE(operator, int, int)
PREPARE_AUDIT_DISCOVERY_RULE_UPDATE(macro, const char*, string)
@@ -474,7 +503,7 @@ void zbx_audit_discovery_rule_update_json_delete_filter_conditions(zbx_uint64_t
zbx_snprintf(buf, sizeof(buf), "discoveryrule.filter[" ZBX_FS_UI64 "].conditions", item_conditionid);
- zbx_audit_update_json_delete(itemid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
#define ITEM_RESOURCE_KEY_RESOLVE_PREPROC(resource, nested) \
@@ -518,13 +547,19 @@ void zbx_audit_item_update_json_add_item_preproc(zbx_uint64_t itemid, zbx_uint64
ITEM_RESOURCE_KEY_RESOLVE_PREPROC(error_handler, .)
ITEM_RESOURCE_KEY_RESOLVE_PREPROC(error_handler_params, .)
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_step, step);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_type, type);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_params, params);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_error_handler, error_handler);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_error_handler_params,
- error_handler_params);
+#define AUDIT_TABLE_NAME "item_preproc"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_);
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_step, step,
+ AUDIT_TABLE_NAME, "step");
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_type, type,
+ AUDIT_TABLE_NAME, "type");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_params, params,
+ AUDIT_TABLE_NAME, "params");
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_error_handler,
+ error_handler, AUDIT_TABLE_NAME, "error_handler");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD,
+ audit_key_error_handler_params, error_handler_params, AUDIT_TABLE_NAME, "error_handler_params");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_item_update_json_update_item_preproc_create_entry(zbx_uint64_t itemid, int item_flags,
@@ -539,7 +574,7 @@ void zbx_audit_item_update_json_update_item_preproc_create_entry(zbx_uint64_t it
ITEM_RESOURCE_KEY_RESOLVE_PREPROC(,)
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
}
#define PREPARE_AUDIT_ITEM_UPDATE_PREPROC(resource, type1, type2) \
@@ -554,7 +589,8 @@ void zbx_audit_item_update_json_update_item_preproc_##resource(zbx_uint64_t item
\
ITEM_RESOURCE_KEY_RESOLVE_PREPROC(resource,.) \
\
- zbx_audit_update_json_update_##type2(itemid, audit_key_##resource, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(itemid, AUDIT_ITEM_ID, audit_key_##resource, resource##_old, \
+ resource##_new); \
}
PREPARE_AUDIT_ITEM_UPDATE_PREPROC(type, int, int)
PREPARE_AUDIT_ITEM_UPDATE_PREPROC(params, const char*, string)
@@ -573,7 +609,7 @@ void zbx_audit_item_delete_preproc(zbx_uint64_t itemid, int item_flags, zbx_uint
ITEM_RESOURCE_KEY_RESOLVE_PREPROC(,)
- zbx_audit_update_json_delete(itemid, AUDIT_DETAILS_ACTION_DELETE, audit_key_);
+ zbx_audit_update_json_delete(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key_);
}
#define ITEM_RESOURCE_KEY_RESOLVE_TAG(resource, nested) \
@@ -613,9 +649,13 @@ void zbx_audit_item_update_json_add_item_tag(zbx_uint64_t itemid, zbx_uint64_t t
ITEM_RESOURCE_KEY_RESOLVE_TAG(tag, .)
ITEM_RESOURCE_KEY_RESOLVE_TAG(value, .)
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "item_tag"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag,
+ AUDIT_TABLE_NAME, "tag");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_item_update_json_update_item_tag_create_entry(zbx_uint64_t itemid, int item_flags,
@@ -630,7 +670,7 @@ void zbx_audit_item_update_json_update_item_tag_create_entry(zbx_uint64_t itemid
ITEM_RESOURCE_KEY_RESOLVE_TAG(,)
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
}
#define PREPARE_AUDIT_ITEM_UPDATE_TAG(resource, type1, type2) \
@@ -645,7 +685,8 @@ void zbx_audit_item_update_json_update_item_tag_##resource(zbx_uint64_t itemid,
\
ITEM_RESOURCE_KEY_RESOLVE_TAG(resource,.) \
\
- zbx_audit_update_json_update_##type2(itemid, audit_key_##resource, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(itemid, AUDIT_ITEM_ID, audit_key_##resource, resource##_old, \
+ resource##_new); \
}
PREPARE_AUDIT_ITEM_UPDATE_TAG(tag, const char*, string)
PREPARE_AUDIT_ITEM_UPDATE_TAG(value, const char*, string)
@@ -662,7 +703,7 @@ void zbx_audit_item_delete_tag(zbx_uint64_t itemid, int item_flags, zbx_uint64_t
ITEM_RESOURCE_KEY_RESOLVE_TAG(,)
- zbx_audit_update_json_delete(itemid, AUDIT_DETAILS_ACTION_DELETE, audit_key_);
+ zbx_audit_update_json_delete(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key_);
}
#define ITEM_RESOURCE_KEY_RESOLVE(resource, nested) \
@@ -702,9 +743,13 @@ void zbx_audit_item_update_json_add_params(zbx_uint64_t itemid, int item_flags,
ITEM_RESOURCE_KEY_RESOLVE(name, .)
ITEM_RESOURCE_KEY_RESOLVE(value, .)
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "item_parameter"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name,
+ AUDIT_TABLE_NAME, "name");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_item_update_json_update_params_create_entry(zbx_uint64_t itemid, int item_flags,
@@ -718,7 +763,7 @@ void zbx_audit_item_update_json_update_params_create_entry(zbx_uint64_t itemid,
resource_type = item_flag_to_resource_type(item_flags);
ITEM_RESOURCE_KEY_RESOLVE(,)
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_UPDATE, audit_key_);
}
#define PREPARE_AUDIT_ITEM_PARAMS_UPDATE(resource) \
@@ -733,7 +778,8 @@ void zbx_audit_item_update_json_update_params_##resource(zbx_uint64_t itemid, in
resource_type = item_flag_to_resource_type(item_flags); \
ITEM_RESOURCE_KEY_RESOLVE(resource, .) \
\
- zbx_audit_update_json_update_string(itemid, audit_key_##resource, resource##_orig, resource); \
+ zbx_audit_update_json_update_string(itemid, AUDIT_ITEM_ID, audit_key_##resource, resource##_orig, \
+ resource); \
}
PREPARE_AUDIT_ITEM_PARAMS_UPDATE(name)
@@ -750,7 +796,7 @@ void zbx_audit_item_delete_params(zbx_uint64_t itemid, int item_flags, zbx_uint6
ITEM_RESOURCE_KEY_RESOLVE(,)
- zbx_audit_update_json_delete(itemid, AUDIT_DETAILS_ACTION_DELETE, audit_key_);
+ zbx_audit_update_json_delete(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key_);
}
void zbx_audit_discovery_rule_update_json_add_lld_macro_path(zbx_uint64_t itemid,
@@ -768,9 +814,13 @@ void zbx_audit_discovery_rule_update_json_add_lld_macro_path(zbx_uint64_t itemid
zbx_snprintf(audit_key_path, sizeof(audit_key_lld_macro),
"discoveryrule.lld_macro_paths[" ZBX_FS_UI64 "].path", lld_macro_pathid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_lld_macro, lld_macro);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_path, path);
+#define AUDIT_TABLE_NAME "lld_macro_path"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_lld_macro,
+ lld_macro, AUDIT_TABLE_NAME, "lld_macro");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_path, path,
+ AUDIT_TABLE_NAME, "path");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_discovery_rule_update_json_lld_macro_path_create_update_entry(zbx_uint64_t itemid,
@@ -782,7 +832,7 @@ void zbx_audit_discovery_rule_update_json_lld_macro_path_create_update_entry(zbx
zbx_snprintf(buf, sizeof(buf), "discoveryrule.lld_macro_paths[" ZBX_FS_UI64 "]", lld_macro_pathid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_UPDATE, buf);
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_UPDATE, buf);
}
#define PREPARE_AUDIT_DISCOVERY_RULE_UPDATE_LLD_MACRO_PATH(resource) \
@@ -796,7 +846,8 @@ void zbx_audit_discovery_rule_update_json_update_lld_macro_path_##resource(zbx_u
zbx_snprintf(audit_key_##resource, sizeof(audit_key_##resource), \
"discoveryrule.lld_macro_paths[" ZBX_FS_UI64 "]."#resource, lld_macro_pathid); \
\
- zbx_audit_update_json_update_string(itemid, audit_key_##resource, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_string(itemid, AUDIT_ITEM_ID, audit_key_##resource, resource##_old, \
+ resource##_new); \
}
PREPARE_AUDIT_DISCOVERY_RULE_UPDATE_LLD_MACRO_PATH(lld_macro)
PREPARE_AUDIT_DISCOVERY_RULE_UPDATE_LLD_MACRO_PATH(path)
@@ -811,7 +862,7 @@ void zbx_audit_discovery_rule_update_json_delete_lld_macro_path(zbx_uint64_t ite
zbx_snprintf(buf, sizeof(buf),"discoveryrule.lld_macro_paths[" ZBX_FS_UI64 "]", lld_macro_pathid);
- zbx_audit_update_json_delete(itemid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_delete(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_discovery_rule_update_json_add_lld_override(zbx_uint64_t itemid, zbx_uint64_t overrideid,
@@ -830,10 +881,15 @@ void zbx_audit_discovery_rule_update_json_add_lld_override(zbx_uint64_t itemid,
zbx_snprintf(audit_key_stop, sizeof(audit_key_stop), "discoveryrule.overrides[" ZBX_FS_UI64 "].stop",
overrideid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_step, step);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_stop, stop);
+#define AUDIT_TABLE_NAME "lld_override"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_name, name,
+ AUDIT_TABLE_NAME, "name");
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_step, step,
+ AUDIT_TABLE_NAME, "step");
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_stop, stop,
+ AUDIT_TABLE_NAME, "stop");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_discovery_rule_update_json_delete_lld_override(zbx_uint64_t itemid, zbx_uint64_t overrideid)
@@ -844,7 +900,7 @@ void zbx_audit_discovery_rule_update_json_delete_lld_override(zbx_uint64_t itemi
zbx_snprintf(buf, sizeof(buf), "discoveryrule.overrides[" ZBX_FS_UI64 "]", overrideid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_DELETE, buf);
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_DELETE, buf);
}
void zbx_audit_discovery_rule_update_json_add_lld_override_filter(zbx_uint64_t itemid, zbx_uint64_t overrideid,
@@ -863,9 +919,13 @@ void zbx_audit_discovery_rule_update_json_add_lld_override_filter(zbx_uint64_t i
zbx_snprintf(audit_key_formula, sizeof(audit_key_formula), "discoveryrule.overrides[" ZBX_FS_UI64
"].filter.formula", overrideid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_evaltype, evaltype);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_formula, formula);
+#define AUDIT_TABLE_NAME "lld_override"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_evaltype, evaltype,
+ AUDIT_TABLE_NAME, "evaltype");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_formula, formula,
+ AUDIT_TABLE_NAME, "formula");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_discovery_rule_update_json_add_lld_override_condition(zbx_uint64_t itemid, zbx_uint64_t overrideid,
@@ -885,10 +945,15 @@ void zbx_audit_discovery_rule_update_json_add_lld_override_condition(zbx_uint64_
zbx_snprintf(audit_key_value, sizeof(audit_key_value), "discoveryrule.overrides[" ZBX_FS_UI64 "].conditions["
ZBX_FS_UI64 "].value", overrideid, override_conditionid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_operator, condition_operator);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_macro, macro);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "lld_override_condition"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_operator,
+ condition_operator, AUDIT_TABLE_NAME, "operator");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_macro, macro,
+ AUDIT_TABLE_NAME, "macro");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_discovery_rule_update_json_add_lld_override_operation(zbx_uint64_t itemid, zbx_uint64_t overrideid,
@@ -906,12 +971,16 @@ void zbx_audit_discovery_rule_update_json_add_lld_override_operation(zbx_uint64_
zbx_snprintf(audit_key_value, sizeof(audit_key_value), "discoveryrule.overrides[" ZBX_FS_UI64 "].operations["
ZBX_FS_UI64 "].value", overrideid, override_operationid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_int(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_operator, condition_operator);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "lld_override_operation"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_int(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_operator,
+ condition_operator, AUDIT_TABLE_NAME, "operator");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
-#define PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(resource, type, type2) \
+#define PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(resource, type, type2, table, field) \
void zbx_audit_discovery_rule_update_json_add_lld_override_##resource(zbx_uint64_t itemid, \
zbx_uint64_t overrideid, zbx_uint64_t resource##_id, type resource) \
{ \
@@ -922,16 +991,17 @@ void zbx_audit_discovery_rule_update_json_add_lld_override_##resource(zbx_uint64
zbx_snprintf(buf, sizeof(buf), "discoveryrule.overrides[" ZBX_FS_UI64 \
"].operations[" ZBX_FS_UI64 "]."#resource, overrideid, resource##_id); \
\
- zbx_audit_update_json_append_##type2(itemid, AUDIT_DETAILS_ACTION_ADD, buf, resource); \
+ zbx_audit_update_json_append_##type2(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, buf, resource, \
+ table, field); \
}
-PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opstatus, int, int)
-PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opdiscover, int, int)
-PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opperiod, const char*, string)
-PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(optrends, const char*, string)
-PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(ophistory, const char*, string)
-PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opseverity, int, int)
-PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opinventory, int, int)
+PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opstatus, int, int, "lld_override_opstatus", "status")
+PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opdiscover, int, int, "lld_override_opdiscover", "discover")
+PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opperiod, const char*, string, "lld_override_opperiod", "delay")
+PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(optrends, const char*, string, "lld_override_optrends", "trends")
+PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(ophistory, const char*, string, "lld_override_ophistory", "history")
+PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opseverity, int, int, "lld_override_opseverity", "severity")
+PREPARE_AUDIT_DISCOVERY_RULE_OVERRIDE_ADD(opinventory, int, int, "lld_override_opinventory", "inventory_mode")
void zbx_audit_discovery_rule_update_json_add_lld_override_optag(zbx_uint64_t itemid, zbx_uint64_t overrideid,
zbx_uint64_t lld_override_optagid, const char *tag, const char *value)
@@ -948,9 +1018,13 @@ void zbx_audit_discovery_rule_update_json_add_lld_override_optag(zbx_uint64_t it
zbx_snprintf(audit_key_value, sizeof(audit_key_value), "discoveryrule.overrides[" ZBX_FS_UI64
"].optag[" ZBX_FS_UI64 "].value", overrideid, lld_override_optagid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag);
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "lld_override_optag"
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag,
+ AUDIT_TABLE_NAME, "tag");
+ zbx_audit_update_json_append_string(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value,
+ AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_discovery_rule_update_json_add_lld_override_optemplate(zbx_uint64_t itemid, zbx_uint64_t overrideid,
@@ -965,6 +1039,7 @@ void zbx_audit_discovery_rule_update_json_add_lld_override_optemplate(zbx_uint64
zbx_snprintf(audit_key_templateid, sizeof(audit_key_templateid), "discoveryrule.overrides[" ZBX_FS_UI64
"].optemplateid[" ZBX_FS_UI64 "].templateid", overrideid, lld_override_optemplateid);
- zbx_audit_update_json_append_no_value(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_uint64(itemid, AUDIT_DETAILS_ACTION_ADD, audit_key_templateid, templateid);
+ zbx_audit_update_json_append_no_value(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_uint64(itemid, AUDIT_ITEM_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_templateid,
+ templateid, "lld_override_optemplate", "templateid");
}
diff --git a/src/libs/zbxaudit/audit_settings.c b/src/libs/zbxaudit/audit_settings.c
index 5cb5a752d2d..699f8bc468e 100644
--- a/src/libs/zbxaudit/audit_settings.c
+++ b/src/libs/zbxaudit/audit_settings.c
@@ -30,12 +30,13 @@ void zbx_audit_settings_create_entry(int audit_action, zbx_uint64_t configid)
local_audit_entry.id = configid;
local_audit_entry.cuid = NULL;
+ local_audit_entry.id_table = AUDIT_CONFIG_ID;
if (NULL == zbx_hashset_search(zbx_get_audit_hashset(), &plocal_audit_entry))
{
zbx_audit_entry_t *new_entry;
- new_entry = zbx_audit_entry_init(configid, "", audit_action, AUDIT_RESOURCE_SETTINGS);
+ new_entry = zbx_audit_entry_init(configid, AUDIT_CONFIG_ID, "", audit_action, AUDIT_RESOURCE_SETTINGS);
zbx_hashset_insert(zbx_get_audit_hashset(), &new_entry, sizeof(new_entry));
}
}
diff --git a/src/libs/zbxaudit/audit_trigger.c b/src/libs/zbxaudit/audit_trigger.c
index 50008ca03a9..7a6e6199ce8 100644
--- a/src/libs/zbxaudit/audit_trigger.c
+++ b/src/libs/zbxaudit/audit_trigger.c
@@ -54,6 +54,7 @@ void zbx_audit_trigger_create_entry(int audit_action, zbx_uint64_t triggerid, co
local_audit_trigger_entry.id = triggerid;
local_audit_trigger_entry.cuid = NULL;
+ local_audit_trigger_entry.id_table = AUDIT_TRIGGER_ID;
found_audit_trigger_entry = (zbx_audit_entry_t**)zbx_hashset_search(zbx_get_audit_hashset(),
&(local_audit_trigger_entry_x));
@@ -62,14 +63,15 @@ void zbx_audit_trigger_create_entry(int audit_action, zbx_uint64_t triggerid, co
{
zbx_audit_entry_t *local_audit_trigger_entry_insert;
- local_audit_trigger_entry_insert = zbx_audit_entry_init(triggerid, name, audit_action, resource_type);
+ local_audit_trigger_entry_insert = zbx_audit_entry_init(triggerid, AUDIT_TRIGGER_ID, name, audit_action,
+ resource_type);
zbx_hashset_insert(zbx_get_audit_hashset(), &local_audit_trigger_entry_insert,
sizeof(local_audit_trigger_entry_insert));
if (AUDIT_ACTION_ADD == audit_action)
{
- zbx_audit_update_json_append_uint64(triggerid, AUDIT_DETAILS_ACTION_ADD,
- TR_OR_TRP(triggerid), triggerid);
+ zbx_audit_update_json_append_uint64(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD,
+ TR_OR_TRP(triggerid), triggerid, "triggers", "triggerid");
}
}
}
@@ -116,29 +118,34 @@ void zbx_audit_trigger_update_json_add_data(zbx_uint64_t triggerid, zbx_uint64_t
if (AUDIT_RESOURCE_TRIGGER_PROTOTYPE == resource_type)
AUDIT_KEY_SNPRINTF(discover)
#undef AUDIT_KEY_SNPRINTF
- zbx_audit_update_json_append_no_value(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key);
-#define ADD_STR(r) zbx_audit_update_json_append_string(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_UINT64(r) zbx_audit_update_json_append_uint64(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
-#define ADD_INT(r) zbx_audit_update_json_append_int(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key_##r, r);
- ADD_STR(event_name)
- ADD_STR(opdata)
- ADD_STR(comments)
- ADD_INT(flags)
- ADD_INT(priority)
- ADD_UINT64(state)
- ADD_INT(status)
- ADD_UINT64(templateid)
- ADD_INT(type)
- ADD_STR(url)
- ADD_UINT64(value)
- ADD_INT(recovery_mode)
- ADD_INT(correlation_mode)
- ADD_STR(correlation_tag)
- ADD_INT(manual_close)
+ zbx_audit_update_json_append_no_value(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+#define ADD_STR(r, t, f) zbx_audit_update_json_append_string(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_UINT64(r,t, f) zbx_audit_update_json_append_uint64(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define ADD_INT(r, t, f) zbx_audit_update_json_append_int(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, \
+ audit_key_##r, r, t, f);
+#define AUDIT_TABLE_NAME "triggers"
+ ADD_STR(event_name, AUDIT_TABLE_NAME, "event_name")
+ ADD_STR(opdata, AUDIT_TABLE_NAME, "opdata")
+ ADD_STR(comments, AUDIT_TABLE_NAME, "comments")
+ ADD_INT(flags, AUDIT_TABLE_NAME, "flags")
+ ADD_INT(priority, AUDIT_TABLE_NAME, "priority")
+ ADD_UINT64(state, AUDIT_TABLE_NAME, "state")
+ ADD_INT(status, AUDIT_TABLE_NAME, "status")
+ ADD_UINT64(templateid, AUDIT_TABLE_NAME, "templateid")
+ ADD_INT(type, AUDIT_TABLE_NAME, "type")
+ ADD_STR(url, AUDIT_TABLE_NAME, "url")
+ ADD_UINT64(value, AUDIT_TABLE_NAME, "value")
+ ADD_INT(recovery_mode, AUDIT_TABLE_NAME, "recovery_mode")
+ ADD_INT(correlation_mode, AUDIT_TABLE_NAME, "correlation_mode")
+ ADD_STR(correlation_tag, AUDIT_TABLE_NAME, "correlation_tag")
+ ADD_INT(manual_close, AUDIT_TABLE_NAME, "manual_close")
if (AUDIT_RESOURCE_TRIGGER_PROTOTYPE == resource_type)
- ADD_UINT64(discover)
+ ADD_UINT64(discover, AUDIT_TABLE_NAME, "discover")
+#undef AUDIT_TABLE_NAME
#undef ADD_STR
#undef ADD_UINT64
#undef ADD_INT
@@ -154,7 +161,8 @@ void zbx_audit_trigger_update_json_add_expr(zbx_uint64_t triggerid, int flags, c
resource_type = trigger_flag_to_resource_type(flags);
zbx_snprintf(buf, sizeof(buf), TR_OR_TRP(expression));
- zbx_audit_update_json_append_string(triggerid, AUDIT_DETAILS_ACTION_ADD, buf, expression);
+ zbx_audit_update_json_append_string(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, buf, expression,
+ "triggers", "expression");
}
void zbx_audit_trigger_update_json_add_rexpr(zbx_uint64_t triggerid, int flags, const char *recovery_expression)
@@ -167,7 +175,8 @@ void zbx_audit_trigger_update_json_add_rexpr(zbx_uint64_t triggerid, int flags,
resource_type = trigger_flag_to_resource_type(flags);
zbx_snprintf(buf, sizeof(buf), TR_OR_TRP(recovery_expression));
- zbx_audit_update_json_append_string(triggerid, AUDIT_DETAILS_ACTION_ADD, buf, recovery_expression);
+ zbx_audit_update_json_append_string(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, buf,
+ recovery_expression, "triggers", "recovery_expression");
}
#define PREPARE_AUDIT_TRIGGER_UPDATE(resource, type1, type2) \
@@ -180,10 +189,10 @@ void zbx_audit_trigger_update_json_update_##resource(zbx_uint64_t triggerid, int
RETURN_IF_AUDIT_OFF(); \
\
resource_type = trigger_flag_to_resource_type(flags); \
- \
+ \
zbx_snprintf(buf, sizeof(buf), TR_OR_TRP(resource)); \
\
- zbx_audit_update_json_update_##type2(triggerid, buf, resource##_old, resource##_new); \
+ zbx_audit_update_json_update_##type2(triggerid, AUDIT_TRIGGER_ID, buf, resource##_old, resource##_new); \
}
PREPARE_AUDIT_TRIGGER_UPDATE(recovery_mode, int, int)
@@ -193,8 +202,14 @@ PREPARE_AUDIT_TRIGGER_UPDATE(manual_close, int, int)
PREPARE_AUDIT_TRIGGER_UPDATE(opdata, const char*, string)
PREPARE_AUDIT_TRIGGER_UPDATE(discover, int, int)
PREPARE_AUDIT_TRIGGER_UPDATE(event_name, const char*, string)
+PREPARE_AUDIT_TRIGGER_UPDATE(priority, int, int)
+PREPARE_AUDIT_TRIGGER_UPDATE(comments, const char*, string)
+PREPARE_AUDIT_TRIGGER_UPDATE(url, const char*, string)
PREPARE_AUDIT_TRIGGER_UPDATE(type, int, int)
PREPARE_AUDIT_TRIGGER_UPDATE(templateid, zbx_uint64_t, uint64)
+PREPARE_AUDIT_TRIGGER_UPDATE(description, const char*, string)
+PREPARE_AUDIT_TRIGGER_UPDATE(expression, const char*, string)
+PREPARE_AUDIT_TRIGGER_UPDATE(recovery_expression, const char*, string)
#undef PREPARE_AUDIT_ITEM_UPDATE
#undef TR_OR_TRP
@@ -232,8 +247,8 @@ void zbx_audit_DBselect_delete_for_trigger(const char *sql, zbx_vector_uint64_t
zbx_vector_uint64_sort(ids, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
}
-void zbx_audit_trigger_update_json_add_dependency(int flags, zbx_uint64_t triggerdepid,
- zbx_uint64_t triggerid, zbx_uint64_t triggerid_up)
+void zbx_audit_trigger_update_json_add_dependency(int flags, zbx_uint64_t triggerdepid, zbx_uint64_t triggerid,
+ zbx_uint64_t triggerid_up)
{
char audit_key[AUDIT_DETAILS_KEY_LEN], audit_key_triggerid_up[AUDIT_DETAILS_KEY_LEN];
int resource_type;
@@ -256,8 +271,24 @@ void zbx_audit_trigger_update_json_add_dependency(int flags, zbx_uint64_t trigge
ZBX_FS_UI64 "].dependsOnTriggerid", triggerdepid);
}
- zbx_audit_update_json_append_no_value(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_uint64(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key_triggerid_up, triggerid_up);
+ zbx_audit_update_json_append_no_value(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_uint64(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD,
+ audit_key_triggerid_up, triggerid_up, "trigger_depends", "triggerid_up");
+}
+
+void zbx_audit_trigger_update_json_remove_dependency(int flags, zbx_uint64_t triggerdepid, zbx_uint64_t triggerid)
+{
+ char audit_key[AUDIT_DETAILS_KEY_LEN];
+ int resource_type;
+
+ RETURN_IF_AUDIT_OFF();
+
+ resource_type = trigger_flag_to_resource_type(flags);
+
+ zbx_snprintf(audit_key, sizeof(audit_key), "trigger%s.dependencies[" ZBX_FS_UI64 "]",
+ (AUDIT_RESOURCE_TRIGGER == resource_type) ? "" : "prototype", triggerdepid);
+
+ zbx_audit_update_json_append_no_value(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key);
}
void zbx_audit_trigger_update_json_add_tags_and_values(zbx_uint64_t triggerid, int flags, zbx_uint64_t triggertagid,
@@ -273,17 +304,17 @@ void zbx_audit_trigger_update_json_add_tags_and_values(zbx_uint64_t triggerid, i
if (AUDIT_RESOURCE_TRIGGER == resource_type)
{
- zbx_snprintf(audit_key, AUDIT_DETAILS_KEY_LEN, "trigger.tags[" ZBX_FS_UI64 "]", triggertagid);
- zbx_snprintf(audit_key_tag, AUDIT_DETAILS_KEY_LEN, "trigger.tags[" ZBX_FS_UI64 "].tag", triggertagid);
- zbx_snprintf(audit_key_value, AUDIT_DETAILS_KEY_LEN, "trigger.tags[" ZBX_FS_UI64 "].value",
+ zbx_snprintf(audit_key, sizeof(audit_key), "trigger.tags[" ZBX_FS_UI64 "]", triggertagid);
+ zbx_snprintf(audit_key_tag, sizeof(audit_key_tag), "trigger.tags[" ZBX_FS_UI64 "].tag", triggertagid);
+ zbx_snprintf(audit_key_value, sizeof(audit_key_value), "trigger.tags[" ZBX_FS_UI64 "].value",
triggertagid);
}
else if(AUDIT_RESOURCE_TRIGGER_PROTOTYPE == resource_type)
{
- zbx_snprintf(audit_key, AUDIT_DETAILS_KEY_LEN, "triggerprototype.tags[" ZBX_FS_UI64 "]", triggertagid);
- zbx_snprintf(audit_key_tag, AUDIT_DETAILS_KEY_LEN, "triggerprototype.tags[" ZBX_FS_UI64 "].tag",
+ zbx_snprintf(audit_key, sizeof(audit_key), "triggerprototype.tags[" ZBX_FS_UI64 "]", triggertagid);
+ zbx_snprintf(audit_key_tag, sizeof(audit_key_tag), "triggerprototype.tags[" ZBX_FS_UI64 "].tag",
triggertagid);
- zbx_snprintf(audit_key_value, AUDIT_DETAILS_KEY_LEN, "triggerprototype.tags[" ZBX_FS_UI64 "].value",
+ zbx_snprintf(audit_key_value, sizeof(audit_key_value), "triggerprototype.tags[" ZBX_FS_UI64 "].value",
triggertagid);
}
else
@@ -293,9 +324,13 @@ void zbx_audit_trigger_update_json_add_tags_and_values(zbx_uint64_t triggerid, i
exit(EXIT_FAILURE);
}
- zbx_audit_update_json_append_no_value(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key);
- zbx_audit_update_json_append_string(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key_tag, tag);
- zbx_audit_update_json_append_string(triggerid, AUDIT_DETAILS_ACTION_ADD, audit_key_value, value);
+#define AUDIT_TABLE_NAME "trigger_tag"
+ zbx_audit_update_json_append_no_value(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, audit_key);
+ zbx_audit_update_json_append_string(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_tag,
+ tag, AUDIT_TABLE_NAME, "tag");
+ zbx_audit_update_json_append_string(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_ADD, audit_key_value,
+ value, AUDIT_TABLE_NAME, "value");
+#undef AUDIT_TABLE_NAME
}
void zbx_audit_trigger_update_json_delete_tags(zbx_uint64_t triggerid, int flags, zbx_uint64_t triggertagid)
@@ -308,9 +343,27 @@ void zbx_audit_trigger_update_json_delete_tags(zbx_uint64_t triggerid, int flags
resource_type = trigger_flag_to_resource_type(flags);
if (AUDIT_RESOURCE_TRIGGER == resource_type)
- zbx_snprintf(audit_key, AUDIT_DETAILS_KEY_LEN, "trigger.tags[" ZBX_FS_UI64 "]", triggertagid);
+ zbx_snprintf(audit_key, sizeof(audit_key), "trigger.tags[" ZBX_FS_UI64 "]", triggertagid);
else
- zbx_snprintf(audit_key, AUDIT_DETAILS_KEY_LEN, "triggerprototype.tags[" ZBX_FS_UI64 "]", triggertagid);
+ zbx_snprintf(audit_key, sizeof(audit_key), "triggerprototype.tags[" ZBX_FS_UI64 "]", triggertagid);
- zbx_audit_update_json_append_no_value(triggerid, AUDIT_DETAILS_ACTION_DELETE, audit_key);
+ zbx_audit_update_json_append_no_value(triggerid, AUDIT_TRIGGER_ID, AUDIT_DETAILS_ACTION_DELETE, audit_key);
}
+
+#define PREPARE_AUDIT_TRIGGER_UPDATE_TAG(resource, type1, type2) \
+void zbx_audit_trigger_update_json_update_tag_##resource(zbx_uint64_t triggerid, zbx_uint64_t triggertagid, \
+ type1 resource##_old, type1 resource##_new) \
+{ \
+ char buf[AUDIT_DETAILS_KEY_LEN]; \
+ \
+ RETURN_IF_AUDIT_OFF(); \
+ \
+ zbx_snprintf(buf, sizeof(buf), "trigger.tags[" ZBX_FS_UI64 "]", triggertagid); \
+ \
+ zbx_audit_update_json_update_##type2(triggerid, AUDIT_TRIGGER_ID, buf, resource##_old, resource##_new); \
+}
+
+PREPARE_AUDIT_TRIGGER_UPDATE_TAG(tag, const char*, string)
+PREPARE_AUDIT_TRIGGER_UPDATE_TAG(value, const char*, string)
+
+#undef PREPARE_AUDIT_TRIGGER_UPDATE_TAG
diff --git a/src/libs/zbxaudit/audit_trigger.h b/src/libs/zbxaudit/audit_trigger.h
index 938ee15aa58..3e75377f24e 100644
--- a/src/libs/zbxaudit/audit_trigger.h
+++ b/src/libs/zbxaudit/audit_trigger.h
@@ -47,14 +47,27 @@ PREPARE_AUDIT_TRIGGER_UPDATE_H(manual_close, int)
PREPARE_AUDIT_TRIGGER_UPDATE_H(opdata, const char*)
PREPARE_AUDIT_TRIGGER_UPDATE_H(discover, int)
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(type, int)
PREPARE_AUDIT_TRIGGER_UPDATE_H(templateid, zbx_uint64_t)
+PREPARE_AUDIT_TRIGGER_UPDATE_H(description, const char*)
+PREPARE_AUDIT_TRIGGER_UPDATE_H(expression, const char*)
+PREPARE_AUDIT_TRIGGER_UPDATE_H(recovery_expression, const char*)
void zbx_audit_DBselect_delete_for_trigger(const char *sql, zbx_vector_uint64_t *ids);
void zbx_audit_trigger_update_json_add_dependency(int flags, zbx_uint64_t triggerdepid,
zbx_uint64_t triggerid, zbx_uint64_t triggerid_up);
+void zbx_audit_trigger_update_json_remove_dependency(int flags, zbx_uint64_t triggerdepid, zbx_uint64_t triggerid);
void zbx_audit_trigger_update_json_add_tags_and_values(zbx_uint64_t triggerid, int flags, zbx_uint64_t triggertagid,
const char *tag, const char *value);
void zbx_audit_trigger_update_json_delete_tags(zbx_uint64_t triggerid, int flags, zbx_uint64_t triggertagid);
+#define PREPARE_AUDIT_TRIGGER_UPDATE_TAG_H(resource, type1) \
+void zbx_audit_trigger_update_json_update_tag_##resource(zbx_uint64_t triggerid, zbx_uint64_t triggertagid, \
+ type1 resource##_old, type1 resource##_new);
+PREPARE_AUDIT_TRIGGER_UPDATE_TAG_H(tag, const char*)
+PREPARE_AUDIT_TRIGGER_UPDATE_TAG_H(value, const char*)
+
#endif /* ZABBIX_AUDIT_TRIGGER_H */