summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/items.inc.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-07-05 09:22:34 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-07-05 09:22:34 +0000
commit0f93047219d365318ef9feb7005403b1c3155bfa (patch)
treefa08172aad7936d7ab9834f8252432e5f5e59d94 /frontends/php/include/items.inc.php
parent51edf7af1a0eee6ddfe22e62d846abeb8c43bcc3 (diff)
downloadzabbix-0f93047219d365318ef9feb7005403b1c3155bfa.tar.gz
zabbix-0f93047219d365318ef9feb7005403b1c3155bfa.tar.xz
zabbix-0f93047219d365318ef9feb7005403b1c3155bfa.zip
- added frontend-side support of quotes and triger expression validation (Eugene)
- merged rev. 4305:4307 [improved trigger expression syntax and validation] - merged rev. 4329:4331 [more support for quotes in key parameters] - merged rev. 4344:4346 [minor improovments] - merged rev. 4431:4432 [added availability of using ":," character for key] git-svn-id: svn://svn.zabbix.com/trunk@4437 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/items.inc.php')
-rw-r--r--frontends/php/include/items.inc.php171
1 files changed, 144 insertions, 27 deletions
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index cb9eab8e..495056ed 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -20,6 +20,18 @@
?>
<?php
+ /*
+ * Function: item_type2str
+ *
+ * Description:
+ * Represent integer value of item type as string
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function item_type2str($type)
{
switch($type)
@@ -41,6 +53,18 @@
return $type;
}
+ /*
+ * Function: item_value_type2str
+ *
+ * Description:
+ * Represent integer value of item value type as string
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function item_value_type2str($value_type)
{
switch($value_type)
@@ -55,6 +79,18 @@
return $value_type;
}
+ /*
+ * Function: item_value_type2str
+ *
+ * Description:
+ * Represent integer value of item status as string
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function item_status2str($status)
{
switch($status)
@@ -68,6 +104,18 @@
return $status;
}
+ /*
+ * Function: item_status2style
+ *
+ * Description:
+ * Represent integer value of item status as CSS style name
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function item_status2style($status)
{
switch($status)
@@ -151,7 +199,7 @@
if( !eregi('^'.ZBX_EREG_ITEM_KEY_FORMAT.'$', $key) )
{
- error("Key should contain '[]0-9a-zA-Z!_,:()+.*\ $'- characters only");
+ error("Incorrect key format 'key_name[param1,param2,...]'");
return false;
}
@@ -312,6 +360,12 @@
if(($i = array_search(0,$applications)) !== FALSE)
unset($applications[$i]);
+ if( !eregi('^'.ZBX_EREG_ITEM_KEY_FORMAT.'$', $key) )
+ {
+ error("Incorrect key format 'key_name[param1,param2,...]'");
+ return false;
+ }
+
if($delay<1)
{
error("Delay cannot be less than 1 second");
@@ -397,6 +451,18 @@
return $result;
}
+ /*
+ * Function: smart_update_item
+ *
+ * Description:
+ * Update specified fields of item
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function smart_update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,
$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,
$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,
@@ -458,12 +524,19 @@
$item_data['templateid']);
}
- /******************************************************************************
- * *
- * Comments: !!! Don't forget sync code with C !!! *
- * *
- ******************************************************************************/
- function delete_template_items($hostid, $templateid = null /* array format 'arr[id]=name' */, $unlink_mode = false)
+ /*
+ * Function: delete_template_items
+ *
+ * Description:
+ * Delete items from host by templateid
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments: !!! Don't forget sync code with C !!!
+ *
+ */
+ function delete_template_items($hostid, $templateid = null, $unlink_mode = false)
{
$db_items = get_items_by_hostid($hostid);
while($db_item = DBfetch($db_items))
@@ -471,18 +544,14 @@
if($db_item["templateid"] == 0)
continue;
- if($templateid != null)
+ if( !is_null($templateid))
{
+ if ( !is_array($templateid) ) $templateid = array($templateid);
+
$db_tmp_item = get_item_by_itemid($db_item["templateid"]);
- if(is_array($templateid))
- {
- if(!isset($templateid[$db_tmp_item["hostid"]]))
- continue;
- }
- elseif($db_tmp_item["hostid"] != $templateid)
- {
+
+ if ( !in_array($db_tmp_item["hostid"], $templateid) )
continue;
- }
}
if($unlink_mode)
@@ -499,6 +568,18 @@
}
}
+ /*
+ * Function: copy_item_to_host
+ *
+ * Description:
+ * Copy specified item to the host
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function copy_item_to_host($itemid, $hostid, $copy_mode = false)
{
$db_tmp_item = get_item_by_itemid($itemid);
@@ -532,21 +613,28 @@
$copy_mode ? 0 : $db_tmp_item["itemid"]);
}
- /******************************************************************************
- * *
- * Comments: !!! Don't forget sync code with C !!! *
- * *
- ******************************************************************************/
- function copy_template_items($hostid, $templateid = null /* array format 'arr[id]=name' */, $copy_mode = false)
+ /*
+ * Function: copy_template_items
+ *
+ * Description:
+ * Copy items from template to the host
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments: !!! Don't forget sync code with C !!!
+ *
+ */
+ function copy_template_items($hostid, $templateid = null, $copy_mode = false)
{
if($templateid == null)
{
- $templateid = get_templates_by_hostid($hostid);
+ $templateid = array_keys(get_templates_by_hostid($hostid));
}
if(is_array($templateid))
{
- foreach($templateid as $id => $name)
+ foreach($templateid as $id)
copy_template_items($hostid, $id, $copy_mode); // attention recursion
return;
}
@@ -679,15 +767,32 @@
return $result;
}
+ /*
+ * Function: get_n_param
+ *
+ * Description:
+ * Return key parameter by index
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments: indexes between 1-x
+ *
+ */
function get_n_param($key, $num)
{
$param="";
- $params = preg_split('/[\]\[,]/', $key);
+ $num--;
- if(isset($params[$num]))
+ if( ereg('^'.ZBX_EREG_ITEM_KEY_FORMAT.'$', $key, $arr) )
{
- $param = $params[$num];
+ $params = zbx_get_params($arr[ZBX_KEY_PARAM_ID]);
+
+ if(isset($params[$num]))
+ {
+ $param = $params[$num];
+ }
}
return $param;
@@ -714,6 +819,18 @@
return get_host_by_itemid($itemid);
}
+ /*
+ * Function: get_items_data_overview
+ *
+ * Description:
+ * Retrive overview table object for items
+ *
+ * Author:
+ * Eugene Grigorjev (eugene.grigorjev@zabbix.com)
+ *
+ * Comments:
+ *
+ */
function get_items_data_overview($groupid, $nodeid)
{
global $USER_DETAILS;