summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/items.inc.php
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-10-21 11:05:00 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-10-21 11:05:00 +0000
commit469010ebdf4c1d779e41eacfcdc4f7c479cbb334 (patch)
tree265c3d34fd2e950b6f6cdbd5e1ebc23c4771bc23 /frontends/php/include/items.inc.php
parent381c6742533757053481569ae11496f8528cd37c (diff)
downloadzabbix-469010ebdf4c1d779e41eacfcdc4f7c479cbb334.tar.gz
zabbix-469010ebdf4c1d779e41eacfcdc4f7c479cbb334.tar.xz
zabbix-469010ebdf4c1d779e41eacfcdc4f7c479cbb334.zip
- [DEV-43] support of new macros {ITEM.VALUE}, {ITEM.VALUE1}, etc (Alexei)
[svn merge -r4874:4876 svn://svn.zabbix.com/branches/1.4.j] git-svn-id: svn://svn.zabbix.com/trunk@4877 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/items.inc.php')
-rw-r--r--frontends/php/include/items.inc.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index 3eea2f4b..f44fa2cf 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -1111,4 +1111,72 @@ COpt::profiling_stop('prepare table');
}
return $lastvalue;
}
+
+ /*
+ * Function: item_get_history
+ *
+ * Description:
+ * Get value from history
+ *
+ * Peremeters:
+ * itemid - item ID
+ * index - 0 - last value, 1 - prev value, 2 - prev prev, and so on
+ * if index=0, clock is used
+ *
+ * Author:
+ * Alexei Vladishev
+ *
+ * Comments:
+ *
+ */
+ function item_get_history($db_item,$index = 1, $clock = 0)
+ {
+ $value = NULL;
+
+ switch($db_item["value_type"])
+ {
+ case ITEM_VALUE_TYPE_FLOAT:
+ $table = "history";
+ break;
+ case ITEM_VALUE_TYPE_UINT64:
+ $table = "history_uint";
+ break;
+ case ITEM_VALUE_TYPE_TEXT:
+ $table = "history_text";
+ break;
+ case ITEM_VALUE_TYPE_STR:
+ $table = "history_str";
+ break;
+ case ITEM_VALUE_TYPE_LOG:
+ default:
+ $table = "history_log";
+ break;
+ }
+ if($index == 0)
+ {
+ $sql="select value from $table where itemid=".$db_item["itemid"]." and clock<=$clock order by clock desc";
+ $result = DBselect($sql, 1);
+ $row = DBfetch(DBselect($sql, 1));
+ if($row)
+ {
+ $value = $row["value"];
+ }
+ }
+ else
+ {
+ $sql="select value from $table where itemid=".$db_item["itemid"]." order by clock desc";
+ $result = DBselect($sql, $index);
+ $num=1;
+ while($row = DBfetch($result))
+ {
+ if($num == $index)
+ {
+ $value = $row["value"];
+ break;
+ }
+ $num++;
+ }
+ }
+ return $value;
+ }
?>