diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | frontends/php/include/actions.inc.php | 17 | ||||
-rw-r--r-- | frontends/php/include/defines.inc.php | 1 | ||||
-rw-r--r-- | frontends/php/include/forms.inc.php | 11 | ||||
-rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 1 | ||||
-rw-r--r-- | include/common.h | 3 | ||||
-rw-r--r-- | src/zabbix_server/actions.c | 35 |
7 files changed, 68 insertions, 1 deletions
@@ -1,5 +1,6 @@ Changes for 1.5.3 + - [DEV-167] added support of Host Template=<template> in actions (Sasha) - [DEV-168] added more supported items in FreeBSD, NetBSD and OpenBSD (Sasha) - [DEV-161] changed greeting message (Artem) - [DEV-157] added fullscreen icon to monitoring screens (Artem) diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index 1bb5edfa..f18bd128 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -45,6 +45,7 @@ include_once 'include/discovery.inc.php'; } break; case CONDITION_TYPE_HOST: + case CONDITION_TYPE_HOST_TEMPLATE: if(!uint_in_array($ac_data['value'],explode(',',$available_hosts))){ $result = false; } @@ -87,6 +88,7 @@ include_once 'include/discovery.inc.php'; } break; case CONDITION_TYPE_HOST: + case CONDITION_TYPE_HOST_TEMPLATE: if(!uint_in_array($ac_data['value'],explode(',',$available_hosts))){ error(S_INCORRECT_HOST); $result = false; @@ -310,6 +312,7 @@ include_once 'include/discovery.inc.php'; function condition_type2str($conditiontype) { $str_type[CONDITION_TYPE_HOST_GROUP] = S_HOST_GROUP; + $str_type[CONDITION_TYPE_HOST_TEMPLATE] = S_HOST_TEMPLATE; $str_type[CONDITION_TYPE_TRIGGER] = S_TRIGGER; $str_type[CONDITION_TYPE_HOST] = S_HOST; $str_type[CONDITION_TYPE_TRIGGER_NAME] = S_TRIGGER_DESCRIPTION; @@ -341,6 +344,7 @@ include_once 'include/discovery.inc.php'; $str_val = expand_trigger_description($value); break; case CONDITION_TYPE_HOST: + case CONDITION_TYPE_HOST_TEMPLATE: $str_val = get_host_by_hostid($value); $str_val = $str_val['host']; break; @@ -469,6 +473,7 @@ include_once 'include/discovery.inc.php'; { $conditions[EVENT_SOURCE_TRIGGERS] = array( CONDITION_TYPE_HOST_GROUP, + CONDITION_TYPE_HOST_TEMPLATE, CONDITION_TYPE_HOST, CONDITION_TYPE_TRIGGER, CONDITION_TYPE_TRIGGER_NAME, @@ -537,6 +542,10 @@ include_once 'include/discovery.inc.php'; CONDITION_OPERATOR_EQUAL, CONDITION_OPERATOR_NOT_EQUAL ); + $operators[CONDITION_TYPE_HOST_TEMPLATE] = array( + CONDITION_OPERATOR_EQUAL, + CONDITION_OPERATOR_NOT_EQUAL + ); $operators[CONDITION_TYPE_HOST] = array( CONDITION_OPERATOR_EQUAL, CONDITION_OPERATOR_NOT_EQUAL @@ -615,6 +624,14 @@ include_once 'include/discovery.inc.php'; return false; } break; + case CONDITION_TYPE_HOST_TEMPLATE: + if(!uint_in_array($value, + get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY))) + { + error(S_INCORRECT_GROUP); + return false; + } + break; case CONDITION_TYPE_TRIGGER: if( !DBfetch(DBselect('select triggerid from triggers where triggerid='.$value)) || !check_right_on_trigger_by_triggerid(PERM_READ_ONLY, $value) ) diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index c463ece2..42edde1c 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -113,6 +113,7 @@ define('CONDITION_TYPE_DSTATUS', 10); define('CONDITION_TYPE_DUPTIME', 11); define('CONDITION_TYPE_DVALUE', 12); + define('CONDITION_TYPE_HOST_TEMPLATE', 13); 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 38b93934..c461b2da 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -3017,6 +3017,17 @@ 'T') ); break; + case CONDITION_TYPE_HOST_TEMPLATE: + $frmAction->AddVar('new_condition[value]','0'); + $rowCondition[] = array( + new CTextBox('host','',20,'yes'), + new CButton('btn1',S_SELECT, + "return PopUp('popup.php?dstfrm=".$frmAction->GetName(). + "&dstfld1=new_condition%5Bvalue%5D&dstfld2=host&srctbl=host_templates". + "&srcfld1=hostid&srcfld2=host',450,450);", + 'T') + ); + break; case CONDITION_TYPE_HOST: $frmAction->AddVar('new_condition[value]','0'); $rowCondition[] = array( diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 4e03888e..1da40e20 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -250,6 +250,7 @@ 'S_CANNOT_LINK_TO_TEMPLATE'=> 'CAnnot link to template', 'S_UNLINK_FROM_TEMPLATE'=> 'Unlink from template', 'S_CANNOT_UNLINK_FROM_TEMPLATE'=> 'Cannot unlink from template', + 'S_HOST_TEMPLATE'=> 'Host template', 'S_INCORRECT_TRIGGER'=> 'Incorrect trigger', 'S_INCORRECT_HOST'=> 'Incorrect host', diff --git a/include/common.h b/include/common.h index 2aa1e12a..56056a11 100644 --- a/include/common.h +++ b/include/common.h @@ -283,7 +283,8 @@ typedef enum CONDITION_TYPE_DSERVICE_PORT, CONDITION_TYPE_DSTATUS, CONDITION_TYPE_DUPTIME, - CONDITION_TYPE_DVALUE + CONDITION_TYPE_DVALUE, + CONDITION_TYPE_HOST_TEMPLATE } zbx_condition_type_t; /* Condition operators */ diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c index 91b8cf40..565f3d07 100644 --- a/src/zabbix_server/actions.c +++ b/src/zabbix_server/actions.c @@ -123,6 +123,41 @@ static int check_action_condition(DB_EVENT *event, DB_CONDITION *condition) } DBfree_result(result); } + else if (event->source == EVENT_SOURCE_TRIGGERS && condition->conditiontype == CONDITION_TYPE_HOST_TEMPLATE) + { + condition_value = zbx_atoui64(condition->value); + + result = DBselect("select distinct ht.templateid from hosts_templates ht,items i,functions f,triggers t" + " where ht.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid=" ZBX_FS_UI64, + event->objectid); + + if (condition->operator == CONDITION_OPERATOR_EQUAL) { + while (NULL != (row = DBfetch(result))) { + hostid = zbx_atoui64(row[0]); + + if (condition_value == hostid) { + ret = SUCCEED; + break; + } + } + } else if (condition->operator == CONDITION_OPERATOR_NOT_EQUAL) { + ret = SUCCEED; + + while (NULL != (row = DBfetch(result))) { + hostid = zbx_atoui64(row[0]); + + if (condition_value == hostid) { + ret = FAIL; + break; + } + } + } else + 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_TRIGGERS && condition->conditiontype == CONDITION_TYPE_HOST) { ZBX_STR2UINT64(condition_value, condition->value); |