summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-23 14:55:32 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-23 14:55:32 +0000
commite5259a33066415ea2d424afeb54cad5d4c2b1ad9 (patch)
treeaf3cc24fe287671eb29574baf79999d11f4154b4 /frontends/php/include
parent0dcb4e9f403253a308b088c145e7404c28de2008 (diff)
downloadzabbix-e5259a33066415ea2d424afeb54cad5d4c2b1ad9.tar.gz
zabbix-e5259a33066415ea2d424afeb54cad5d4c2b1ad9.tar.xz
zabbix-e5259a33066415ea2d424afeb54cad5d4c2b1ad9.zip
- improved webmonitoring (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3749 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/classes/ccombobox.inc.php92
-rw-r--r--frontends/php/include/defines.inc.php8
-rw-r--r--frontends/php/include/forms.inc.php59
-rw-r--r--frontends/php/include/httptest.inc.php57
-rw-r--r--frontends/php/include/items.inc.php19
-rw-r--r--frontends/php/include/locales/en_gb.inc.php1
6 files changed, 181 insertions, 55 deletions
diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php
index 387821e6..d05020d7 100644
--- a/frontends/php/include/classes/ccombobox.inc.php
+++ b/frontends/php/include/classes/ccombobox.inc.php
@@ -19,6 +19,8 @@
**/
?>
<?php
+ require_once("include/classes/ctag.inc.php");
+
class CComboItem extends CTag
{
/* public */
@@ -98,7 +100,7 @@
class CListBox extends CComboBox
{
/* public */
- function CListBox($name='combobox',$value=NULL,$size=5,$action=NULL)
+ function CListBox($name='listbox',$value=NULL,$size=5,$action=NULL)
{
parent::CComboBox($name,NULL,$action);
$this->options['multiple'] = 'multiple';
@@ -111,4 +113,92 @@
}
}
+ function inseret_javascript_for_editable_combobox()
+ {
+ if(defined('EDITABLE_COMBOBOX_SCRIPT_INSERTTED')) return;
+
+ define('EDITABLE_COMBOBOX_SCRIPT_INSERTTED', 1);
+?>
+<script language="JavaScript" type="text/javascript">
+<!--
+ function CEditableComboBoxInit(obj)
+ {
+ var opt = obj.options;
+
+ if(obj.value) obj.oldValue = obj.value;
+
+ for (var i = 0; i < opt.length; i++)
+ if (-1 == opt.item(i).value)
+ return;
+
+ opt = document.createElement("option");
+ opt.value = -1;
+ opt.text = "(other ...)";
+
+ if(!obj.options.add)
+ obj.insertBefore(opt, obj.options.item(0));
+ else
+ obj.options.add(opt, 0);
+
+ return;
+ }
+
+ function CEditableComboBoxOnChange(obj,size)
+ {
+ if(-1 != obj.value)
+ {
+ obj.oldValue = obj.value;
+ }
+ else
+ {
+ var new_obj = document.createElement("input");
+ new_obj.type = "text";
+ new_obj.name = obj.name;
+ if(size && size > 0)
+ {
+ new_obj.size = size;
+ }
+ new_obj.className = obj.className;
+ if(obj.oldValue) new_obj.value = obj.oldValue;
+ obj.parentNode.replaceChild(new_obj, obj);
+ new_obj.focus();
+ new_obj.select();
+ }
+ }
+-->
+</script>
+<?php
+ }
+
+ class CEditableComboBox extends CComboBox
+ {
+ function CEditableComboBox($name='editablecombobox',$value=NULL,$size=0,$action=NULL)
+ {
+ inseret_javascript_for_editable_combobox();
+
+ parent::CComboBox($name,$value,$action);
+ parent::AddOption('onfocus','CEditableComboBoxInit(this);');
+ parent::AddOption('onchange','CEditableComboBoxOnChange(this,'.$size.');');
+ }
+
+ function AddItem($value, $caption='', $selected=NULL, $enabled='yes')
+ {
+ if(is_null($selected))
+ {
+ if($value == $this->value || (is_array($this->value) && in_array($value, $this->value)))
+ $this->value_exist = 1;
+ }
+
+ parent::AddItem($value,$caption,$selected,$enabled);
+ }
+
+ function ToString($destroy=true)
+ {
+ if(!isset($this->value_exist) && !empty($this->value))
+ {
+ $this->AddItem($this->value, $this->value, 'yes');
+ }
+ return parent::ToString($destroy);
+ }
+ }
?>
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index 2e5af920..e95d19ec 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -294,8 +294,12 @@
define("ZBX_NODE_LOCAL", 1);
define("ZBX_NODE_MASTER", 2);
- define("HTTPTEST_STATUS_ACTIVE",0);
- define("HTTPTEST_STATUS_DISABLED",1);
+ 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("BR", "<br/>\n");
define("SPACE", "&nbsp;");
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 82071ad4..9d0f08b5 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -35,7 +35,7 @@
$form->AddVar('sid', get_request('sid', null));
$form->AddVar('list_name', get_request('list_name', null));
- $sid = get_request('name', null);
+ $sid = get_request('sid', null);
$name = get_request('name', '');
$url = get_request('url', '');
$posts = get_request('posts', '');
@@ -95,7 +95,7 @@
$db_steps = DBselect('select * from httpstep where httptestid='.$_REQUEST["httptestid"].' order by no');
while($step_data = DBfetch($db_steps))
{
- $steps[$step_data['httpstepid']] = $step_data;
+ $steps[] = $step_data;
}
}
@@ -112,9 +112,24 @@
$form->AddRow(S_UPDATE_INTERVAL_IN_SEC, new CNumericBox("delay",$delay,5));
- $form->AddRow(S_AGENT, new CTextBox('agent', $agent, 40));
+ $cmbAgent = new CEditableComboBox('agent', $agent, 80);
+ $cmbAgent->AddItem('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)',
+ 'Internet Explorer 6.0 on Windows XP SP2 with .NET Framework 2.0 installed');
+ $cmbAgent->AddItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7',
+ 'Mozilla Firefox 1.5.0.7 on Windows XP');
+ $cmbAgent->AddItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7',
+ 'Mozilla Firefox 1.5.0.7 on Linux');
+ $cmbAgent->AddItem('Opera/9.02 (Windows NT 5.1; U; en)',
+ 'Opera 9.02 on Windows XP');
+ $cmbAgent->AddItem('Opera/9.02 (X11; Linux i686; U; en)',
+ 'Opera 9.02 on Linux');
+ $cmbAgent->AddItem('Lynx/2.8.4rel.1 libwww-FM/2.14',
+ 'Lynx 2.8.4rel.1 on Linux');
+ $cmbAgent->AddItem('Googlebot/2.1 (+http://www.google.com/bot.html)',
+ 'Googlebot');
+ $form->AddRow(S_AGENT, $cmbAgent);
- $cmbStatus = new CComboBox("status",$status);
+ $cmbStatus = new CComboBox("status", $status);
foreach(array(HTTPTEST_STATUS_ACTIVE, HTTPTEST_STATUS_DISABLED) as $st)
$cmbStatus->AddItem($st, httptest_status2str($st));
$form->AddRow(S_STATUS,$cmbStatus);
@@ -926,7 +941,7 @@
" from items i,hosts h where i.itemid=".$_REQUEST["itemid"].
" and h.hostid=i.hostid"));
- $limited = $item_data['templateid'] == 0 ? null : 'yes';
+ $limited = ($item_data['templateid'] == 0 && $item_data['type'] != ITEM_TYPE_HTTPTEST) ? null : 'yes';
}
if((isset($_REQUEST["itemid"]) && !isset($_REQUEST["form_refresh"])) || isset($limited))
@@ -980,7 +995,7 @@
$delay_flex_el = array();
- if($type != ITEM_TYPE_TRAPPER)
+ if($type != ITEM_TYPE_TRAPPER && $type != ITEM_TYPE_HTTPTEST)
{
$i = 0;
foreach($delay_flex as $val)
@@ -1161,7 +1176,7 @@
{
$frmItem->AddVar("formula",$formula);
}
- if($type != ITEM_TYPE_TRAPPER)
+ if($type != ITEM_TYPE_TRAPPER && $type != ITEM_TYPE_HTTPTEST)
{
$frmItem->AddRow(S_UPDATE_INTERVAL_IN_SEC, new CNumericBox("delay",$delay,5));
$frmItem->AddRow("Flexible intervals (sec)", $delay_flex_el);
@@ -1218,7 +1233,7 @@
if(($value_type==ITEM_VALUE_TYPE_UINT64) || ($value_type == ITEM_VALUE_TYPE_STR))
{
- if(isset($limited))
+ if(isset($limited) && $type != ITEM_TYPE_HTTPTEST)
{
$frmItem->AddVar("valuemapid", $valuemapid);
$map_name = S_AS_IS;
@@ -1256,15 +1271,25 @@
$frmItem->AddVar("trapper_hosts",$trapper_hosts);
}
- $cmbApps = new CListBox("applications[]",$applications,6);
- $cmbApps->AddItem(0,"-".S_NONE."-");
- $db_applications = DBselect("select distinct applicationid,name from applications".
- " where hostid=".$_REQUEST["hostid"]." order by name");
- while($db_app = DBfetch($db_applications))
- {
- $cmbApps->AddItem($db_app["applicationid"],$db_app["name"]);
- }
- $frmItem->AddRow(S_APPLICATIONS,$cmbApps);
+ if($type==ITEM_TYPE_HTTPTEST)
+ {
+ $app_names = get_applications_by_itemid($_REQUEST["itemid"], 'name');
+ $frmItem->AddRow(S_APPLICATIONS, new CTextBox("application_name",
+ isset($app_names[0]) ? $app_names[0] : '', 20, $limited));
+ $frmItem->AddVar("applications",$applications,6);
+ }
+ else
+ {
+ $cmbApps = new CListBox("applications[]",$applications,6);
+ $cmbApps->AddItem(0,"-".S_NONE."-");
+ $db_applications = DBselect("select distinct applicationid,name from applications".
+ " where hostid=".$_REQUEST["hostid"]." order by name");
+ while($db_app = DBfetch($db_applications))
+ {
+ $cmbApps->AddItem($db_app["applicationid"],$db_app["name"]);
+ }
+ $frmItem->AddRow(S_APPLICATIONS,$cmbApps);
+ }
$frmRow = array(new CButton("save",S_SAVE));
if(isset($_REQUEST["itemid"]) && !isset($limited))
diff --git a/frontends/php/include/httptest.inc.php b/frontends/php/include/httptest.inc.php
index aeb4dd30..575bb957 100644
--- a/frontends/php/include/httptest.inc.php
+++ b/frontends/php/include/httptest.inc.php
@@ -47,7 +47,7 @@
function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required)
{
- $hystory = 30; // TODO !!! Allow user set this parametr
+ $history = 30; // TODO !!! Allow user set this parametr
$trends = 90; // TODO !!! Allow user set this parametr
if (!eregi('^([0-9a-zA-Z\_\.-\$ ]+)$', $name))
@@ -80,39 +80,45 @@
$monitored_items = array(
array(
- 'description' => 'Download speed for step \'$2\' of scenario \'$1\'',
- 'key_' => 'web.test.in['.$testname.','.$name.',bps]',
- 'type' => ITEM_VALUE_TYPE_UINT64,
- 'units' => 'bps'),
+ 'description' => 'Download speed for step \'$2\' of scenario \'$1\'',
+ 'key_' => 'web.test.in['.$testname.','.$name.',bps]',
+ 'type' => ITEM_VALUE_TYPE_UINT64,
+ 'units' => 'bps',
+ 'httpstepitemtype'=> HTTPSTEP_ITEM_TYPE_IN),
array(
- 'description' => 'Response time for step \'$2\' of scenario \'$1\'',
- 'key_' => 'web.test.time['.$testname.','.$name.',resp]',
- 'type' => ITEM_VALUE_TYPE_UINT64,
- 'units' => 's'),
+ 'description' => 'Response time for step \'$2\' of scenario \'$1\'',
+ 'key_' => 'web.test.time['.$testname.','.$name.',resp]',
+ 'type' => ITEM_VALUE_TYPE_UINT64,
+ 'units' => 's',
+ 'httpstepitemtype'=> HTTPSTEP_ITEM_TYPE_TIME),
array(
- 'description' => 'Response code for step \'$2\' of scenario \'$1\'',
- 'key_' => 'web.test.rspcode['.$testname.','.$name.']',
- 'type' => ITEM_VALUE_TYPE_UINT64,
- 'units' => ''),
+ 'description' => 'Response code for step \'$2\' of scenario \'$1\'',
+ 'key_' => 'web.test.rspcode['.$testname.','.$name.']',
+ 'type' => ITEM_VALUE_TYPE_UINT64,
+ 'units' => '',
+ 'httpstepitemtype'=> HTTPSTEP_ITEM_TYPE_RSPCODE),
);
foreach($monitored_items as $item)
{
- if(!($item_data = DBfetch(DBselect('select itemid from items '.
- ' where hostid='.$hostid.' and key_='.zbx_dbstr($item['key_'])))))
+ if(!($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']))))
{
- if (!($itemid = add_item($item['description'], $item['key_'], $hostid, 30, $hystory, ITEM_STATUS_ACTIVE,
- ITEM_TYPE_HTTPTEST, '', '', $item['type'], 'localhost', 161, $item['units'], 0, 0, '', 0, '', '',
- '', $trends, '', 0, '', array($applicationid))))
+ if (!($itemid = add_item($item['description'], $item['key_'], $hostid, 30,
+ $history, ITEM_STATUS_ACTIVE, ITEM_TYPE_HTTPTEST, '', '', $item['type'], 'localhost',
+ 161, $item['units'], 0, 0, '', 0, '', '', '0', $trends, '', 0, '', array($applicationid))))
return false;
}
else
{
$itemid = $item_data['itemid'];
- if (!(update_item($itemid, $item['description'], $item['key_'], $hostid, 30, $hystory, ITEM_STATUS_ACTIVE,
- ITEM_TYPE_HTTPTEST, '', '', $item['type'], 'localhost', 161, $item['units'], 0, 0, '', 0, '', '',
- '', $trends, '', 0, '', array($applicationid))))
+ if (!(update_item($itemid, $item['description'], $item['key_'], $hostid, 30, $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))))
return false;
}
@@ -122,8 +128,8 @@
DBexecute('delete from httpstepitem where itemid='.$itemid);
if (!DBexecute('insert into httpstepitem'.
- ' (httpstepitemid, httpstepid, itemid) '.
- ' values ('.$httpstepitemid.','.$httpstepid.','.$itemid.')'
+ ' (httpstepitemid, httpstepid, itemid, type) '.
+ ' values ('.$httpstepitemid.','.$httpstepid.','.$itemid.','.$item['httpstepitemtype'].')'
)) return false;
}
@@ -209,8 +215,7 @@
while($step_data = DBfetch($db_steps))
{
if(isset($httpstepids[$step_data['httpstepid']])) continue;
- delete_step($step_data['httpstepid']);
- DBexecute('delete httpstep where httpstepid='.$step_data['httpstepid']);
+ delete_httpstep($step_data['httpstepid']);
}
}
}
@@ -249,7 +254,7 @@
while($httpstepitem_data = DBfetch($db_httpstepitems))
{
if(!DBexecute('delete from httpstepitem where httpstepitemid='.$httpstepitem_data['httpstepitemid'])) return false;
- if(!DBexecute('delete from items where itemid='.$httpstepitem_data['itemid'])) return false;
+ if(!delete_item($httpstepitem_data['itemid'])) return false;
}
return DBexecute('delete from httpstep where httpstepid='.$httpstepid);
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index 2a830b09..4f880ed1 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -23,15 +23,16 @@
{
switch($type)
{
- case 0: $type = S_ZABBIX_AGENT; break;
- case 1: $type = S_SNMPV1_AGENT; break;
- case 2: $type = S_ZABBIX_TRAPPER; break;
- case 3: $type = S_SIMPLE_CHECK; break;
- case 4: $type = S_SNMPV2_AGENT; break;
- case 5: $type = S_ZABBIX_INTERNAL; break;
- case 6: $type = S_SNMPV3_AGENT; break;
- case 7: $type = S_ZABBIX_AGENT_ACTIVE; break;
- case 8: $type = S_ZABBIX_AGGREGATE; break;
+ case ITEM_TYPE_ZABBIX: $type = S_ZABBIX_AGENT; break;
+ case ITEM_TYPE_SNMPV1: $type = S_SNMPV1_AGENT; break;
+ case ITEM_TYPE_TRAPPER: $type = S_ZABBIX_TRAPPER; break;
+ case ITEM_TYPE_SIMPLE: $type = S_SIMPLE_CHECK; break;
+ case ITEM_TYPE_SNMPV2C: $type = S_SNMPV2_AGENT; break;
+ case ITEM_TYPE_INTERNAL: $type = S_ZABBIX_INTERNAL; break;
+ case ITEM_TYPE_SNMPV3: $type = S_SNMPV3_AGENT; break;
+ case ITEM_TYPE_ZABBIX_ACTIVE: $type = S_ZABBIX_AGENT_ACTIVE; break;
+ case ITEM_TYPE_AGGREGATE: $type = S_ZABBIX_AGGREGATE; break;
+ case ITEM_TYPE_HTTPTEST: $type = S_WEB_MONITORING; break;
default:$type = S_UNKNOWN; break;
}
return $type;
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 1a0b644d..f9343af2 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -597,6 +597,7 @@
"S_SNMPV3_AGENT"=> "SNMPv3 agent",
"S_ZABBIX_INTERNAL"=> "ZABBIX internal",
"S_ZABBIX_AGGREGATE"=> "ZABBIX aggregate",
+ "S_WEB_MONITORING"=> "Web monitoring",
"S_ZABBIX_UNKNOWN"=> "Unknown",
"S_ACTIVE"=> "Active",
"S_NOT_ACTIVE"=> "Not active",