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:
authorVladislavs Sokurenko <vladislavs.sokurenko@zabbix.com>2021-07-07 16:12:51 +0300
committerVladislavs Sokurenko <vladislavs.sokurenko@zabbix.com>2021-07-07 16:12:51 +0300
commit3996caad6548e96357463049f95898456ed08ad7 (patch)
treead5377b27558bc2454e7d1028405ae15c394b7b7
parentf29f1140c544727fa6c8a45a457da7af8478f27d (diff)
........S. [ZBXNEXT-6755] added support of escalation update operations
-rw-r--r--include/common.h4
-rw-r--r--include/zbxserver.h2
-rw-r--r--src/libs/zbxserver/expression.c16
-rw-r--r--src/zabbix_server/escalator/escalator.c75
4 files changed, 67 insertions, 30 deletions
diff --git a/include/common.h b/include/common.h
index c9da439b972..193b00aa2c8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -732,12 +732,12 @@ const char *zbx_item_logtype_string(unsigned char logtype);
#define OPERATION_TYPE_HOST_DISABLE 9
#define OPERATION_TYPE_HOST_INVENTORY 10
#define OPERATION_TYPE_RECOVERY_MESSAGE 11
-#define OPERATION_TYPE_ACK_MESSAGE 12
+#define OPERATION_TYPE_UPDATE_MESSAGE 12
/* normal and recovery operations */
#define ZBX_OPERATION_MODE_NORMAL 0
#define ZBX_OPERATION_MODE_RECOVERY 1
-#define ZBX_OPERATION_MODE_ACK 2
+#define ZBX_OPERATION_MODE_UPDATE 2
/* algorithms for service status calculation */
#define SERVICE_ALGORITHM_NONE 0
diff --git a/include/zbxserver.h b/include/zbxserver.h
index f41f19121f5..12190cf57ff 100644
--- a/include/zbxserver.h
+++ b/include/zbxserver.h
@@ -44,7 +44,7 @@
#define MACRO_TYPE_ALERT 0x00010000
#define MACRO_TYPE_TRIGGER_TAG 0x00020000
#define MACRO_TYPE_JMX_ENDPOINT 0x00040000
-#define MACRO_TYPE_MESSAGE_ACK 0x00080000
+#define MACRO_TYPE_MESSAGE_UPDATE 0x00080000
#define MACRO_TYPE_HTTP_RAW 0x00100000
#define MACRO_TYPE_HTTP_JSON 0x00200000
#define MACRO_TYPE_HTTP_XML 0x00400000
diff --git a/src/libs/zbxserver/expression.c b/src/libs/zbxserver/expression.c
index 8ddf8938725..bc161e56087 100644
--- a/src/libs/zbxserver/expression.c
+++ b/src/libs/zbxserver/expression.c
@@ -2840,7 +2840,7 @@ static int substitute_simple_macros_impl(const zbx_uint64_t *actionid, const DB_
break;
case ZBX_TOKEN_SIMPLE_MACRO:
if (0 == (macro_type & (MACRO_TYPE_MESSAGE_NORMAL | MACRO_TYPE_MESSAGE_RECOVERY |
- MACRO_TYPE_MESSAGE_ACK | MACRO_TYPE_SCRIPT_NORMAL |
+ MACRO_TYPE_MESSAGE_UPDATE | MACRO_TYPE_SCRIPT_NORMAL |
MACRO_TYPE_SCRIPT_RECOVERY)) ||
EVENT_SOURCE_TRIGGERS != ((NULL != r_event) ? r_event : event)->source)
{
@@ -2866,7 +2866,7 @@ static int substitute_simple_macros_impl(const zbx_uint64_t *actionid, const DB_
ret = SUCCEED;
if (0 != (macro_type & (MACRO_TYPE_MESSAGE_NORMAL | MACRO_TYPE_MESSAGE_RECOVERY |
- MACRO_TYPE_MESSAGE_ACK |
+ MACRO_TYPE_MESSAGE_UPDATE |
MACRO_TYPE_SCRIPT_NORMAL | MACRO_TYPE_SCRIPT_RECOVERY)))
/* MACRO_TYPE_SCRIPT_NORMAL and MACRO_TYPE_SCRIPT_RECOVERY behave pretty similar to */
/* MACRO_TYPE_MESSAGE_NORMAL and MACRO_TYPE_MESSAGE_RECOVERY. Therefore the code is not duplicated */
@@ -2931,22 +2931,22 @@ static int substitute_simple_macros_impl(const zbx_uint64_t *actionid, const DB_
}
else if (0 == strcmp(m, MVAR_ACK_MESSAGE) || 0 == strcmp(m, MVAR_EVENT_UPDATE_MESSAGE))
{
- if (0 != (macro_type & MACRO_TYPE_MESSAGE_ACK) && NULL != ack)
+ if (0 != (macro_type & MACRO_TYPE_MESSAGE_UPDATE) && NULL != ack)
replace_to = zbx_strdup(replace_to, ack->message);
}
else if (0 == strcmp(m, MVAR_ACK_TIME) || 0 == strcmp(m, MVAR_EVENT_UPDATE_TIME))
{
- if (0 != (macro_type & MACRO_TYPE_MESSAGE_ACK) && NULL != ack)
+ if (0 != (macro_type & MACRO_TYPE_MESSAGE_UPDATE) && NULL != ack)
replace_to = zbx_strdup(replace_to, zbx_time2str(ack->clock, tz));
}
else if (0 == strcmp(m, MVAR_ACK_DATE) || 0 == strcmp(m, MVAR_EVENT_UPDATE_DATE))
{
- if (0 != (macro_type & MACRO_TYPE_MESSAGE_ACK) && NULL != ack)
+ if (0 != (macro_type & MACRO_TYPE_MESSAGE_UPDATE) && NULL != ack)
replace_to = zbx_strdup(replace_to, zbx_date2str(ack->clock, tz));
}
else if (0 == strcmp(m, MVAR_EVENT_UPDATE_ACTION))
{
- if (0 != (macro_type & MACRO_TYPE_MESSAGE_ACK) && NULL != ack)
+ if (0 != (macro_type & MACRO_TYPE_MESSAGE_UPDATE) && NULL != ack)
{
get_problem_update_actions(ack, ZBX_PROBLEM_UPDATE_ACKNOWLEDGE |
ZBX_PROBLEM_UPDATE_UNACKNOWLEDGE |
@@ -2956,7 +2956,7 @@ static int substitute_simple_macros_impl(const zbx_uint64_t *actionid, const DB_
}
else if (0 == strcmp(m, MVAR_EVENT_UPDATE_STATUS))
{
- if (0 != (macro_type & MACRO_TYPE_MESSAGE_ACK) && NULL != ack)
+ if (0 != (macro_type & MACRO_TYPE_MESSAGE_UPDATE) && NULL != ack)
replace_to = zbx_strdup(replace_to, "1");
else
replace_to = zbx_strdup(replace_to, "0");
@@ -3162,7 +3162,7 @@ static int substitute_simple_macros_impl(const zbx_uint64_t *actionid, const DB_
{
replace_to = zbx_dsprintf(replace_to, "%d", c_event->trigger.value);
}
- else if (0 != (macro_type & MACRO_TYPE_MESSAGE_ACK) && NULL != ack &&
+ else if (0 != (macro_type & MACRO_TYPE_MESSAGE_UPDATE) && NULL != ack &&
0 == strcmp(m, MVAR_USER_FULLNAME))
{
const char *user_name1;
diff --git a/src/zabbix_server/escalator/escalator.c b/src/zabbix_server/escalator/escalator.c
index 0240d16b46f..cfec136fa10 100644
--- a/src/zabbix_server/escalator/escalator.c
+++ b/src/zabbix_server/escalator/escalator.c
@@ -638,7 +638,7 @@ static void add_sentusers_msg(ZBX_USER_MSG **user_msg, zbx_uint64_t actionid, zb
zbx_chrcpy_alloc(&sql, &sql_alloc, &sql_offset, ')');
if (NULL != ack)
- message_type = MACRO_TYPE_MESSAGE_ACK;
+ message_type = MACRO_TYPE_MESSAGE_UPDATE;
result = DBselect("%s", sql);
@@ -825,8 +825,9 @@ static void add_sentusers_ack_msg(ZBX_USER_MSG **user_msg, zbx_uint64_t actionid
if (PERM_READ > get_trigger_permission(userid, event, &user_timezone))
goto clean;
- add_user_msgs(userid, operationid, 0, user_msg, actionid, event, r_event, ack, MACRO_TYPE_MESSAGE_ACK,
- evt_src, ZBX_OPERATION_MODE_ACK, default_timezone, user_timezone);
+ add_user_msgs(userid, operationid, 0, user_msg, actionid, event, r_event, ack,
+ MACRO_TYPE_MESSAGE_UPDATE, evt_src, ZBX_OPERATION_MODE_UPDATE, default_timezone,
+ user_timezone);
clean:
zbx_free(user_timezone);
}
@@ -1252,7 +1253,7 @@ static void get_mediatype_params(const DB_EVENT *event, const DB_EVENT *r_event,
int message_type;
if (NULL != ack)
- message_type = MACRO_TYPE_MESSAGE_ACK;
+ message_type = MACRO_TYPE_MESSAGE_UPDATE;
else
message_type = (NULL != r_event ? MACRO_TYPE_MESSAGE_RECOVERY : MACRO_TYPE_MESSAGE_NORMAL);
@@ -1717,20 +1718,20 @@ static void escalation_execute_recovery_operations(const DB_EVENT *event, const
/******************************************************************************
* *
- * Function: escalation_execute_acknowledge_operations *
+ * Function: escalation_execute_update_operations *
* *
- * Purpose: execute escalation acknowledge operations *
+ * Purpose: execute escalation update operations *
* *
* Parameters: event - [IN] the event *
* action - [IN] the action *
* ack - [IN] the acknowledge *
* *
- * Comments: Action acknowledge operations have a single escalation step, so *
- * alerts created by escalation acknowledge operations must have *
+ * Comments: Action update operations have a single escalation step, so *
+ * alerts created by escalation update operations must have *
* esc_step field set to 1. *
* *
******************************************************************************/
-static void escalation_execute_acknowledge_operations(const DB_EVENT *event, const DB_EVENT *r_event,
+static void escalation_execute_update_operations(const DB_EVENT *event, const DB_EVENT *r_event,
const DB_ACTION *action, const DB_ACKNOWLEDGE *ack, const char *default_timezone)
{
DB_RESULT result;
@@ -1748,8 +1749,8 @@ static void escalation_execute_acknowledge_operations(const DB_EVENT *event, con
" and o.operationtype in (%d,%d,%d)"
" and o.recovery=%d",
action->actionid,
- OPERATION_TYPE_MESSAGE, OPERATION_TYPE_COMMAND, OPERATION_TYPE_ACK_MESSAGE,
- ZBX_OPERATION_MODE_ACK);
+ OPERATION_TYPE_MESSAGE, OPERATION_TYPE_COMMAND, OPERATION_TYPE_UPDATE_MESSAGE,
+ ZBX_OPERATION_MODE_UPDATE);
while (NULL != (row = DBfetch(result)))
{
@@ -1760,18 +1761,21 @@ static void escalation_execute_acknowledge_operations(const DB_EVENT *event, con
{
case OPERATION_TYPE_MESSAGE:
add_object_msg(action->actionid, operationid, &user_msg, event, r_event, ack,
- MACRO_TYPE_MESSAGE_ACK, action->eventsource, ZBX_OPERATION_MODE_ACK,
+ MACRO_TYPE_MESSAGE_UPDATE, action->eventsource, ZBX_OPERATION_MODE_UPDATE,
default_timezone);
break;
- case OPERATION_TYPE_ACK_MESSAGE:
+ case OPERATION_TYPE_UPDATE_MESSAGE:
add_sentusers_msg(&user_msg, action->actionid, operationid, event, r_event, ack,
- action->eventsource, ZBX_OPERATION_MODE_ACK, default_timezone);
- add_sentusers_ack_msg(&user_msg, action->actionid, operationid, event, r_event, ack,
- action->eventsource, default_timezone);
+ action->eventsource, ZBX_OPERATION_MODE_UPDATE, default_timezone);
+ if (NULL != ack)
+ {
+ add_sentusers_ack_msg(&user_msg, action->actionid, operationid, event, r_event,
+ ack, action->eventsource, default_timezone);
+ }
break;
case OPERATION_TYPE_COMMAND:
execute_commands(event, r_event, ack, action->actionid, operationid, 1,
- MACRO_TYPE_MESSAGE_ACK, default_timezone);
+ MACRO_TYPE_MESSAGE_UPDATE, default_timezone);
break;
}
}
@@ -2208,7 +2212,7 @@ static void escalation_acknowledge(DB_ESCALATION *escalation, const DB_ACTION *a
ack.old_severity = atoi(row[4]);
ack.new_severity = atoi(row[5]);
- escalation_execute_acknowledge_operations(event, r_event, action, &ack, default_timezone);
+ escalation_execute_update_operations(event, r_event, action, &ack, default_timezone);
}
DBfree_result(result);
@@ -2218,6 +2222,35 @@ static void escalation_acknowledge(DB_ESCALATION *escalation, const DB_ACTION *a
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
}
+/******************************************************************************
+ * *
+ * Function: escalation_acknowledge *
+ * *
+ * Purpose: process escalation acknowledge *
+ * *
+ * Parameters: escalation - [IN/OUT] the escalation to recovery *
+ * action - [IN] the action *
+ * event - [IN] the event *
+ * r_event - [IN] the recovery event *
+ * *
+ ******************************************************************************/
+static void escalation_update(DB_ESCALATION *escalation, const DB_ACTION *action, const DB_EVENT *event,
+ const char *default_timezone)
+{
+ DB_ROW row;
+ DB_RESULT result;
+
+ zabbix_log(LOG_LEVEL_DEBUG, "In %s() escalationid:" ZBX_FS_UI64 " servicealarmid:" ZBX_FS_UI64 " status:%s",
+ __func__, escalation->escalationid, escalation->acknowledgeid,
+ zbx_escalation_status_string(escalation->status));
+
+ escalation_execute_update_operations(event, NULL, action, NULL, default_timezone);
+
+ escalation->status = ESCALATION_STATUS_COMPLETED;
+
+ zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
+}
+
typedef struct
{
zbx_uint64_t escalationid;
@@ -2441,7 +2474,11 @@ static int process_db_escalations(int now, int *nextcheck, zbx_vector_ptr_t *esc
/* Execute operations and recovery operations, mark changes in 'diffs' for batch saving in DB below. */
diff = escalation_create_diff(escalation);
- if (0 != escalation->acknowledgeid)
+ if (0 != escalation->servicealarmid)
+ {
+ escalation_update(escalation, action, event, default_timezone);
+ }
+ else if (0 != escalation->acknowledgeid)
{
zbx_uint64_t r_eventid = 0;
zbx_uint64_pair_t event_pair;