summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-31 09:44:53 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-31 09:44:53 +0000
commitf7b95a3f252ac4615e698250ca32de04d187b6ec (patch)
tree65bca851d9f1748c936d9575f4e7b715e6bbb129 /frontends/php
parent718d89f5e6eac164f4c4fb87f6333f010e2bf6c3 (diff)
downloadzabbix-f7b95a3f252ac4615e698250ca32de04d187b6ec.tar.gz
zabbix-f7b95a3f252ac4615e698250ca32de04d187b6ec.tar.xz
zabbix-f7b95a3f252ac4615e698250ca32de04d187b6ec.zip
added items for webtests & fixed massupdate
git-svn-id: svn://svn.zabbix.com/trunk@3775 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/include/defines.inc.php5
-rw-r--r--frontends/php/include/httptest.inc.php97
-rw-r--r--frontends/php/include/items.inc.php3
-rw-r--r--frontends/php/items.php2
4 files changed, 94 insertions, 13 deletions
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index 1c5898ad..5b547bae 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -298,9 +298,10 @@
define("HTTPTEST_STATUS_ACTIVE", 0);
define("HTTPTEST_STATUS_DISABLED", 1);
- define("HTTPSTEP_ITEM_TYPE_IN", 2);
- define("HTTPSTEP_ITEM_TYPE_TIME", 1);
define("HTTPSTEP_ITEM_TYPE_RSPCODE", 0);
+ define("HTTPSTEP_ITEM_TYPE_TIME", 1);
+ define("HTTPSTEP_ITEM_TYPE_IN", 2);
+ define("HTTPSTEP_ITEM_TYPE_LASTSTEP", 3);
define("BR", "<br/>\n");
define("SPACE", "&nbsp;");
diff --git a/frontends/php/include/httptest.inc.php b/frontends/php/include/httptest.inc.php
index 3d77e290..bc91c798 100644
--- a/frontends/php/include/httptest.inc.php
+++ b/frontends/php/include/httptest.inc.php
@@ -45,11 +45,8 @@
return $status;
}
- function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required)
+ function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required, $delay, $history, $trends)
{
- $history = 30; // TODO !!! Allow user set this parametr
- $trends = 90; // TODO !!! Allow user set this parametr
-
if (!eregi('^([0-9a-zA-Z\_\.-\$ ]+)$', $name))
{
error("Scenario step name should contain '0-9a-zA-Z_ .$'- characters only");
@@ -101,12 +98,20 @@
foreach($monitored_items as $item)
{
- if(!($item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid '.
+ $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid '.
' from items i, httpstepitem hi '.
' where hi.httpstepid='.$httpstepid.' and hi.itemid=i.itemid '.
- ' and hi.type='.$item['httpstepitemtype']))))
+ ' and hi.type='.$item['httpstepitemtype']));
+
+ if(!$item_data)
{
- if (!($itemid = add_item($item['description'], $item['key_'], $hostid, 30,
+ $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid '.
+ ' from items i where i.key_='.zbx_dbstr($item['key_']).' and i.hostid='.$hostid));
+ }
+
+ if(!$item_data)
+ {
+ if (!($itemid = add_item($item['description'], $item['key_'], $hostid, $delay,
$history, ITEM_STATUS_ACTIVE, ITEM_TYPE_HTTPTEST, '', '', $item['type'], 'localhost',
161, $item['units'], 0, 0, '', 0, '', '', '0', $trends, '', 0, '', array($applicationid))))
return false;
@@ -115,7 +120,7 @@
{
$itemid = $item_data['itemid'];
- if (!(update_item($itemid, $item['description'], $item['key_'], $hostid, 30, $item_data['history'],
+ if (!(update_item($itemid, $item['description'], $item['key_'], $hostid, $delay, $item_data['history'],
$item_data['status'], ITEM_TYPE_HTTPTEST, '', '', $item['type'], 'localhost', 161,
$item['units'], 0, 0, $item_data['delta'], 0, '', '', '0', $item_data['trends'], '',
$item_data['valuemapid'], '', array($applicationid))))
@@ -139,6 +144,9 @@
function db_save_httptest($httptestid, $hostid, $application, $name, $delay, $status, $agent, $macros, $steps)
{
+ $history = 30; // TODO !!! Allow user set this parametr
+ $trends = 90; // TODO !!! Allow user set this parametr
+
if (!eregi('^([0-9a-zA-Z\_\.-\$ ]+)$', $name))
{
error("Scenario name should contain '0-9a-zA-Z_.$ '- characters only");
@@ -202,7 +210,8 @@
if(!isset($s['required'])) $s['required'] = '';
$result = db_save_step($hostid, $applicationid, $httptestid,
- $name, $s['name'], $sid, $s['timeout'], $s['url'], $s['posts'], $s['required']);
+ $name, $s['name'], $sid, $s['timeout'], $s['url'], $s['posts'], $s['required'],
+ $delay, $history, $trends);
if(!$result) break;
@@ -220,7 +229,75 @@
}
}
- // TODO !!! Create items for httptest
+ if($result)
+ {
+ $monitored_items = array(
+ array(
+ 'description' => 'Download speed for scenario \'$1\'',
+ 'key_' => 'web.test.in['.$name.',,bps]',
+ 'type' => ITEM_VALUE_TYPE_FLOAT,
+ 'units' => 'bps',
+ 'httptestitemtype'=> HTTPSTEP_ITEM_TYPE_IN),
+ array(
+ 'description' => 'Failed step of scenario \'$1\'',
+ 'key_' => 'web.test.fail['.$name.']',
+ 'type' => ITEM_VALUE_TYPE_UINT64,
+ 'units' => '',
+ 'httptestitemtype'=> HTTPSTEP_ITEM_TYPE_LASTSTEP)
+ );
+
+ foreach($monitored_items as $item)
+ {
+ $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid '.
+ ' from items i, httptestitem hi '.
+ ' where hi.httptestid='.$httptestid.' and hi.itemid=i.itemid '.
+ ' and hi.type='.$item['httptestitemtype']));
+
+ if(!$item_data)
+ {
+ $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid '.
+ ' from items i where i.key_='.zbx_dbstr($item['key_']).' and i.hostid='.$hostid));
+ }
+
+ if(!$item_data)
+ {
+ if (!($itemid = add_item($item['description'], $item['key_'], $hostid, $delay,
+ $history, ITEM_STATUS_ACTIVE, ITEM_TYPE_HTTPTEST, '', '', $item['type'], 'localhost',
+ 161, $item['units'], 0, 0, '', 0, '', '', '0', $trends, '', 0, '', array($applicationid))))
+ {
+ $result = false;
+ break;
+ }
+ }
+ else
+ {
+ $itemid = $item_data['itemid'];
+
+ if (!(update_item($itemid, $item['description'], $item['key_'], $hostid, $delay, $item_data['history'],
+ $item_data['status'], ITEM_TYPE_HTTPTEST, '', '', $item['type'], 'localhost', 161,
+ $item['units'], 0, 0, $item_data['delta'], 0, '', '', '0', $item_data['trends'], '',
+ $item_data['valuemapid'], '', array($applicationid))))
+ {
+ $result = false;
+ break;
+ }
+ }
+
+
+ $httptestitemid = get_dbid('httptestitem', 'httptestitemid');
+
+ DBexecute('delete from httptestitem where itemid='.$itemid);
+
+ if (!DBexecute('insert into httptestitem'.
+ ' (httptestitemid, httptestid, itemid, type) '.
+ ' values ('.$httptestitemid.','.$httptestid.','.$itemid.','.$item['httptestitemtype'].')'
+ ))
+ {
+ $result = false;
+ break;
+ }
+ }
+ }
if(!$result && isset($test_added)) delete_httptest($httptestid);
else $restult = $httptestid;
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index 65128904..a225a860 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -427,6 +427,9 @@
$$var_name = $item_data[$info['db_varname']];
}
+ if($item_data['type'] == ITEM_TYPE_HTTPTEST)
+ $applications = get_applications_by_itemid($itemid);
+
return update_item($itemid,
$description,$key,$hostid,$delay,
$history,$status,$type,
diff --git a/frontends/php/items.php b/frontends/php/items.php
index 423e1e54..cad896f8 100644
--- a/frontends/php/items.php
+++ b/frontends/php/items.php
@@ -537,7 +537,7 @@ include_once "include/page_header.php";
if(ZBX_DISTRIBUTED && isset($_REQUEST['with_node']))
{
$from_tables['n'] = 'nodes n';
- $where_case[] = 'n.nodeid='.('i.itemid');
+ $where_case[] = 'n.nodeid='.DBid2nodeid('i.itemid');
$where_case[] = 'n.name like '.zbx_dbstr('%'.$_REQUEST['with_node'].'%');
}
if(isset($_REQUEST['with_group']))