summaryrefslogtreecommitdiffstats
path: root/frontends/php/popup_trexpr.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-06-06 10:35:31 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-06-06 10:35:31 +0000
commitaef82a51d4e5f2aa85d29f882b2c0713545f25f0 (patch)
treed72fe9e775405132166c8c4d8b3371bebd600141 /frontends/php/popup_trexpr.php
parent94eb3a3761163d3be70d010a7b7dac125894f909 (diff)
downloadzabbix-aef82a51d4e5f2aa85d29f882b2c0713545f25f0.tar.gz
zabbix-aef82a51d4e5f2aa85d29f882b2c0713545f25f0.tar.xz
zabbix-aef82a51d4e5f2aa85d29f882b2c0713545f25f0.zip
- merged from branches/1.4.1 rev. 4239:4240 (Eugene) [fixed 'count' function for trigger expression]
git-svn-id: svn://svn.zabbix.com/trunk@4241 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/popup_trexpr.php')
-rw-r--r--frontends/php/popup_trexpr.php120
1 files changed, 90 insertions, 30 deletions
diff --git a/frontends/php/popup_trexpr.php b/frontends/php/popup_trexpr.php
index 41b348ce..05dbd94c 100644
--- a/frontends/php/popup_trexpr.php
+++ b/frontends/php/popup_trexpr.php
@@ -40,6 +40,33 @@ include_once "include/page_header.php";
'=' => '=',
'#' => 'NOT');
+ $metrics = array(
+ PARAM_TYPE_SECONDS => S_SECONDS,
+ PARAM_TYPE_COUNTS => S_COUNT);
+
+ $param1_sec_count = array(
+ array(
+ 'C' => S_LAST_OF.' T', /* caption */
+ 'T' => T_ZBX_INT, /* type */
+ 'M' => $metrics /* metrcis */
+ ));
+
+ $param1_str = array(
+ array(
+ 'C' => 'T', /* caption */
+ 'T' => T_ZBX_STR,
+ ));
+
+ $param2_sec_val = array(
+ array(
+ 'C' => S_LAST_OF.' T', /* caption */
+ 'T' => T_ZBX_INT,
+ ),
+ array(
+ 'C' => 'V', /* caption */
+ 'T' => T_ZBX_STR,
+ ));
+
$functions = array(
'abschange' => array(
'description' => 'Absolute difference between last and previous value {OP} N',
@@ -48,21 +75,21 @@ include_once "include/page_header.php";
'avg' => array(
'description' => 'Average value for period of T times {OP} N',
'operators' => $operators,
- 'T' => T_ZBX_INT
+ 'params' => $param1_sec_count
),
'delta' => array(
'description' => 'Difference between MAX and MIN value of T times {OP} N',
'operators' => $operators,
- 'T' => T_ZBX_INT
+ 'params' => $param1_sec_count
),
'change' => array(
'description' => 'Difference between last and previous value of T times {OP} N.',
'operators' => $operators
),
'count' => array(
- 'description' => 'Number of successfully retrieved values for period of time T {OP} N.',
+ 'description' => 'Number of successfully retrieved values V for period of time T {OP} N.',
'operators' => $operators,
- 'T' => T_ZBX_INT
+ 'params' => $param2_sec_val
),
'diff' => array(
'description' => 'N {OP} X, where X is 1 - if last and previous values differs, 0 - otherwise.',
@@ -75,12 +102,12 @@ include_once "include/page_header.php";
'max' => array(
'description' => 'Maximal value for period of time T {OP} N.',
'operators' => $operators,
- 'T' => T_ZBX_INT
+ 'params' => $param1_sec_count
),
'min' => array(
'description' => 'Minimal value for period of time T {OP} N.',
'operators' => $operators,
- 'T' => T_ZBX_INT
+ 'params' => $param1_sec_count
),
'prev' => array(
'description' => 'Previous value {OP} N.',
@@ -89,12 +116,12 @@ include_once "include/page_header.php";
'str' => array(
'description' => 'Find string T last value. N {OP} X, where X is 1 - if found, 0 - otherwise',
'operators' => $limited_operators,
- 'T' => T_ZBX_STR
+ 'params' => $param1_str
),
'sum' => array(
'description' => 'Sum of values for period of time T {OP} N',
'operators' => $operators,
- 'T' => T_ZBX_INT
+ 'params' => $param1_sec_count
)
);
@@ -102,8 +129,8 @@ include_once "include/page_header.php";
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "dstfrm"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
- "dstfld1"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "dstfrm"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, null),
+ "dstfld1"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, null),
"expression"=> array(T_ZBX_STR, O_OPT, null, null, null),
@@ -113,7 +140,7 @@ include_once "include/page_header.php";
"paramtype"=> array(T_ZBX_INT, O_OPT, null, IN(PARAM_TYPE_SECONDS.','.PARAM_TYPE_COUNTS), 'isset({insert})'),
"value"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({insert})'),
- "insert"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL)
+ "insert"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null)
);
check_fields($fields);
@@ -145,10 +172,10 @@ include_once "include/page_header.php";
{
$_REQUEST['paramtype'] = PARAM_TYPE_SECONDS;
$_REQUEST['param'] = $expr_res[$pat['idx']['param']];
- if($pat['idx']['param'][0] == '#')
+ if($_REQUEST['param'][0] == '#')
{
$_REQUEST['paramtype'] = PARAM_TYPE_COUNTS;
- $_REQUEST['param'] = ltrim('#', $expr_res[$pat['idx']['param']]);
+ $_REQUEST['param'] = ltrim($_REQUEST['param'],'#');
}
}
@@ -204,7 +231,19 @@ include_once "include/page_header.php";
$param = get_request('param', 0);
$paramtype = get_request('paramtype', PARAM_TYPE_SECONDS);
$value = get_request('value', 0);
-
+
+ if( !is_array($param) )
+ {
+ if( isset($functions[$function]['params']) )
+ {
+ $param = split(',', $param, count($functions[$function]['params']));
+ }
+ else
+ {
+ $param = array($param);
+ }
+ }
+
?>
<script language="JavaScript" type="text/javascript">
<!--
@@ -244,7 +283,7 @@ function InsertText(obj, value)
$item_data['key_'],
$function,
$paramtype == PARAM_TYPE_COUNTS ? '#' : '',
- $param,
+ rtrim(implode(',', $param),','),
$operator,
$value);
@@ -294,23 +333,44 @@ if(form)
}
$form->AddRow(S_FUNCTION, $cmbFnc);
- if(isset($functions[$function]['T']))
+ if(isset($functions[$function]['params']))
{
- if($functions[$function]['T'] == T_ZBX_INT)
- {
- $cmbParamType = new CComboBox('paramtype', $paramtype);
- $cmbParamType->AddItem(PARAM_TYPE_SECONDS, S_SECONDS);
- $cmbParamType->AddItem(PARAM_TYPE_COUNTS, S_COUNTS);
-
- $form->AddRow(S_LAST_OF.' T', array(
- new CNumericBox('param', $param, 10),
- $cmbParamType
- ));
- }
- else
+ foreach($functions[$function]['params'] as $pid => $pf )
{
- $form->AddRow('T', new CTextBox('param', $param, 30));
- $form->AddVar('paramtype', PARAM_TYPE_SECONDS);
+ $pv = (isset($param[$pid])) ? $param[$pid] : null;
+
+ if($pf['T'] == T_ZBX_INT)
+ {
+ if( 0 == $pid)
+ {
+ if( isset($pf['M']) && is_array($pf['M']))
+ {
+ $cmbParamType = new CComboBox('paramtype', $paramtype);
+ foreach( $pf['M'] as $mid => $caption )
+ {
+ $cmbParamType->AddItem($mid, $caption);
+ }
+ } else {
+ $form->AddVar('paramtype', PARAM_TYPE_SECONDS);
+ $cmbParamType = S_SECONDS;
+ }
+ }
+ else
+ {
+ $cmbParamType = null;
+ }
+
+
+ $form->AddRow(S_LAST_OF.' ', array(
+ new CNumericBox('param['.$pid.']', $pv, 10),
+ $cmbParamType
+ ));
+ }
+ else
+ {
+ $form->AddRow($pf['C'], new CTextBox('param['.$pid.']', $pv, 30));
+ $form->AddVar('paramtype', PARAM_TYPE_SECONDS);
+ }
}
}
else