summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-19 15:34:39 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-19 15:34:39 +0000
commit938eeba4af4a46126fc4d2fcbe46c15c98d70090 (patch)
treedaf653ad9c11f00b291719b19c19adcb72ca20f1 /frontends/php/include
parenta901997b009039670ecc3144465ecea54d16af4a (diff)
- developed configuration interface of http monitoring (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3732 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/audit.inc.php1
-rw-r--r--frontends/php/include/classes/ctag.inc.php2
-rw-r--r--frontends/php/include/classes/cvar.inc.php4
-rw-r--r--frontends/php/include/config.inc.php7
-rw-r--r--frontends/php/include/defines.inc.php5
-rw-r--r--frontends/php/include/forms.inc.php183
-rw-r--r--frontends/php/include/html.inc.php2
-rw-r--r--frontends/php/include/httptest.inc.php300
-rw-r--r--frontends/php/include/items.inc.php14
-rw-r--r--frontends/php/include/locales/en_gb.inc.php41
-rw-r--r--frontends/php/include/page_header.php3
-rw-r--r--frontends/php/include/validate.inc.php6
12 files changed, 547 insertions, 21 deletions
diff --git a/frontends/php/include/audit.inc.php b/frontends/php/include/audit.inc.php
index 3c3f736e..1ca8d876 100644
--- a/frontends/php/include/audit.inc.php
+++ b/frontends/php/include/audit.inc.php
@@ -39,6 +39,7 @@
$str_resource[AUDIT_RESOURCE_MAP] = S_MAP;
$str_resource[AUDIT_RESOURCE_SCREEN] = S_SCREEN;
$str_resource[AUDIT_RESOURCE_NODE] = S_NODE;
+ $str_resource[AUDIT_RESOURCE_SCENARIO] = S_SCENARIO;
if(isset($str_resource[$resource_type]))
return $str_resource[$resource_type];
diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php
index 587bd1c9..2b462617 100644
--- a/frontends/php/include/classes/ctag.inc.php
+++ b/frontends/php/include/classes/ctag.inc.php
@@ -216,6 +216,8 @@
function SetHint($text, $width='', $class='')
{
+ insert_showhint_javascript();
+
$text = addslashes(htmlspecialchars($text));
if($width != '' || $class!= '')
{
diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php
index 7b7c3a11..8703a559 100644
--- a/frontends/php/include/classes/cvar.inc.php
+++ b/frontends/php/include/classes/cvar.inc.php
@@ -27,11 +27,11 @@
parent::CTag('input','no');
$this->options['type'] = 'hidden';
$this->options['name'] = $name;
- $this->options['value'] = $value;
+ $this->SetValue($value);
}
function SetValue($value)
{
- $this->options['value'] = $value;
+ $this->options['value'] = htmlspecialchars($value);
}
}
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 018dc860..8f898817 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -1335,14 +1335,11 @@ else
}
}
-$SHOW_HINT_SCRIPT_ISERTTED = false; /* TODO rewrite with JS include */
-
function insert_showhint_javascript()
{
- global $SHOW_HINT_SCRIPT_ISERTTED;
+ if(defined('SHOW_HINT_SCRIPT_INSERTTED')) return;
- if($SHOW_HINT_SCRIPT_ISERTTED) return;
- $SHOW_HINT_SCRIPT_ISERTTED = true;
+ define('SHOW_HINT_SCRIPT_INSERTTED', 1);
?>
<script language="JavaScript" type="text/javascript">
<!--
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index f81680b9..2e5af920 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -93,6 +93,7 @@
define("AUDIT_RESOURCE_MAP", 19);
define("AUDIT_RESOURCE_SCREEN", 20);
define("AUDIT_RESOURCE_NODE", 21);
+ define("AUDIT_RESOURCE_SCENARIO", 22);
define("CONDITION_TYPE_GROUP", 0);
define("CONDITION_TYPE_HOST", 1);
@@ -145,6 +146,7 @@
define("ITEM_TYPE_SNMPV3",6);
define("ITEM_TYPE_ZABBIX_ACTIVE",7);
define("ITEM_TYPE_AGGREGATE",8);
+ define("ITEM_TYPE_HTTPTEST",9);
define("ITEM_VALUE_TYPE_FLOAT",0);
define("ITEM_VALUE_TYPE_STR",1);
@@ -292,6 +294,9 @@
define("ZBX_NODE_LOCAL", 1);
define("ZBX_NODE_MASTER", 2);
+ define("HTTPTEST_STATUS_ACTIVE",0);
+ define("HTTPTEST_STATUS_DISABLED",1);
+
define("BR", "<br/>\n");
define("SPACE", "&nbsp;");
define("RARR", "&rArr;");
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 9a18ba19..82071ad4 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -26,6 +26,180 @@
require_once "include/users.inc.php";
require_once "include/db.inc.php";
+ function insert_httpstep_form()
+ {
+ $form = new CFormTable(S_STEP_OF_SCENARIO, null, 'post');
+ $form->SetHelp("web.webmon.httpconf.php");
+
+ $form->AddVar('dstfrm', get_request('dstfrm', null));
+ $form->AddVar('sid', get_request('sid', null));
+ $form->AddVar('list_name', get_request('list_name', null));
+
+ $sid = get_request('name', null);
+ $name = get_request('name', '');
+ $url = get_request('url', '');
+ $posts = get_request('posts', '');
+ $timeout = get_request('timeout', 15);
+ $required = get_request('required', '');
+
+ $form->AddRow(S_NAME, new CTextBox('name', $name, 50));
+ $form->AddRow(S_URL, new CTextBox('url', $url, 80));
+ $form->AddRow(S_POST, new CTextArea('posts', $posts, 50, 10));
+ $form->AddRow(S_TIMEOUT, new CNumericBox('timeout', $timeout, 5));
+ $form->AddRow(S_REQUIRED, new CTextBox('required', $required, 80));
+
+ $form->AddItemToBottomRow(new CButton("save", isset($sid) ? S_SAVE : S_ADD));
+
+ $form->AddItemToBottomRow(new CButton('cancel',S_CANCEL,'window.close();'));
+
+ $form->show();
+ }
+
+ function insert_httptest_form()
+ {
+ $form = new CFormTable(S_SCENARIO, null, 'post');
+ $form->SetHelp("web.webmon.httpconf.php");
+
+ if(isset($_request["groupid"]))
+ $form->addvar("groupid",$_request["groupid"]);
+
+ $form->AddVar("hostid",$_REQUEST["hostid"]);
+
+ if(isset($_REQUEST["httptestid"]))
+ {
+ $form->AddVar("httptestid",$_REQUEST["httptestid"]);
+ }
+
+ $name = get_request('name', '');
+ $application = get_request('application', '');
+ $delay = get_request('delay', 60);
+ $status = get_request('status', HTTPTEST_STATUS_ACTIVE);
+ $agent = get_request('agent', '');
+ $macros = get_request('macros', array());
+ $steps = get_request('steps', array());
+
+ if((isset($_REQUEST["httptestid"]) && !isset($_REQUEST["form_refresh"])) || isset($limited))
+ {
+ $httptest_data = DBfetch(DBselect("select wt.*, a.name as application ".
+ " from httptest wt,applications a where wt.httptestid=".$_REQUEST["httptestid"].
+ " and a.applicationid=wt.applicationid"));
+
+ $name = $httptest_data['name'];
+ $application = $httptest_data['application'];
+ $delay = $httptest_data['delay'];
+ $status = $httptest_data['status'];
+ $agent = $httptest_data['agent'];
+ $macros = $httptest_data['macros'];
+
+ $steps = array();
+ $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;
+ }
+ }
+
+ $form->AddRow(S_APPLICATION,array(
+ new CTextBox('application', $application, 40),
+ SPACE,
+ new CButton('select_app',S_SELECT,
+ 'return PopUp("popup.php?dstfrm='.$form->GetName().
+ '&dstfld1=application&srctbl=applications'.
+ '&srcfld1=name&only_hostid='.$_REQUEST['hostid'].'",200,300,"application");')
+ ));
+
+ $form->AddRow(S_NAME, new CTextBox('name', $name, 40));
+
+ $form->AddRow(S_UPDATE_INTERVAL_IN_SEC, new CNumericBox("delay",$delay,5));
+
+ $form->AddRow(S_AGENT, new CTextBox('agent', $agent, 40));
+
+ $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);
+
+ $form->AddRow(S_VARIABLES, new CTextArea('macros', $macros, 40, 5));
+
+ $tblSteps = new CTableInfo();
+ $tblSteps->SetHeader(array(S_NAME,S_TIMEOUT,S_URL,S_REQUIRED,SPACE));
+ if(count($steps) > 0)
+ {
+ $first = min(array_keys($steps));
+ $last = max(array_keys($steps));
+ }
+ foreach($steps as $sid => $s)
+ {
+ if(!isset($s['name'])) $s['name'] = '';
+ if(!isset($s['timeout'])) $s['timeout'] = 15;
+ if(!isset($s['url'])) $s['url'] = '';
+ if(!isset($s['posts'])) $s['posts'] = '';
+ if(!isset($s['required'])) $s['required'] = '';
+
+ $up = null;
+ if($sid != $first)
+ {
+ $up = new CLink(S_UP,'#','action');
+ $up->OnClick("return create_var('".$form->GetName()."','move_up',".$sid.", true);");
+ }
+
+ $down = null;
+ if($sid != $last)
+ {
+ $down = new CLink(S_DOWN,'#','action');
+ $down->OnClick("return create_var('".$form->GetName()."','move_down',".$sid.", true);");
+ }
+
+ $name = new CLink($s['name'],'#','action');
+ $name->OnClick('return PopUp("popup_httpstep.php?dstfrm='.$form->GetName().
+ '&list_name=steps&sid='.$sid.
+ url_param($s['name'],false,'name').
+ url_param($s['timeout'],false,'timeout').
+ url_param($s['url'],false,'url').
+ url_param($s['posts'],false,'posts').
+ url_param($s['required'],false,'required').
+ '");');
+
+ if(strlen($s['url']) > 70)
+ {
+ $url = new CTag('span','yes', substr($s['url'],0,35).SPACE.'...'.SPACE.substr($s['url'],strlen($s['url'])-25,25));
+ $url->SetHint($s['url']);
+ }
+ else
+ {
+ $url = $s['url'];
+ }
+
+ $tblSteps->AddRow(array(
+ array(new CCheckBox('sel_step[]',null,null,$sid), $name),
+ $s['timeout'].SPACE.S_SEC_SMALL,
+ $url,
+ $s['required'],
+ array($up, isset($up) && isset($down) ? SPACE : null, $down)
+ ));
+ }
+ $form->AddVar('steps', $steps);
+
+ $form->AddRow(S_STEPS, array(
+ (count($steps) > 0) ? array ($tblSteps, BR) : null ,
+ new CButton('add_step',S_ADD,
+ 'return PopUp("popup_httpstep.php?dstfrm='.$form->GetName().'");'),
+ (count($steps) > 0) ? new CButton('del_sel_step',S_DELETE_SELECTED) : null
+ ));
+
+ $form->AddItemToBottomRow(new CButton("save",S_SAVE));
+ if(isset($_REQUEST["httptestid"]))
+ {
+ $form->AddItemToBottomRow(SPACE);
+ $form->AddItemToBottomRow(new CButtonDelete(S_DELETE_SCENARIO_Q,
+ url_param("form").url_param("httptestid").url_param('hostid')));
+ }
+ $form->AddItemToBottomRow(SPACE);
+ $form->AddItemToBottomRow(new CButtonCancel());
+
+ $form->Show();
+ }
+
function insert_configuration_form($file)
{
$type = get_request('type', 'MYSQL');
@@ -702,8 +876,8 @@
$frmItem->SetHelp("web.items.item.php");
$frmItem->AddVar("config",get_request("config",0));
- if(isset($_REQUEST["groupid"]))
- $frmItem->AddVar("groupid",$_REQUEST["groupid"]);
+ if(isset($_request["groupid"]))
+ $frmitem->addvar("groupid",$_request["groupid"]);
$frmItem->AddVar("hostid",$_REQUEST["hostid"]);
@@ -1016,9 +1190,8 @@
$frmItem->AddRow(S_KEEP_TRENDS_IN_DAYS, new CNumericBox("trends",$trends,8));
$cmbStatus = new CComboBox("status",$status);
- $cmbStatus->AddItem(ITEM_STATUS_ACTIVE,S_MONITORED);
- $cmbStatus->AddItem(ITEM_STATUS_DISABLED,S_DISABLED);
- $cmbStatus->AddItem(ITEM_STATUS_NOTSUPPORTED,S_NOT_SUPPORTED);
+ foreach(array(ITEM_STATUS_ACTIVE,ITEM_STATUS_DISABLED,ITEM_STATUS_NOTSUPPORTED) as $st)
+ $cmbStatus->AddItem($st,item_status2str($st));
$frmItem->AddRow(S_STATUS,$cmbStatus);
if($value_type==ITEM_VALUE_TYPE_LOG)
diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php
index bcebb5a8..bd497c36 100644
--- a/frontends/php/include/html.inc.php
+++ b/frontends/php/include/html.inc.php
@@ -94,7 +94,7 @@
}
else
{
- $result = "&".$varname."=".$var;
+ $result = "&".$varname."=".urlencode($var);
}
return $result;
}
diff --git a/frontends/php/include/httptest.inc.php b/frontends/php/include/httptest.inc.php
new file mode 100644
index 00000000..aeb4dd30
--- /dev/null
+++ b/frontends/php/include/httptest.inc.php
@@ -0,0 +1,300 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+ require_once('include/defines.inc.php');
+ require_once('include/items.inc.php');
+?>
+<?php
+ function httptest_status2str($status)
+ {
+ switch($status)
+ {
+ case HTTPTEST_STATUS_ACTIVE: $status = S_ACTIVE; break;
+ case HTTPTEST_STATUS_DISABLED: $status = S_DISABLED; break;
+ default:
+ $status = S_UNKNOWN; break;
+ }
+ return $status;
+ }
+
+ function httptest_status2style($status)
+ {
+ switch($status)
+ {
+ case HTTPTEST_STATUS_ACTIVE: $status = 'off'; break;
+ case HTTPTEST_STATUS_DISABLED: $status = 'on'; break;
+ default:
+ $status = 'uncnown'; break;
+ }
+ return $status;
+ }
+
+ function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required)
+ {
+ $hystory = 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");
+ return false;
+ }
+
+ if(!($httpstep_data = DBfetch(DBselect('select httpstepid from httpstep '.
+ ' where httptestid='.$httptestid.' and name='.zbx_dbstr($name)))))
+ {
+ $httpstepid = get_dbid("httpstep","httpstepid");
+
+ if (!DBexecute('insert into httpstep'.
+ ' (httpstepid, httptestid, name, no, url, timeout, posts, required) '.
+ ' values ('.$httpstepid.','.$httptestid.','.zbx_dbstr($name).','.$no.','.
+ zbx_dbstr($url).','.$timeout.','.
+ zbx_dbstr($posts).','.zbx_dbstr($required).')'
+ )) return false;
+ }
+ else
+ {
+ $httpstepid = $httpstep_data['httpstepid'];
+
+ if (!DBexecute('update httpstep set '.
+ ' name='.zbx_dbstr($name).', no='.$no.', url='.zbx_dbstr($url).', timeout='.$timeout.','.
+ ' posts='.zbx_dbstr($posts).', required='.zbx_dbstr($required).
+ ' where httpstepid='.$httpstepid)) return false;
+ }
+
+ $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'),
+ array(
+ 'description' => 'Response time for step \'$2\' of scenario \'$1\'',
+ 'key_' => 'web.test.time['.$testname.','.$name.',resp]',
+ 'type' => ITEM_VALUE_TYPE_UINT64,
+ 'units' => 's'),
+ array(
+ 'description' => 'Response code for step \'$2\' of scenario \'$1\'',
+ 'key_' => 'web.test.rspcode['.$testname.','.$name.']',
+ 'type' => ITEM_VALUE_TYPE_UINT64,
+ 'units' => ''),
+ );
+
+ foreach($monitored_items as $item)
+ {
+ if(!($item_data = DBfetch(DBselect('select itemid from items '.
+ ' where hostid='.$hostid.' and key_='.zbx_dbstr($item['key_'])))))
+ {
+ 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))))
+ 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))))
+ return false;
+ }
+
+
+ $httpstepitemid = get_dbid('httpstepitem', 'httpstepitemid');
+
+ DBexecute('delete from httpstepitem where itemid='.$itemid);
+
+ if (!DBexecute('insert into httpstepitem'.
+ ' (httpstepitemid, httpstepid, itemid) '.
+ ' values ('.$httpstepitemid.','.$httpstepid.','.$itemid.')'
+ )) return false;
+
+ }
+
+ return $httpstepid;
+ }
+
+ function db_save_httptest($httptestid, $hostid, $application, $name, $delay, $status, $agent, $macros, $steps)
+ {
+ if (!eregi('^([0-9a-zA-Z\_\.-\$ ]+)$', $name))
+ {
+ error("Scenario name should contain '0-9a-zA-Z_.$ '- characters only");
+ return false;
+ }
+
+ DBstart();
+
+ if($applicationid = DBfetch(DBselect('select applicationid from applications '.
+ ' where name='.zbx_dbstr($application).
+ ' and hostid='.$hostid)))
+ {
+ $applicationid = $applicationid['applicationid'];
+ }
+ else
+ {
+ $applicationid = add_application($application, $hostid);
+ if(!$applicationid)
+ {
+ error('Can\'t add new application. ['.$application.']');
+ return false;
+ }
+ }
+
+ if(isset($httptestid))
+ {
+ $result = DBexecute('update httptest set '.
+ ' applicationid='.$applicationid.', name='.zbx_dbstr($name).', delay='.$delay.','.
+ ' status='.$status.', agent='.zbx_dbstr($agent).', macros='.zbx_dbstr($macros).
+ ' where httptestid='.$httptestid);
+ }
+ else
+ {
+ $httptestid = get_dbid("httptest","httptestid");
+
+ if(DBfetch(DBselect('select t.httptestid from httptest t, applications a where t.applicationid=a.applicationid '.
+ ' and a.hostid='.$hostid.' and t.name='.zbx_dbstr($name))))
+ {
+ error('Scenario with name ['.$name.'] already exist');
+ return false;
+ }
+
+ $result = DBexecute('insert into httptest'.
+ ' (httptestid, applicationid, name, delay, status, agent, macros) '.
+ ' values ('.$httptestid.','.$applicationid.','.zbx_dbstr($name).','.
+ $delay.','.$status.','.zbx_dbstr($agent).','.zbx_dbstr($macros).')'
+ );
+
+ $test_added = true;
+ }
+
+ if($result)
+ {
+ $httpstepids = array();
+ foreach($steps as $sid => $s)
+ {
+ if(!isset($s['name'])) $s['name'] = '';
+ if(!isset($s['timeout'])) $s['timeout'] = 15;
+ if(!isset($s['url'])) $s['url'] = '';
+ if(!isset($s['posts'])) $s['posts'] = '';
+ 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']);
+
+ if(!$result) break;
+
+ $httpstepids[$result] = $result;
+ }
+ if($result)
+ {
+ /* clean unneeded steps */
+ $db_steps = DBselect('select httpstepid from httpstep where httptestid='.$httptestid);
+ 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']);
+ }
+ }
+ }
+
+ // TODO !!! Create items for httptest
+
+ if(!$result && isset($test_added)) delete_httptest($httptestid);
+ else $restult = $httptestid;
+
+ DBend($result);
+
+ return $result;
+ }
+
+ function add_httptest($hostid, $application, $name, $delay, $status, $agent, $macros, $steps)
+ {
+ $result = db_save_httptest(null, $hostid, $application, $name, $delay, $status, $agent, $macros, $steps);
+
+ if($result) info("Sceanrio '".$name."' added");
+
+ return $result;
+ }
+
+ function update_httptest($httptestid, $hostid, $application, $name, $delay, $status, $agent, $macros, $steps)
+ {
+ $result = db_save_httptest($httptestid, $hostid, $application, $name, $delay, $status, $agent, $macros, $steps);
+
+ if($result) info("Sceanrio '".$name."' updated");
+
+ return $result;
+ }
+
+ function delete_httpstep($httpstepid)
+ {
+ $db_httpstepitems = DBselect('select distinct * from httpstepitem where httpstepid='.$httpstepid);
+ 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;
+ }
+
+ return DBexecute('delete from httpstep where httpstepid='.$httpstepid);
+ }
+
+ function delete_httptest($httptestid)
+ {
+ if (!($httptest = DBfetch(DBselect('select * from httptest where httptestid='.$httptestid)))) return false;
+
+ $db_httpstep = DBselect('select distinct s.httpstepid from httpstep s '.
+ ' where s.httptestid='.$httptestid);
+ while($httpstep_data = DBfetch($db_httpstep))
+ {
+ delete_httpstep($httpstep_data['httpstepid']);
+ }
+
+ if(!DBexecute('delete from httptest where httptestid='.$httptestid)) return false;
+
+ info("Sceanrio '".$httptest["name"]."' deleted");
+
+ return true;
+ }
+
+ function activate_httptest($httptestid)
+ {
+ return DBexecute('update httptest set status='.HTTPTEST_STATUS_ACTIVE.' where httptestid='.$httptestid);
+ }
+
+ function disable_httptest($httptestid)
+ {
+ return DBexecute('update httptest set status='.HTTPTEST_STATUS_DISABLED.' where httptestid='.$httptestid);
+ }
+
+ function delete_history_by_httptestid($httptestid)
+ {
+ $db_items = DBselect('select distinct i.itemid from items i, httpstepitem si, httpstep s '.
+ ' where s.httptestid='.$httptestid.' and si.httpstepid=s.httpstepid and i.itemid=si.itemid');
+ while($item_data = DBfetch($db_items))
+ {
+ if(!delete_history_by_itemid($item_data['itemid'], 0 /* use housekeeper */)) return false;
+ }
+ return true;
+ }
+ function get_httptest_by_httptestid($httptestid)
+ {
+ return DBfetch(DBselect('select * from httptest where httptestid='.$httptestid));
+ }
+?>
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index 35989989..2a830b09 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -55,9 +55,9 @@
{
switch($status)
{
- case 0: $status = S_ACTIVE; break;
- case 1: $status = S_DISABLED; break;
- case 3:
+ case ITEM_STATUS_ACTIVE: $status = S_ACTIVE; break;
+ case ITEM_STATUS_DISABLED: $status = S_DISABLED; break;
+ case ITEM_STATUS_NOTSUPPORTED: $status = S_NOT_SUPPORTED; break;
default:
$status = S_UNKNOWN; break;
}
@@ -68,9 +68,9 @@
{
switch($status)
{
- case 0: $status = 'off'; break;
- case 1: $status = 'on'; break;
- case 3:
+ case ITEM_STATUS_ACTIVE: $status = 'off'; break;
+ case ITEM_STATUS_DISABLED: $status = 'on'; break;
+ case ITEM_STATUS_NOTSUPPORTED:
default:
$status = 'uncnown'; break;
}
@@ -200,7 +200,7 @@
" where hostid=$hostid and key_=".zbx_dbstr($key)));
if($db_item && $templateid == 0)
{
- error("An item with the same Key already exists for host ".$host["host"].".".
+ error("An item with the Key [".$key."] already exists for host [".$host["host"]."].".
" The key must be unique.");
return FALSE;
} elseif ($db_item && $templateid != 0){
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 7bffb267..1a0b644d 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -27,6 +27,43 @@
"S_DATE_FORMAT_YMD"=> "d M Y",
"S_HTML_CHARSET"=> "iso-8859-1",
+ "S_ACTIVATE_SELECTED"=> "Activate selected",
+ "S_DISABLE_SELECTED"=> "Disable selected",
+ "S_DELETE_SELECTED"=> "Delete selected",
+ "S_COPY_SELECTED_TO"=> "Copy selected to ...",
+
+// httpconf.php
+ "S_WEB"=> "Web",
+ "S_CONFIGURATION_OF_WEB_MONITORING"=> "Configuration of Web monitoring",
+ "S_CONFIGURATION_OF_WEB_MONITORING_BIG"=>"CONFIGURATION OF WEB MONITORING",
+ "S_SCENARIO"=> "Scenario",
+ "S_SCENARIOS_BIG"=> "SCENARIOS",
+ "S_CREATE_SCENARIO"=> "Create scenario",
+ "S_HIDE_DISABLED_SCENARIOS"=> "Hide disabled scenarios",
+ "S_SHOW_DISABLED_SCENARIOS"=> "Show disabled scenarios",
+ "S_NUMBER_OF_STEPS"=> "Number of steps",
+ "S_SCENARIO_DELETED"=> "Scenario deleted",
+ "S_SCENARIO_ACTIVATED"=> "Scenario activated",
+ "S_SCENARIO_DISABLED"=> "Scenario disabled",
+ "S_ACTIVATE_SELECTED_SCENARIOS_Q"=> "Activate selected scenarios?",
+ "S_DISABLE_SELECTED_SCENARIOS_Q"=> "Disable selected scenarios?",
+ "S_DELETE_SELECTED_SCENARIOS_Q"=> "Delete selected scenarios?",
+ "S_DELETE_SCENARIO_Q"=> "Delete scenario?",
+ "S_CLEAN_HISTORY_SELECTED_SCENARIOS"=> "Clean history selected scenarios",
+ "S_SCENARIO_UPDATED"=> "Scenario updated",
+ "S_CANNOT_UPDATE_SCENARIO"=> "Cannot update scenario",
+ "S_SCENARIO_ADDED"=> "Scenario added",
+ "S_CANNOT_ADD_SCENARIO"=> "Cannot add scenario",
+ "S_SCENARIO_DELETED"=> "Scenario deleted",
+ "S_CANNOT_DELETE_SCENARIO"=> "Cannot delete scenario",
+ "S_AGENT"=> "Agent",
+ "S_VARIABLES"=> "Variables",
+ "S_STEPS"=> "Steps",
+ "S_TIMEOUT"=> "Timeout",
+ "S_POST"=> "Post",
+ "S_REQUIRED"=> "Required",
+ "S_STEP_OF_SCENARIO"=> "Step of scenario",
+
// exp_imp.php
"S_ELEMENT"=> "Element",
"S_ELEMENTS"=> "Elements",
@@ -426,6 +463,7 @@
"S_CANNOT_ADD_APPLICATION"=> "Cannot add application",
"S_APPLICATION_DELETED"=> "Application deleted",
"S_CANNOT_DELETE_APPLICATION"=> "Cannot delete application",
+ "S_NO_APPLICATIONS_DEFINED"=> "No applications defined",
"S_HOSTS"=> "Hosts",
"S_ITEMS"=> "Items",
@@ -527,6 +565,7 @@
// items.php
"S_NO_ITEMS_DEFINED"=> "No items defined",
"S_HISTORY_CLEANED"=> "History cleaned",
+ "S_CLEAN_HISTORY_SELECTED_ITEMS"=> "Clean history selected items",
"S_CANNOT_CLEAN_HISTORY"=> "Cannot clean history",
"S_CONFIGURATION_OF_ITEMS"=> "Configuration of items",
"S_CONFIGURATION_OF_ITEMS_BIG"=> "CONFIGURATION OF ITEMS",
@@ -611,6 +650,7 @@
"S_SHOW_ITEMS_WITH_DESCRIPTION_LIKE"=> "Show items with description like",
"S_SHOW_DISABLED_ITEMS"=> "Show disabled items",
"S_HIDE_DISABLED_ITEMS"=> "Hide disabled items",
+ "S_HISTORY_CLEANING_CAN_TAKE_A_LONG_TIME_CONTINUE_Q" => "History cleaning can take a long time. Continue?",
// events.php
"S_LATEST_EVENTS"=> "Latest events",
@@ -964,6 +1004,7 @@
"S_INSERT"=> "Insert",
"S_TIMES"=> "Times",
"S_SECONDS"=> "Seconds",
+ "S_SEC_SMALL"=> "sec",
"S_COUNTS"=> "Counts",
"S_LAST_OF"=> "Last of",
"S_SHOW_DISABLED_TRIGGERS"=> "Show disabled triggers",
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index 5a7a3b75..0704350c 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -159,6 +159,9 @@ COpt::profiling_start("page");
array("url"=>"config.php" ,"label"=>S_GENERAL ,
"sub_pages"=>array("image.php")
),
+ array("url"=>"httpconf.php" ,"label"=>S_WEB ,
+ "sub_pages"=>array("popup_httpstep.php")
+ ),
array("url"=>"hosts.php" ,"label"=>S_HOSTS ),
array("url"=>"items.php" ,"label"=>S_ITEMS ),
array("url"=>"triggers.php" ,"label"=>S_TRIGGERS ,
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php
index 98ea357d..51587261 100644
--- a/frontends/php/include/validate.inc.php
+++ b/frontends/php/include/validate.inc.php
@@ -50,7 +50,11 @@
}
function HEX($var=NULL)
{
- return "ereg(\"^[a-zA-Z0-9]{1,}$\",{".$var."})";
+ return "ereg(\"^[a-zA-Z0-9]{1,}$\",{".$var."})&&";
+ }
+ function KEY_PARAM($var=NULL)
+ {
+ return 'ereg(\'^([0-9a-zA-Z\_\.-\$ ]+)$\',{'.$var.'})&&';
}
define("NOT_EMPTY","({}!='')&&");