summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-06-26 07:20:41 +0000
committersasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-06-26 07:20:41 +0000
commit0524a8a2dfb101e926b5a092c32a3e7c4dbb2543 (patch)
tree36f09ca9e171267aa2d77a7cc69e336f3663cd37
parente20118aa386b5d231699ee309a6cd7cbdd166756 (diff)
downloadzabbix-0524a8a2dfb101e926b5a092c32a3e7c4dbb2543.tar.gz
zabbix-0524a8a2dfb101e926b5a092c32a3e7c4dbb2543.tar.xz
zabbix-0524a8a2dfb101e926b5a092c32a3e7c4dbb2543.zip
- [DEV-183] added support of applications in action conditions
git-svn-id: svn://svn.zabbix.com/trunk@5793 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog1
-rw-r--r--frontends/php/include/actions.inc.php17
-rw-r--r--frontends/php/include/config.inc.php2
-rw-r--r--frontends/php/include/defines.inc.php1
-rw-r--r--frontends/php/include/forms.inc.php3
-rw-r--r--include/common.h3
-rw-r--r--src/zabbix_server/actions.c41
7 files changed, 63 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index c5f9b4ae..cc5e5a11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Changes for 1.5.4
+ - [DEV-183] added support of applications in action conditions (Sasha)
- [DEV-174] added ability to edit user medias (Artem)
- [DEV-185] added support of zabbix[uptime] and zabbix[boottime] (Alexei)
- [DEV-176] implemented "color only non-zero values" in "Status of triggers" (Artem)
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index c8e08b55..c6d8520a 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -361,7 +361,8 @@ function condition_type2str($conditiontype)
$str_type[CONDITION_TYPE_DSTATUS] = S_DISCOVERY_STATUS;
$str_type[CONDITION_TYPE_DUPTIME] = S_UPTIME_DOWNTIME;
$str_type[CONDITION_TYPE_DVALUE] = S_RECEIVED_VALUE;
- $str_type[CONDITION_TYPE_EVENT_ACKNOWLEDGED] = S_EVENT_ACKNOWLEDGED;
+ $str_type[CONDITION_TYPE_EVENT_ACKNOWLEDGED] = S_EVENT_ACKNOWLEDGED;
+ $str_type[CONDITION_TYPE_APPLICATION] = S_APPLICATION;
if(isset($str_type[$conditiontype]))
return $str_type[$conditiontype];
@@ -418,6 +419,9 @@ function condition_value2str($conditiontype, $value)
case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
$str_val = ($value)?S_ACK:S_NOT_ACK;
break;
+ case CONDITION_TYPE_APPLICATION:
+ $str_val = $value;
+ break;
default:
return S_UNKNOWN;
break;
@@ -530,6 +534,8 @@ function get_operation_desc($type=SHORT_DESCRITION, $data){
function get_conditions_by_eventsource($eventsource){
$conditions[EVENT_SOURCE_TRIGGERS] = array(
+ CONDITION_TYPE_APPLICATION,
+ CONDITION_TYPE_EVENT_ACKNOWLEDGED,
CONDITION_TYPE_HOST_GROUP,
CONDITION_TYPE_HOST_TEMPLATE,
CONDITION_TYPE_HOST,
@@ -537,8 +543,7 @@ function get_conditions_by_eventsource($eventsource){
CONDITION_TYPE_TRIGGER_NAME,
CONDITION_TYPE_TRIGGER_SEVERITY,
CONDITION_TYPE_TRIGGER_VALUE,
- CONDITION_TYPE_TIME_PERIOD,
- CONDITION_TYPE_EVENT_ACKNOWLEDGED
+ CONDITION_TYPE_TIME_PERIOD
);
$conditions[EVENT_SOURCE_DISCOVERY] = array(
CONDITION_TYPE_DHOST_IP,
@@ -673,6 +678,11 @@ function get_operators_by_conditiontype($conditiontype)
$operators[CONDITION_TYPE_EVENT_ACKNOWLEDGED] = array(
CONDITION_OPERATOR_EQUAL
);
+ $operators[CONDITION_TYPE_APPLICATION] = array(
+ CONDITION_OPERATOR_EQUAL,
+ CONDITION_OPERATOR_LIKE,
+ CONDITION_OPERATOR_NOT_LIKE
+ );
if(isset($operators[$conditiontype]))
return $operators[$conditiontype];
@@ -770,6 +780,7 @@ function validate_condition($conditiontype, $value)
case CONDITION_TYPE_TRIGGER_SEVERITY:
case CONDITION_TYPE_DUPTIME:
case CONDITION_TYPE_DVALUE:
+ case CONDITION_TYPE_APPLICATION:
break;
default:
error(S_INCORRECT_CONDITION_TYPE);
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 01b79851..219df8cd 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -24,10 +24,10 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
?>
<?php
+ require_once "include/func.inc.php";
require_once "include/defines.inc.php";
require_once "include/html.inc.php";
require_once "include/copt.lib.php";
- require_once "include/func.inc.php";
require_once "include/profiles.inc.php";
require_once "conf/maintenance.inc.php";
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index b217c340..a21cb69c 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -119,6 +119,7 @@
define('CONDITION_TYPE_DVALUE', 12);
define('CONDITION_TYPE_HOST_TEMPLATE', 13);
define('CONDITION_TYPE_EVENT_ACKNOWLEDGED', 14);
+ define('CONDITION_TYPE_APPLICATION', 15);
define('CONDITION_OPERATOR_EQUAL', 0);
define('CONDITION_OPERATOR_NOT_EQUAL', 1);
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 80ebafd9..8aaefa72 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -3171,6 +3171,9 @@
case CONDITION_TYPE_DVALUE:
$rowCondition[] = new CTextBox('new_condition[value]', "", 40);
break;
+ case CONDITION_TYPE_APPLICATION:
+ $rowCondition[] = new CTextBox('new_condition[value]', "", 40);
+ break;
}
$tblCond->AddRow($rowCondition);
diff --git a/include/common.h b/include/common.h
index 751fb0af..fe2e0430 100644
--- a/include/common.h
+++ b/include/common.h
@@ -285,7 +285,8 @@ typedef enum
CONDITION_TYPE_DUPTIME,
CONDITION_TYPE_DVALUE,
CONDITION_TYPE_HOST_TEMPLATE,
- CONDITION_TYPE_EVENT_ACKNOWLEDGED
+ CONDITION_TYPE_EVENT_ACKNOWLEDGED,
+ CONDITION_TYPE_APPLICATION
} zbx_condition_type_t;
/* Condition operators */
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)