diff options
author | Andris Zeila <andris.zeila@zabbix.com> | 2021-10-19 10:59:54 +0300 |
---|---|---|
committer | Andris Zeila <andris.zeila@zabbix.com> | 2021-10-19 10:59:54 +0300 |
commit | 1f512918f4175dd1c21d634c4476ea5ba94ce1fa (patch) | |
tree | 80c2a030ff3b879a267347e2db7fdc188424861d /src/libs/zbxaudit/audit_item.c | |
parent | 646b3bc1315055ddebbb93cfe50dfd98f2de44b9 (diff) | |
parent | c8fab6d8ab863c196370d3d145d72106ff4e33c6 (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/audit_item.c')
-rw-r--r-- | src/libs/zbxaudit/audit_item.c | 461 |
1 files changed, 268 insertions, 193 deletions
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"); } |