From 0524a8a2dfb101e926b5a092c32a3e7c4dbb2543 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 26 Jun 2008 07:20:41 +0000 Subject: - [DEV-183] added support of applications in action conditions git-svn-id: svn://svn.zabbix.com/trunk@5793 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- src/zabbix_server/actions.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src') diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c index f52dad8f..ca88da7c 100644 --- a/src/zabbix_server/actions.c +++ b/src/zabbix_server/actions.c @@ -356,6 +356,47 @@ int check_action_condition(DB_EVENT *event, DB_CONDITION *condition) DBfree_result(result); } + else if(event->source == EVENT_SOURCE_TRIGGERS && condition->conditiontype == CONDITION_TYPE_APPLICATION) + { + result = DBselect("select distinct a.name from applications a,items_applications i,functions f,triggers t" + " where a.applicationid=i.applicationid and i.itemid=f.itemid" + " and f.triggerid=t.triggerid and t.triggerid=" ZBX_FS_UI64, + event->objectid); + + switch (condition->operator) { + case CONDITION_OPERATOR_EQUAL: + while (NULL != (row = DBfetch(result))) { + if (0 == strcmp(row[0], condition->value)) { + ret = SUCCEED; + break; + } + } + break; + case CONDITION_OPERATOR_LIKE: + while (NULL != (row = DBfetch(result))) { + if (NULL != strstr(row[0], condition->value)) { + ret = SUCCEED; + break; + } + } + break; + case CONDITION_OPERATOR_NOT_LIKE: + ret = SUCCEED; + while (NULL != (row = DBfetch(result))) { + if (NULL != strstr(row[0], condition->value)) { + ret = FAIL; + break; + } + } + break; + default: + zabbix_log( LOG_LEVEL_ERR, "Unsupported operator [%d] for condition id [" ZBX_FS_UI64 "]", + condition->operator, + condition->conditionid); + } + + DBfree_result(result); + } else if(event->source == EVENT_SOURCE_DISCOVERY && event->object == EVENT_OBJECT_DSERVICE && condition->conditiontype == CONDITION_TYPE_DVALUE) -- cgit