diff options
author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-03 12:01:36 +0000 |
---|---|---|
committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-06-03 12:01:36 +0000 |
commit | c3d3eaea01e691748c2d2b875bb5326e9e494047 (patch) | |
tree | f663f87c81c7b5588f94d5064f17252517c5168c /src | |
parent | 62d85d6dedace6ef9470bc2d8ff394df18f71bf2 (diff) | |
download | zabbix-c3d3eaea01e691748c2d2b875bb5326e9e494047.tar.gz zabbix-c3d3eaea01e691748c2d2b875bb5326e9e494047.tar.xz zabbix-c3d3eaea01e691748c2d2b875bb5326e9e494047.zip |
- [DEV-173] added support of notification escalations on server side
git-svn-id: svn://svn.zabbix.com/trunk@5748 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/zbxdbhigh/db.c | 7 | ||||
-rw-r--r-- | src/zabbix_server/actions.c | 2 | ||||
-rw-r--r-- | src/zabbix_server/escalator/escalator.c | 20 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index 1a7c609c..59a99216 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -1582,14 +1582,13 @@ int DBstart_escalation(zbx_uint64_t actionid, zbx_uint64_t triggerid, zbx_uint64 return SUCCEED; } -int DBstop_escalation(zbx_uint64_t actionid, zbx_uint64_t triggerid, zbx_uint64_t eventid) +int DBstop_escalation(zbx_uint64_t actionid, zbx_uint64_t triggerid) { DBexecute("update escalations set status=%d,nextcheck=0 where actionid=" ZBX_FS_UI64 - " and triggerid=" ZBX_FS_UI64 " and eventid = " ZBX_FS_UI64, + " and triggerid=" ZBX_FS_UI64, ESCALATION_STATUS_RECOVERY, actionid, - triggerid, - eventid); + triggerid); return SUCCEED; } diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c index 1323ff8e..f52dad8f 100644 --- a/src/zabbix_server/actions.c +++ b/src/zabbix_server/actions.c @@ -840,7 +840,7 @@ void process_actions(DB_EVENT *event) zabbix_log( LOG_LEVEL_DEBUG, "Conditions do not match our event. Do not execute operations."); if (event->source == EVENT_SOURCE_TRIGGERS && event->object == EVENT_OBJECT_TRIGGER) - DBstop_escalation(action.actionid, event->objectid, event->eventid); + DBstop_escalation(action.actionid, event->objectid); } } DBfree_result(result); diff --git a/src/zabbix_server/escalator/escalator.c b/src/zabbix_server/escalator/escalator.c index 1272f2e1..3adcac49 100644 --- a/src/zabbix_server/escalator/escalator.c +++ b/src/zabbix_server/escalator/escalator.c @@ -412,9 +412,9 @@ static void execute_operations(DB_ESCALATION *escalation, DB_EVENT *event, DB_AC zbx_free(p); } - if (0 == action->esc_period) - escalation->status = ESCALATION_STATUS_COMPLETED; - else { + if (0 == action->esc_period) { + escalation->status = (action->recovery_msg == 1) ? ESCALATION_STATUS_SLEEP : ESCALATION_STATUS_COMPLETED; + } else { if (0 == operations) { result = DBselect("select operationid from operations where actionid=" ZBX_FS_UI64 " and esc_step_from>%d", action->actionid, @@ -430,7 +430,7 @@ static void execute_operations(DB_ESCALATION *escalation, DB_EVENT *event, DB_AC esc_period = (0 != esc_period) ? esc_period : action->esc_period; escalation->nextcheck = time(NULL) + esc_period; } else - escalation->status = ESCALATION_STATUS_COMPLETED; + escalation->status = (action->recovery_msg == 1) ? ESCALATION_STATUS_SLEEP : ESCALATION_STATUS_COMPLETED; } } @@ -441,9 +441,11 @@ static void process_recovery_msg(DB_ESCALATION *escalation, DB_EVENT *event, DB_ zbx_uint64_t userid; if (1 == action->recovery_msg) { - result = DBselect("select distinct userid from alerts where actionid=" ZBX_FS_UI64 " and eventid=" ZBX_FS_UI64, + result = DBselect("select distinct userid from alerts where actionid=" ZBX_FS_UI64 + " and eventid=" ZBX_FS_UI64 " and alerttype=%d", action->actionid, - event->eventid); + event->eventid, + ALERT_TYPE_MESSAGE); while (NULL != (row = DBfetch(result))) { userid = zbx_atoui64(row[0]); @@ -469,7 +471,7 @@ static void execute_escalation(DB_ESCALATION *escalation, DB_EVENT *event) switch (escalation->status) { case ESCALATION_STATUS_ACTIVE: - result = DBselect("select actionid,eventsource,esc_period,def_shortdata,def_longdata" + result = DBselect("select actionid,eventsource,esc_period,def_shortdata,def_longdata,recovery_msg" " from actions where actionid=" ZBX_FS_UI64, escalation->actionid); break; @@ -561,7 +563,9 @@ static void process_escalations(int now) if (escalation.status == ESCALATION_STATUS_COMPLETED) DBremove_escalation(escalation.escalationid); else - DBexecute("update escalations set esc_step=%d,nextcheck=%d where escalationid=" ZBX_FS_UI64, + DBexecute("update escalations set status=%d,esc_step=%d,nextcheck=%d" + " where escalationid=" ZBX_FS_UI64, + escalation.status, escalation.esc_step, escalation.nextcheck, escalation.escalationid); |