summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-02-10 12:53:34 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-02-10 12:53:34 +0000
commitf54860dfdd8d24de1dc26a530d95a23343756dc2 (patch)
tree76234c5a861862aee2170b41cf7a517e82633e93
parent455a64dfe19d7700fa1fe10edecb1ea82fa5dcce (diff)
downloadzabbix-f54860dfdd8d24de1dc26a530d95a23343756dc2.tar.gz
zabbix-f54860dfdd8d24de1dc26a530d95a23343756dc2.tar.xz
zabbix-f54860dfdd8d24de1dc26a530d95a23343756dc2.zip
- improved Templates logic (Eugene)
- speed improvement for proc.num of Tru64 (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2631 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog2
-rw-r--r--frontends/php/actionconf.php2
-rw-r--r--frontends/php/actions.php2
-rw-r--r--frontends/php/charts.php6
-rw-r--r--frontends/php/events.php8
-rw-r--r--frontends/php/history.php6
-rw-r--r--frontends/php/hosts.php403
-rw-r--r--frontends/php/include/config.inc.php204
-rw-r--r--frontends/php/include/db.inc.php9
-rw-r--r--frontends/php/include/forms.inc.php42
-rw-r--r--frontends/php/include/graphs.inc.php24
-rw-r--r--frontends/php/include/hosts.inc.php261
-rw-r--r--frontends/php/include/html.inc.php2
-rw-r--r--frontends/php/include/items.inc.php281
-rw-r--r--frontends/php/include/locales/en_gb.inc.php3
-rw-r--r--frontends/php/include/profiles.inc.php43
-rw-r--r--frontends/php/include/services.inc.php6
-rw-r--r--frontends/php/items.php214
-rw-r--r--frontends/php/latest.php6
-rw-r--r--frontends/php/overview.php25
-rw-r--r--frontends/php/popup.php4
-rw-r--r--frontends/php/queue.php2
-rw-r--r--frontends/php/report2.php6
-rw-r--r--frontends/php/report3.php6
-rw-r--r--frontends/php/services.php6
-rw-r--r--frontends/php/srv_status.php2
-rw-r--r--frontends/php/tr_status.php6
-rw-r--r--frontends/php/triggers.php6
-rw-r--r--src/libs/zbxsysinfo/osf/proc.c14
29 files changed, 736 insertions, 865 deletions
diff --git a/ChangeLog b/ChangeLog
index 880f4260..d7109a02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
Changes for 1.1beta7:
+ - improved Templates logic (Eugene)
+ - speed improvement for proc.num of Tru64 (Eugene)
- fixed evaluation of {IPADDRESS} (Alexei)
- added hosts.templateid and items.templateid (Alexei)
diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php
index 73c0507f..c13dd164 100644
--- a/frontends/php/actionconf.php
+++ b/frontends/php/actionconf.php
@@ -182,7 +182,7 @@
$cmbType->AddItem(1,S_REMOTE_COMMAND,NULL,'no');
$form->AddItem($cmbType);
- $form->AddItem("&nbsp;|&nbsp;");
+ $form->AddItem(SPACE."|".SPACE);
$form->AddItem(new CButton("form",S_CREATE_ACTION));
show_header2(S_ACTIONS, $form);
diff --git a/frontends/php/actions.php b/frontends/php/actions.php
index 5306d950..88b9f62e 100644
--- a/frontends/php/actions.php
+++ b/frontends/php/actions.php
@@ -121,7 +121,7 @@
$message="<pre>".htmlspecialchars($row["message"])."</pre>";
if($row["error"] == "")
{
- $error=new CSpan("&nbsp;","off");
+ $error=new CSpan(SPACE,"off");
}
else
{
diff --git a/frontends/php/charts.php b/frontends/php/charts.php
index a120e388..35e47cae 100644
--- a/frontends/php/charts.php
+++ b/frontends/php/charts.php
@@ -107,7 +107,7 @@
$h1=S_GRAPHS_BIG.nbsp(" / ").$h1;
- $h2=S_GROUP."&nbsp;";
+ $h2=S_GROUP.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
$h2=$h2.form_select("groupid",0,S_ALL_SMALL);
$result=DBselect("select groupid,name from groups order by name");
@@ -131,7 +131,7 @@
}
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_HOST."&nbsp;";
+ $h2=$h2.SPACE.S_HOST.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
$h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
@@ -165,7 +165,7 @@
unset($_REQUEST["graphid"]);
}
- $h2=$h2."&nbsp;".S_GRAPH."&nbsp;";
+ $h2=$h2.SPACE.S_GRAPH.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"graphid\" onChange=\"submit()\">";
$h2=$h2.form_select("graphid",0,S_SELECT_GRAPH_DOT_DOT_DOT);
diff --git a/frontends/php/events.php b/frontends/php/events.php
index 443a0d34..3f816fb3 100644
--- a/frontends/php/events.php
+++ b/frontends/php/events.php
@@ -64,9 +64,9 @@
<?php
- $h1="&nbsp;".S_HISTORY_OF_EVENTS_BIG;
+ $h1=SPACE.S_HISTORY_OF_EVENTS_BIG;
- $h2=S_GROUP."&nbsp;";
+ $h2=S_GROUP.SAPCE;
$h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
$h2=$h2.form_select("groupid",0,S_ALL_SMALL);
$result=DBselect("select groupid,name from groups order by name");
@@ -90,7 +90,7 @@
}
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_HOST."&nbsp;";
+ $h2=$h2.SPACE.S_HOST.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
$h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
@@ -112,7 +112,7 @@
}
$h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
}
- $h2=$h2."</select>&nbsp;";
+ $h2=$h2."</select>".SPACE;
if(isset($_REQUEST["start"]))
{
diff --git a/frontends/php/history.php b/frontends/php/history.php
index 296ed8b2..e9548067 100644
--- a/frontends/php/history.php
+++ b/frontends/php/history.php
@@ -105,7 +105,7 @@
$h1="<A HREF='latest.php?hostid=$hostid'>$host</A> : $description";
-# $h2=S_GROUP."&nbsp;";
+# $h2=S_GROUP.SPACE
$h2="<input class=\"biginput\" name=\"itemid\" type=\"hidden\" value=\"".$_REQUEST["itemid"]."\">";
$h2=$h2."<select class=\"biginput\" name=\"action\" onChange=\"submit()\">";
$h2=$h2.form_select("action","showhistory",S_LAST_HOUR_GRAPH);
@@ -205,7 +205,7 @@
if($local==0)
{
- echo "<TD>&nbsp;</TD>";
+ echo "<TD>".SPACE."</TD>";
}
else
{
@@ -310,7 +310,7 @@
if($local==0)
{
- $local="&nbsp";
+ $local=SPACE;
}
{
$local=date("Y.M.d H:i:s",$local);
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 7e5b64ff..09c5bd4a 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -42,7 +42,7 @@
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "config"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,2"), NULL),
+ "config"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), NULL),
"hosts"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
"groups"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
@@ -50,12 +50,12 @@
"hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '{config}==0&&{form}=="update"'),
"host"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{config}==0&&isset({save})'),
"useip"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
- "ip"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useip})'),
+ "ip"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useip})'),
"port"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'{config}==0&&isset({save})'),
"status"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,3"), '{config}==0&&isset({save})'),
"newgroup"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
- "host_templateid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL),
+ "templateid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL),
"useprofile"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
"devicetype"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'),
@@ -72,18 +72,11 @@
/* group */
"groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '{config}==1&&{form}=="update"'),
"gname"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, '{config}==1&&isset({save})'),
-/* linkages */
- "hosttemplateid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '{config}==3&&{form}=="update"'),
- "templateid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
- "items"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1,2,4"), NULL),
- "triggers"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1,2,4"), NULL),
- "graphs"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1,2,4"), NULL),
/* actions */
"activate"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"disable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
-// "register"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
@@ -106,59 +99,36 @@
if(isset($_REQUEST["hostid"]))
{
- $result=update_host(
- $_REQUEST["hostid"],$_REQUEST["host"],$_REQUEST["port"],$_REQUEST["status"],
- $useip,$_REQUEST["ip"],$_REQUEST["newgroup"],$groups);
+ $result = update_host($_REQUEST["hostid"],
+ $_REQUEST["host"],$_REQUEST["port"],$_REQUEST["status"],$useip,
+ $_REQUEST["ip"],$_REQUEST["templateid"],$_REQUEST["newgroup"],$groups);
$msg_ok = S_HOST_UPDATED;
$msg_fail = S_CANNOT_UPDATE_HOST;
$audit_action = AUDIT_ACTION_UPDATE;
- $hostid=$_REQUEST["hostid"];
+ $hostid = $_REQUEST["hostid"];
} else {
- $result=add_host(
+ $hostid = add_host(
$_REQUEST["host"],$_REQUEST["port"],$_REQUEST["status"],$useip,
- $_REQUEST["ip"],$_REQUEST["host_templateid"],$_REQUEST["newgroup"],$groups);
+ $_REQUEST["ip"],$_REQUEST["templateid"],$_REQUEST["newgroup"],$groups);
$msg_ok = S_HOST_ADDED;
$msg_fail = S_CANNOT_ADD_HOST;
$audit_action = AUDIT_ACTION_ADD;
- $db_hosts=DBexecute("select hostid from hosts where host='".$_REQUEST["host"]."'");
- if(DBnum_rows($db_hosts)==0){
- $result=FALSE;
- $hostid=0;
- } else {
- $db_host = DBfetch($db_hosts);
- $hostid=$db_host["hostid"];
- }
+ $result = $hostid;
}
if($result){
- $useprofile = get_request("useprofile","no");
- $db_profiles = DBselect("select * from hosts_profiles where hostid=".$hostid);
- if($useprofile=="yes"){
- if(DBnum_rows($db_profiles)==0)
- {
- $result=add_host_profile($hostid,
- $_REQUEST["devicetype"],$_REQUEST["name"],$_REQUEST["os"],
- $_REQUEST["serialno"],$_REQUEST["tag"],$_REQUEST["macaddress"],
- $_REQUEST["hardware"],$_REQUEST["software"],$_REQUEST["contact"],
- $_REQUEST["location"],$_REQUEST["notes"]);
-
-// show_messages($result, S_PROFILE_ADDED, S_CANNOT_ADD_PROFILE);
- } else {
- $result=update_host_profile($hostid,
- $_REQUEST["devicetype"],$_REQUEST["name"],$_REQUEST["os"],
- $_REQUEST["serialno"],$_REQUEST["tag"],$_REQUEST["macaddress"],
- $_REQUEST["hardware"],$_REQUEST["software"],$_REQUEST["contact"],
- $_REQUEST["location"],$_REQUEST["notes"]);
-
-// show_messages($result, S_PROFILE_UPDATED, S_CANNOT_UPDATE_PROFILE);
- }
- } elseif (DBnum_rows($db_profiles)>0){
- $result=delete_host_profile($hostid);
-// show_messages($result, S_PROFILE_DELETED, S_CANNOT_DELETE_PROFILE);
+ delete_host_profile($hostid);
+
+ if(get_request("useprofile","no") == "yes"){
+ $result = add_host_profile($hostid,
+ $_REQUEST["devicetype"],$_REQUEST["name"],$_REQUEST["os"],
+ $_REQUEST["serialno"],$_REQUEST["tag"],$_REQUEST["macaddress"],
+ $_REQUEST["hardware"],$_REQUEST["software"],$_REQUEST["contact"],
+ $_REQUEST["location"],$_REQUEST["notes"]);
}
}
@@ -252,10 +222,12 @@
$result = update_host_group($_REQUEST["groupid"], $_REQUEST["gname"], $hosts);
$msg_ok = S_GROUP_UPDATED;
$msg_fail = S_CANNOT_UPDATE_GROUP;
+ $groupid = $_REQUEST["groupid"];
} else {
- $result = add_host_group($_REQUEST["gname"], $hosts);
+ $groupid = add_host_group($_REQUEST["gname"], $hosts);
$msg_ok = S_GROUP_ADDED;
$msg_fail = S_CANNOT_ADD_GROUP;
+ $result = $groupid;
}
show_messages($result, $msg_ok, $msg_fail);
if($result){
@@ -318,66 +290,6 @@
show_messages($result, S_HOST_STATUS_UPDATED, NULL);
unset($_REQUEST["activate"]);
}
-/****** ACTIONS FOR LINKS **********/
- elseif($_REQUEST["config"]==2&&isset($_REQUEST["save"]))
- {
- $items = 0;
- $arr_items = get_request("items",array());
- foreach($arr_items as $el) $items |= $el;
-
- $triggers=0;
- $arr_triggers= get_request("triggers",array());
- foreach($arr_triggers as $el) $triggers |= $el;
-
- $graphs=0;
- $arr_graphs = get_request("graphs",array());
- foreach($arr_graphs as $el) $graphs |= $el;
-
- if(isset($_REQUEST["hosttemplateid"]))
- {
- $result=update_template_linkage($_REQUEST["hosttemplateid"],
- $_REQUEST["hostid"],$_REQUEST["templateid"],$items,$triggers,$graphs);
- show_messages($result, S_TEMPLATE_LINKAGE_UPDATED, S_CANNOT_UPDATE_TEMPLATE_LINKAGE);
- }
- else
- {
- $result=add_template_linkage(
- $_REQUEST["hostid"],$_REQUEST["templateid"],$items,$triggers,$graphs);
-
- show_messages($result, S_TEMPLATE_LINKAGE_ADDED, S_CANNOT_ADD_TEMPLATE_LINKAGE);
- }
- if($result){
- unset($_REQUEST["form"]);
- }
- }
- elseif($_REQUEST["config"]==2&&isset($_REQUEST["delete"])&&isset($_REQUEST["hosttemplateid"]))
- {
- $result=delete_template_linkage($_REQUEST["hosttemplateid"]);
- show_messages($result, S_TEMPLATE_LINKAGE_DELETED, S_CANNOT_DELETE_TEMPLATE_LINKAGE);
- unset($_REQUEST["hosttemplateid"]);
- if($result){
- unset($_REQUEST["form"]);
- }
- }
-
-/************* OLD ACTIONS ***************/
-/*
- elseif(isset($_REQUEST["register"]))
- {
- if($_REQUEST["register"]=="add items from template")
- {
- if(isset($_REQUEST["host_templateid"])&&($_REQUEST["host_templateid"]!=0))
- {
- $result=sync_items_with_template_host($_REQUEST["hostid"],$_REQUEST["host_templateid"]);
- show_messages(TRUE,S_ITEMS_ADDED,S_CANNOT_ADD_ITEMS);
- }
- else
- {
- show_messages(FALSE,"",S_SELECT_HOST_TEMPLATE_FIRST);
- }
- }
- }
-*/
?>
<?php
@@ -386,21 +298,15 @@
$cmbConf = new CComboBox("config",$_REQUEST["config"],"submit()");
$cmbConf->AddItem(0,S_HOSTS);
$cmbConf->AddItem(1,S_HOST_GROUPS);
- $cmbConf->AddItem(2,S_HOSTS_TEMPLATES_LINKAGE);
switch($_REQUEST["config"]){
case 0:
- $frmForm->AddVar("groupid",get_request("groupid",0));
$btn = new CButton("form",S_CREATE_HOST);
+ $frmForm->AddVar("groupid",get_request("groupid",0));
break;
case 1:
$btn = new CButton("form",S_CREATE_GROUP);
break;
- case 2:
- $frmForm->AddVar("groupid",get_request("groupid",0));
- $frmForm->AddVar("hostid",get_request("hostid",0));
- $btn = new CButton("form",S_CREATE_LINKAGE);
- break;
}
$frmForm->AddItem($cmbConf);
@@ -412,185 +318,6 @@
echo BR;
?>
-
-<?php
- if($_REQUEST["config"]==2)
- {
- if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0))
- {
- unset($_REQUEST["groupid"]);
- }
- if(isset($_REQUEST["hostid"])&&($_REQUEST["hostid"]==0))
- {
- unset($_REQUEST["hostid"]);
- }
-
-/* filter panel */
- $form = new CForm();
- $form->AddVar("config",$_REQUEST["config"]);
-
- $_REQUEST["groupid"] = get_request("groupid",0);
- $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit();");
- $cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups order by name");
- while($row=DBfetch($result))
- {
- // Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and".
- " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","U",$row2["hostid"])) continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
- }
- $form->AddItem(S_GROUP.SPACE);
- $form->AddItem($cmbGroup);
-
- if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"]>0)
- {
- $sql="select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and".
- " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host";
- }
- else
- {
- $sql="select h.hostid,h.host from hosts h where h.status<>".HOST_STATUS_DELETED.
- " group by h.hostid,h.host order by h.host";
- }
-
- $result=DBselect($sql);
-
- $_REQUEST["hostid"] = get_request("hostid",0);
- $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit();");
-
- $correct_hostid='no';
- $first_hostid = -1;
- while($row=DBfetch($result))
- {
- if(!check_right("Host","U",$row["hostid"])) continue;
- $cmbHosts->AddItem($row["hostid"],$row["host"]);
-
- if($_REQUEST["hostid"]!=0){
- if($_REQUEST["hostid"]==$row["hostid"])
- $correct_hostid = 'ok';
- }
- if($first_hostid <= 0)
- $first_hostid = $row["hostid"];
- }
- if($correct_hostid!='ok')
- $_REQUEST["hostid"] = $first_hostid;
-
- $form->AddItem(SPACE.S_HOST.SPACE);
- $form->AddItem($cmbHosts);
-
- show_header2(S_CONFIGURATION_OF_ITEMS_BIG, $form);
-
-/* table */
- echo BR;
- if(isset($_REQUEST["form"]))
- {
- insert_template_form();
- } else {
- $table = new CTableInfo(S_NO_LINKAGES_DEFINED);
- $table->setHeader(array(S_HOST,S_TEMPLATE,S_ITEMS,S_TRIGGERS,S_GRAPHS));
-
- $result=DBselect("select * from hosts_templates where hostid=".$_REQUEST["hostid"]);
- while($row=DBfetch($result))
- {
- $host=get_host_by_hostid($row["hostid"]);
- $template=get_host_by_hostid($row["templateid"]);
-
- $table->addRow(array(
- new CLink(
- $host["host"],
- "hosts.php?form=update".url_param("config").
- "&hostid=".$row["hostid"].
- "&hosttemplateid=".$row["hosttemplateid"],
- 'action'),
- new CLink(
- $template["host"],
- "hosts.php?form=update".url_param("config").
- "&hostid=".$row["hostid"].
- "&hosttemplateid=".$row["hosttemplateid"],
- 'action'),
- get_template_permission_str($row["items"]),
- get_template_permission_str($row["triggers"]),
- get_template_permission_str($row["graphs"])
- ));
- }
- $table->show();
- }
- }
-?>
-<?php
- if($_REQUEST["config"]==1)
- {
- if(isset($_REQUEST["form"]))
- {
- insert_hostgroups_form(get_request("groupid",NULL));
- } else {
- show_table_header(S_HOST_GROUPS_BIG);
-
- $form = new CForm('hosts.php');
- $form->SetName('groups');
- $form->AddVar("config",get_request("config",0));
-
- $table = new CTableInfo(S_NO_HOST_GROUPS_DEFINED);
-
- $table->setHeader(array(
- array( new CCheckBox("all_groups",NULL,NULL,
- "CheckAll('".$form->GetName()."','all_groups');"),
- S_NAME),
- S_MEMBERS));
-
- $db_groups=DBselect("select groupid,name from groups order by name");
- while($db_group=DBfetch($db_groups))
- {
- $db_hosts = DBselect("select distinct h.host, h.status".
- " from hosts h, hosts_groups hg".
- " where h.hostid=hg.hostid and hg.groupid=".$db_group["groupid"].
- " and h.status not in (".HOST_STATUS_DELETED.") order by host");
-
- $hosts = array("");
- if($db_host=DBfetch($db_hosts)){
- $style = $db_host["status"]==HOST_STATUS_MONITORED ? NULL: "on";
- array_push($hosts,new CSpan($db_host["host"],$style));
- }
- while($db_host=DBfetch($db_hosts)){
- $style = $db_host["status"]==HOST_STATUS_MONITORED ? NULL: "on";
- array_push($hosts,", ",new CSpan($db_host["host"],$style));
- }
-
- $table->AddRow(array(
- array(
- new CCheckBox("groups[]",NULL,NULL,NULL,$db_group["groupid"]),
- new CLink(
- $db_group["name"],
- "hosts.php?form=update&groupid=".$db_group["groupid"].
- url_param("config"),'action')
- ),
- $hosts
- ));
- }
- $footerButtons = array();
- array_push($footerButtons, new CButton('activate','Activate selected',
- "return Confirm('".S_ACTIVATE_SELECTED_HOSTS_Q."');"));
- array_push($footerButtons, SPACE);
- array_push($footerButtons, new CButton('disable','Disable selected',
- "return Confirm('".S_DISABLE_SELECTED_HOSTS_Q."');"));
- array_push($footerButtons, SPACE);
- array_push($footerButtons, new CButton('delete','Delete selected',
- "return Confirm('".S_DELETE_SELECTED_GROUPS_Q."');"));
- $table->SetFooter(new CCol($footerButtons),'table_footer');
-
- $form->AddItem($table);
- $form->Show();
- }
- }
-?>
<?php
if($_REQUEST["config"]==0)
{
@@ -604,19 +331,17 @@
while($row=DBfetch($result))
{
// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.hostid=i.hostid and hg.groupid=".$row["groupid"].
+ $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg".
+ " where hg.groupid=".$row["groupid"].
" and hg.hostid=h.hostid and h.status not in (".HOST_STATUS_DELETED.")".
" group by h.hostid,h.host order by h.host");
- $right='no';
while($row2=DBfetch($result2))
{
if(!check_right("Host","R",$row2["hostid"])) continue;
- $right='yes'; break;
+ $cmbGroups->AddItem($row["groupid"],$row["name"]);
+ break;
}
- if($right=='no') continue;
- $cmbGroups->AddItem($row["groupid"],$row["name"]);
}
$frmForm = new CForm("hosts.php");
$frmForm->AddVar("config",$_REQUEST["config"]);
@@ -654,8 +379,12 @@
continue;
}
+ $template = get_template_path($row["hostid"]);
+ if($template == "/") $template = NULL;
+
$host=new CCol(array(
new CCheckBox("hosts[]",NULL,NULL,NULL,$row["hostid"]),
+ $template,
new CLink($row["host"],"hosts.php?form=update&hostid=".
$row["hostid"].url_param("groupid").url_param("config"), 'action')
));
@@ -694,7 +423,7 @@
else if($row["available"] == HOST_AVAILABLE_UNKNOWN)
$available=new CCol(S_UNKNOWN,"unknown");
- if($row["error"] == "") $error=new CCol("&nbsp;","off");
+ if($row["error"] == "") $error=new CCol(SPACE,"off");
else $error=new CCol($row["error"],"on");
if(check_right("Host","U",$row["hostid"])) {
@@ -729,6 +458,76 @@
}
}
+ elseif($_REQUEST["config"]==1)
+ {
+ if(isset($_REQUEST["form"]))
+ {
+ insert_hostgroups_form(get_request("groupid",NULL));
+ } else {
+ show_table_header(S_HOST_GROUPS_BIG);
+
+ $form = new CForm('hosts.php');
+ $form->SetName('groups');
+ $form->AddVar("config",get_request("config",0));
+
+ $table = new CTableInfo(S_NO_HOST_GROUPS_DEFINED);
+
+ $table->setHeader(array(
+ array( new CCheckBox("all_groups",NULL,NULL,
+ "CheckAll('".$form->GetName()."','all_groups');"),
+ S_NAME),
+ S_MEMBERS));
+
+ $db_groups=DBselect("select groupid,name from groups order by name");
+ while($db_group=DBfetch($db_groups))
+ {
+ $db_hosts = DBselect("select distinct h.host, h.status".
+ " from hosts h, hosts_groups hg".
+ " where h.hostid=hg.hostid and hg.groupid=".$db_group["groupid"].
+ " and h.status not in (".HOST_STATUS_DELETED.") order by host");
+
+ $hosts = array("");
+ if($db_host=DBfetch($db_hosts)){
+ $style =
+ $db_host["status"]==HOST_STATUS_MONITORED ? NULL: (
+ $db_host["status"]==HOST_STATUS_TEMPLATE ? "unknown" :
+ "on");
+ array_push($hosts,new CSpan($db_host["host"],$style));
+ }
+ while($db_host=DBfetch($db_hosts)){
+ $style =
+ $db_host["status"]==HOST_STATUS_MONITORED ? NULL: (
+ $db_host["status"]==HOST_STATUS_TEMPLATE ? "unknown" :
+ "on");
+ array_push($hosts,", ",new CSpan($db_host["host"],$style));
+ }
+
+ $table->AddRow(array(
+ array(
+ new CCheckBox("groups[]",NULL,NULL,NULL,$db_group["groupid"]),
+ new CLink(
+ $db_group["name"],
+ "hosts.php?form=update&groupid=".$db_group["groupid"].
+ url_param("config"),'action')
+ ),
+ $hosts
+ ));
+ }
+ $footerButtons = array();
+ array_push($footerButtons, new CButton('activate','Activate selected',
+ "return Confirm('".S_ACTIVATE_SELECTED_HOSTS_Q."');"));
+ array_push($footerButtons, SPACE);
+ array_push($footerButtons, new CButton('disable','Disable selected',
+ "return Confirm('".S_DISABLE_SELECTED_HOSTS_Q."');"));
+ array_push($footerButtons, SPACE);
+ array_push($footerButtons, new CButton('delete','Delete selected',
+ "return Confirm('".S_DELETE_SELECTED_GROUPS_Q."');"));
+ $table->SetFooter(new CCol($footerButtons),'table_footer');
+
+ $form->AddItem($table);
+ $form->Show();
+ }
+ }
?>
<?php
show_page_footer();
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 6956ff0c..59c8bbc9 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -278,10 +278,10 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
function get_template_permission_str($num)
{
- $str="&nbsp;";
- if(($num&1)==1) $str=$str.S_ADD."&nbsp;";
- if(($num&2)==2) $str=$str.S_UPDATE."&nbsp;";
- if(($num&4)==4) $str=$str.S_DELETE."&nbsp;";
+ $str=SPACE;
+ if(($num&1)==1) $str=$str.S_ADD.SPACE;
+ if(($num&2)==2) $str=$str.S_UPDATE.SPACE;
+ if(($num&4)==4) $str=$str.S_DELETE.SPACE;
return $str;
}
@@ -1227,7 +1227,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
if(($sub["url"]=="screenconf.php")&&!check_anyright("Screen","U")) continue;
if(($sub["url"]=="services.php")&&!check_anyright("Service","U")) continue;
- echo "<a href=\"".$sub["url"]."\" class=\"highlight\">".$sub["label"]."</a><span class=\"divider\">&nbsp;&nbsp;|&nbsp;</span>\n";
+ echo "<a href=\"".$sub["url"]."\" class=\"highlight\">".$sub["label"]."</a><span class=\"divider\">".SPACE.SPACE."|".SPACE."</span>\n";
}
?>
</b></td></tr>
@@ -1600,178 +1600,6 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
}
}
- # Add host-template linkage
- function add_template_linkage($hostid,$templateid,$items,$triggers,$graphs)
- {
- $sql="insert into hosts_templates (hostid,templateid,items,triggers,graphs) values ($hostid,$templateid,$items,$triggers,$graphs)";
- return DBexecute($sql);
- }
-
- # Update host-template linkage
- function update_template_linkage($hosttemplateid,$hostid,$templateid,$items,$triggers,$graphs)
- {
- $sql="update hosts_templates set hostid=$hostid,templateid=$templateid,items=$items,triggers=$triggers,graphs=$graphs where hosttemplateid=$hosttemplateid";
- return DBexecute($sql);
- }
-
- # Delete host-template linkage
- function delete_template_linkage($hosttemplateid)
- {
- $sql="delete from hosts_templates where hosttemplateid=$hosttemplateid";
- return DBexecute($sql);
- }
-
- function add_group_to_host($hostid,$newgroup)
- {
- $sql="insert into groups (groupid,name) values (NULL,".zbx_dbstr($newgroup).")";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
-
- $groupid=DBinsert_id($result,"groupd","groupid");
-
- $sql="insert into hosts_groups (hostid,groupid) values ($hostid,$groupid)";
- $result=DBexecute($sql);
-
- return $result;
- }
-
- function update_host_groups_by_groupid($groupid,$hosts)
- {
- $count=count($hosts);
-
- $sql="delete from hosts_groups where groupid=$groupid";
- DBexecute($sql);
-
- for($i=0;$i<$count;$i++)
- {
- $sql="insert into hosts_groups (hostid,groupid) values (".$hosts[$i].",$groupid)";
- DBexecute($sql);
- }
- }
-
- function update_host_groups($hostid,$groups)
- {
- $count=count($groups);
-
- $sql="delete from hosts_groups where hostid=$hostid";
- DBexecute($sql);
-
- for($i=0;$i<$count;$i++)
- {
- $sql="insert into hosts_groups (hostid,groupid) values ($hostid,".$groups[$i].")";
- DBexecute($sql);
- }
- }
-
- function add_host_group($name,$hosts)
- {
-// if(!check_right("Host","A",0))
-// {
-// error("Insufficient permissions");
-// return 0;
-// }
-
- $sql="select * from groups where name=".zbx_dbstr($name);
- $result=DBexecute($sql);
- if(DBnum_rows($result)>0)
- {
- error("Group '$name' already exists");
- return 0;
- }
-
- $sql="insert into groups (name) values (".zbx_dbstr($name).")";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
-
- $groupid=DBinsert_id($result,"groups","groupid");
-
- update_host_groups_by_groupid($groupid,$hosts);
-
- return $result;
- }
-
- function update_host_group($groupid,$name,$users)
- {
-// if(!check_right("Host","U",0))
-// {
-// error("Insufficient permissions");
-// return 0;
-// }
-
- $sql="select * from groups where name=".zbx_dbstr($name)." and groupid<>$groupid";
- $result=DBexecute($sql);
- if(DBnum_rows($result)>0)
- {
- error("Group '$name' already exists");
- return 0;
- }
-
- $sql="update groups set name=".zbx_dbstr($name)." where groupid=$groupid";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
-
- update_host_groups_by_groupid($groupid,$users);
-
- return $result;
- }
-
- # Sync host with hard-linked templates
- function sync_host_with_templates($hostid)
- {
- $sql="select * from hosts_templates where hostid=$hostid";
- $result=DBselect($sql);
- while($row=DBfetch($result))
- {
- sync_host_with_template($hostid,$row["templateid"],$row["items"],$row["triggers"],
- $row["graphs"]);
- }
- }
-
- # Sync host with hard-linked template
- function sync_host_with_template($hostid,$templateid,$items,$triggers,$graphs)
- {
- if(!isset($templateid)||($templateid==0))
- {
- error("Select template first");
- return 0;
- }
-
- // Sync items
- $sql="select itemid from items where hostid=$templateid";
- $result=DBselect($sql);
- while($row=DBfetch($result))
- {
- add_item_to_linked_hosts($row["itemid"],$hostid);
- }
-
- // Sync triggers
- $sql="select distinct t.triggerid from hosts h, items i,triggers t,functions f where h.hostid=$templateid and h.hostid=i.hostid and t.triggerid=f.triggerid and i.itemid=f.itemid";
- $result=DBselect($sql);
- while($row=DBfetch($result))
- {
- add_trigger_to_linked_hosts($row["triggerid"],$hostid);
- }
-
- // Sync graphs
- $sql="select distinct gi.gitemid from graphs g,graphs_items gi,items i where i.itemid=gi.itemid and i.hostid=$templateid and g.graphid=gi.graphid";
- $result=DBselect($sql);
- while($row=DBfetch($result))
- {
- add_graph_item_to_linked_hosts($row["gitemid"],$hostid);
- }
-
- return TRUE;
- }
-
# Delete Media definition by mediatypeid
function delete_media_by_mediatypeid($mediatypeid)
@@ -2462,8 +2290,10 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
S_ZABBIX_VER.SPACE.S_COPYRIGHT_BY.SPACE.S_SIA_ZABBIX,
"http://www.zabbix.com", "highlight"),
"page_footer_l"),
- new CCol("<span class='divider'>&nbsp;&nbsp;|&nbsp;&nbsp;</span>".
- S_CONNECTED_AS."&nbsp;".$USER_DETAILS["alias"],
+ new CCol(array(
+ new CSpan(SPACE.SPACE."|".SPACE.SPACE,"divider"),
+ S_CONNECTED_AS.SPACE.$USER_DETAILS["alias"]
+ ),
"page_footer_r")
));
$table->Show();
@@ -2919,7 +2749,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
echo "<TD ALIGN=LEFT>";
echo "<div align=left>";
- echo "<b>".S_PERIOD.":</b>&nbsp;";
+ echo "<b>".S_PERIOD.":</b>".SPACE;
$hour=3600;
@@ -2944,14 +2774,14 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
$tmp=$_REQUEST["period"]+$sec;
echo("<A HREF=\"charts.php?period=$tmp".url_param($resource).url_param("stime").url_param("from").url_param("keep").url_param("fullscreen")."\">+</A>");
- echo "]&nbsp;";
+ echo "]".SPACE;
}
echo("</div>");
echo "</TD>";
echo "<TD BGCOLOR=#FFFFFF WIDTH=15% ALIGN=RIGHT>";
- echo "<b>".nbsp(S_KEEP_PERIOD).":</b>&nbsp;";
+ echo "<b>".nbsp(S_KEEP_PERIOD).":</b>".SPACE;
if($_REQUEST["keep"] == 1)
{
echo("[<A HREF=\"charts.php?keep=0".url_param($resource).url_param("from").url_param("period").url_param("fullscreen")."\">".S_ON_C."</a>]");
@@ -2967,7 +2797,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
if(isset($_REQUEST["stime"]))
{
echo "<div align=left>" ;
- echo "<b>".S_MOVE.":</b>&nbsp;" ;
+ echo "<b>".S_MOVE.":</b>".SPACE;
$day=24;
// $a already defined
@@ -2991,14 +2821,14 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
$tmp=date("YmdHi",$tmp);
echo("<A HREF=\"charts.php?stime=$tmp".url_param($resource).url_param("period").url_param("keep").url_param("fullscreen")."\">+</A>");
- echo "]&nbsp;";
+ echo "]".SPACE;
}
echo("</div>");
}
else
{
echo "<div align=left>";
- echo "<b>".S_MOVE.":</b>&nbsp;";
+ echo "<b>".S_MOVE.":</b>".SPACE;
$day=24;
// $a already defined
@@ -3022,7 +2852,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
echo "+";
}
- echo "]&nbsp;";
+ echo "]".SPACE;
}
echo("</div>");
}
@@ -3040,7 +2870,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
{
echo "<input name=\"stime\" class=\"biginput\" value=\"yyyymmddhhmm\" size=12>";
}
- echo "&nbsp;";
+ echo SPACE;
echo "<input class=\"button\" type=\"submit\" name=\"action\" value=\"go\">";
echo "</form>";
// echo("</div>");
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index 7d9c1cf4..8f6c2b68 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -79,7 +79,7 @@
{
global $DB,$DB_TYPE;
-# echo $query."<br>";
+ $result = FALSE;
if($DB_TYPE == "MYSQL")
{
@@ -90,14 +90,15 @@
error("SQL error: ".mysql_error());
error("Query: $query");
}
- return $result;
}
if($DB_TYPE == "POSTGRESQL")
{
$result=pg_exec($DB,$query);
- return $result;
}
- return FALSE;
+
+//SDI("DBexecute($query) = '".$result."'");
+
+ return $result;
}
function DBfetch($result)
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 18e767f6..e2d9725f 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -318,7 +318,9 @@
if(isset($_REQUEST["groupid"]))
$frmItem->AddVar("groupid",$_REQUEST["groupid"]);
- $description = get_request("description" ,"");
+ $frmItem->AddVar("hostid",$_REQUEST["hostid"]);
+
+ $description = get_request("description" ,"new");
$key = get_request("key" ,"");
$host = get_request("host", NULL);
$delay = get_request("delay" ,30);
@@ -332,7 +334,6 @@
$trapper_hosts = get_request("trapper_hosts" ,"");
$units = get_request("units" ,'');
$multiplier = get_request("multiplier" ,0);
- $hostid = get_request("hostid" ,0);
$delta = get_request("delta" ,0);
$trends = get_request("trends" ,365);
@@ -347,8 +348,8 @@
$add_groupid = get_request("add_groupid" ,get_request("groupid",0));
- if(is_null($host)&&$hostid>0){
- $host_info = get_host_by_hostid($hostid);
+ if(is_null($host)){
+ $host_info = get_host_by_hostid($_REQUEST["hostid"]);
$host = $host_info["host"];
}
@@ -364,8 +365,6 @@
" from items i,hosts h where i.itemid=".$_REQUEST["itemid"].
" and h.hostid=i.hostid");
$row=DBfetch($result);
-
- $frmItem->SetTitle(S_ITEM." \"". $row["description"]."\"");
}
if(isset($_REQUEST["itemid"]) && !isset($_REQUEST["form_refresh"]))
@@ -396,16 +395,14 @@
$formula = $row["formula"];
$logtimefmt = $row["logtimefmt"];
}
+ if(isset($_REQUEST["itemid"])) {
+ $frmItem->SetTitle(S_ITEM." '$host:".$row["description"]."'");
+ } else {
+ $frmItem->SetTitle(S_ITEM." '$host:$description'");
+ }
$frmItem->AddRow(S_DESCRIPTION, new CTextBox("description",$description,40));
- $frmItem->AddVar("hostid",$hostid);
- $frmItem->AddRow(S_HOST, array(
- new CTextBox("host",$host,30,NULL,'yes'),
- new CButton("btn1","Select","return PopUp('popup.php?form=".$frmItem->GetName().
- "&field1=hostid&field2=host','host','width=450,height=450,".
- "resizable=1,scrollbars=1');","T")
- ));
$cmbType = new CComboBox("type",$type,"submit()");
$cmbType->AddItem(ITEM_TYPE_ZABBIX,'Zabbix agent');
@@ -1188,7 +1185,7 @@
while($trigger = DBfetch($triggers))
{
$cmbCondVal->AddItem($trigger["triggerid"],
- $trigger["host"].":&nbsp;".$trigger["description"]);
+ $trigger["host"].":".SPACE.$trigger["description"]);
}
array_push($rowCondition,$cmbCondVal);
}
@@ -1735,7 +1732,6 @@
$groups= get_request("groups",array());
$newgroup = get_request("newgroup","");
- $host_templateid= get_request("host_templateid","");
$host = get_request("host", "");
$port = get_request("port", get_profile("HOST_PORT",10050));
@@ -1757,6 +1753,8 @@
$location = get_request("location","");
$notes = get_request("notes","");
+ $templateid= get_request("templateid",0);
+
if(isset($_REQUEST["hostid"])){
$db_host=get_host_by_hostid($_REQUEST["hostid"]);
$frm_title = S_HOST.SPACE."\"".$db_host["host"]."\"";
@@ -1771,6 +1769,8 @@
$status = $db_host["status"];
$useip = $db_host["useip"]==1 ? 'yes' : 'no';
$ip = $db_host["ip"];
+
+ $templateid = $db_host["templateid"];
// add groups
$db_groups=DBselect("select groupid from hosts_groups where hostid=".$_REQUEST["hostid"]);
while($db_group=DBfetch($db_groups)){
@@ -1845,14 +1845,15 @@
$cmbStatus->AddItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED);
$frmHost->AddRow(S_STATUS,$cmbStatus);
- $cmbHosts = new CComboBox("host_templateid",$host_templateid);
+ $cmbHosts = new CComboBox("templateid",$templateid);
$cmbHosts->AddItem(0,"...");
- $hosts=DBselect("select host,hostid from hosts where status not in (".HOST_STATUS_DELETED.") order by host");
+ $hosts=DBselect("select host,hostid from hosts where status not in (".HOST_STATUS_DELETED.")".
+ " order by host");
while($host=DBfetch($hosts))
{
$cmbHosts->AddItem($host["hostid"],$host["host"]);
}
- $frmHost->AddRow(S_USE_TEMPLATES_OF_THIS_HOST,$cmbHosts);
+ $frmHost->AddRow(S_LINK_WITH_HOST,$cmbHosts);
$frmHost->AddRow(S_USE_PROFILE,new CCheckBox("useprofile",$useprofile,NULL,"submit()"));
if($useprofile=="yes")
@@ -1892,12 +1893,13 @@
$frmHost->AddItemToBottomRow(SPACE);
$frmHost->AddItemToBottomRow(
new CButtonDelete(S_DELETE_SELECTED_HOST_Q,
- url_param("form").url_param("config").url_param("hostid")
+ url_param("form").url_param("config").url_param("hostid").
+ url_param("groupid")
)
);
}
$frmHost->AddItemToBottomRow(SPACE);
- $frmHost->AddItemToBottomRow(new CButtonCancel(url_param("config")));
+ $frmHost->AddItemToBottomRow(new CButtonCancel(url_param("config").url_param("groupid")));
$frmHost->Show();
}
diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php
index 495d6c46..0963cbbb 100644
--- a/frontends/php/include/graphs.inc.php
+++ b/frontends/php/include/graphs.inc.php
@@ -495,7 +495,7 @@
function navigation_bar($url)
{
$h1=S_NAVIGATE;
- $h2=S_PERIOD."&nbsp;";
+ $h2=S_PERIOD.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"period\" onChange=\"submit()\">";
$h2=$h2.form_select("period",3600,"1h");
$h2=$h2.form_select("period",2*3600,"2h");
@@ -525,7 +525,7 @@
$h2=$h2.form_select("inc",31*24*3600,"+month");
$h2=$h2.form_select("inc",365*24*3600,"+year");
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_MOVE."&nbsp;";
+ $h2=$h2.SPACE.S_MOVE.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"left\" onChange=\"submit()\">";
$h2=$h2.form_select("left",0,S_LEFT_DIR);
$h2=$h2.form_select("left",1,"-1h");
@@ -544,9 +544,9 @@
$h2=$h2.form_select("right",31*24,"+month");
$h2=$h2.form_select("right",365*24,"+year");
$h2=$h2."</select>";
- $h2=$h2."&nbsp;";
+ $h2=$h2.SPACE;
$h2=$h2."<input name=\"stime\" size=18 class=\"biginput\" value=\"yyyymmddhhmm\" size=12>";
- $h2=$h2."&nbsp;";
+ $h2=$h2.SPACE;
$h2=$h2."<input class=\"button\" type=\"submit\" name=\"action\" value=\"go\">";
$h2=$h2."<input class=\"button\" type=\"submit\" name=\"reset\" value=\"reset\">";
@@ -584,7 +584,7 @@
echo "<TD ALIGN=LEFT>";
echo "<div align=left>";
- echo "<b>".S_PERIOD.":</b>&nbsp;";
+ echo "<b>".S_PERIOD.":</b>".SPACE;
$hour=3600;
@@ -609,14 +609,14 @@
$tmp=$_REQUEST["period"]+$sec;
echo("<A HREF=\"$url?period=$tmp".url_param("graphid").url_param("stime").url_param("from").url_param("keep").url_param("fullscreen")."\">+</A>");
- echo "]&nbsp;";
+ echo "]".SPACE;
}
echo("</div>");
echo "</TD>";
echo "<TD BGCOLOR=#FFFFFF WIDTH=15% ALIGN=RIGHT>";
- echo "<b>".nbsp(S_KEEP_PERIOD).":</b>&nbsp;";
+ echo "<b>".nbsp(S_KEEP_PERIOD).":</b>".SPACE;
if($_REQUEST["keep"] == 1)
{
echo("[<A HREF=\"$url?keep=0".url_param("graphid").url_param("from").url_param("period").url_param("fullscreen")."\">".S_ON_C."</a>]");
@@ -632,7 +632,7 @@
if(isset($_REQUEST["stime"]))
{
echo "<div align=left>" ;
- echo "<b>".S_MOVE.":</b>&nbsp;" ;
+ echo "<b>".S_MOVE.":</b>".SPACE;
$day=24;
// $a already defined
@@ -656,14 +656,14 @@
$tmp=date("YmdHi",$tmp);
echo("<A HREF=\"$url?stime=$tmp".url_param("graphid").url_param("period").url_param("keep").url_param("fullscreen")."\">+</A>");
- echo "]&nbsp;";
+ echo "]".SPACE;
}
echo("</div>");
}
else
{
echo "<div align=left>";
- echo "<b>".S_MOVE.":</b>&nbsp;";
+ echo "<b>".S_MOVE.":</b>".SPACE;
$day=24;
// $a already defined
@@ -687,7 +687,7 @@
echo "+";
}
- echo "]&nbsp;";
+ echo "]".SPACE;
}
echo("</div>");
}
@@ -704,7 +704,7 @@
{
echo "<input name=\"stime\" class=\"biginput\" value=\"yyyymmddhhmm\" size=12>";
}
- echo "&nbsp;";
+ echo SPACE;
echo "<input class=\"button\" type=\"submit\" name=\"action\" value=\"go\">";
echo "</form>";
echo "</TD>";
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index c874c318..3a547d46 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -19,122 +19,234 @@
**/
?>
<?php
- # Add Host definition
- function add_host($host,$port,$status,$useip,$ip,$host_templateid,$newgroup,$groups)
+/* HOST GROUP functions */
+ function add_host_to_group($hostid, $groupid)
{
- if(!check_right("Host","A",0))
- {
- error("Insufficient permissions");
- return 0;
+ if(!is_numeric($hostid) || !is_numeric($groupid)){
+ error("incorrect parameters for 'add_host_to_group'");
+ return FALSE;
}
-
- if (!eregi('^([0-9a-zA-Z\_\.-]+)$', $host, $arr))
- {
- error("Hostname should contain 0-9a-zA-Z_.- characters only");
- return 0;
+ return DBexecute("insert into hosts_groups (hostid,groupid) values ($hostid,$groupid)");
+ }
+ function db_save_group($name,$groupid=NULL)
+ {
+ if(!is_string($name)){
+ error("incorrect parameters for 'db_save_group'");
+ return FALSE;
}
-
- $sql="select * from hosts where host=".zbx_dbstr($host);
- $result=DBexecute($sql);
+
+ if($groupid==NULL)
+ $result = DBexecute("select * from groups where name=".zbx_dbstr($name));
+ else
+ $result = DBexecute("select * from groups where name=".zbx_dbstr($name).
+ " and groupid<>$groupid");
+
if(DBnum_rows($result)>0)
{
- error("Host '$host' already exists");
- return 0;
- }
-
- if($useip=="on" || $useip=="yes" || $useip==1)
- {
- $useip=1;
+ error("Group '$name' already exists");
+ return FALSE;
}
+ if($groupid==NULL)
+ return DBexecute("insert into groups (name) values (".zbx_dbstr($name).")");
else
- {
- $useip=0;
- }
+ return DBexecute("update groups set name=".zbx_dbstr($name)." where groupid=$groupid");
+ }
+
+ function add_group_to_host($hostid,$newgroup="")
+ {
+ if($newgroup == "" || $newgroup == NULL)
+ return TRUE;
- $sql="insert into hosts (host,port,status,useip,ip,disable_until,available) values (".zbx_dbstr($host).",$port,$status,$useip,".zbx_dbstr($ip).",0,".HOST_AVAILABLE_UNKNOWN.")";
- $result=DBexecute($sql);
+ $result = db_save_group($newgroup);
if(!$result)
- {
return $result;
- }
- $hostid=DBinsert_id($result,"hosts","hostid");
+ $groupid = DBinsert_id($result,"groupd","groupid");
- if($host_templateid != 0)
- {
- add_templates_to_host($hostid,$host_templateid);
- sync_host_with_templates($hostid);
- }
- if($groups != "")
+ return add_host_to_group($hostid, $groupid);
+ }
+
+ function update_host_groups_by_groupid($groupid,$hosts=array())
+ {
+ DBexecute("delete from hosts_groups where groupid=$groupid");
+
+ foreach($hosts as $hostid)
{
- update_host_groups($hostid,$groups);
+ add_host_to_group($hostid, $groupid);
}
- if($newgroup != "")
+ }
+
+ function update_host_groups($hostid,$groups=array())
+ {
+ DBexecute("delete from hosts_groups where hostid=$hostid");
+
+ foreach($groups as $groupid)
{
- add_group_to_host($hostid,$newgroup);
+ add_host_to_group($hostid, $groupid);
}
+ }
- update_profile("HOST_PORT",$port);
+ function add_host_group($name,$hosts)
+ {
+// if(!check_right("Host","A",0))
+// {
+// error("Insufficient permissions");
+// return FLASE;
+// }
+
+ $result = db_save_group($name);
+ if(!$result)
+ return $result;
- return $result;
+ $groupid = DBinsert_id($result,"groups","groupid");
+
+ update_host_groups_by_groupid($groupid,$hosts);
+
+ return $groupid;
}
- function update_host($hostid,$host,$port,$status,$useip,$ip,$newgroup,$groups)
+ function update_host_group($groupid,$name,$hosts)
{
- if(!check_right("Host","U",$hostid))
- {
- error("Insufficient permissions");
- return 0;
- }
+// if(!check_right("Host","U",0))
+// {
+// error("Insufficient permissions");
+// return 0;
+// }
- if (!eregi('^([0-9a-zA-Z\_\.-]+)$', $host, $arr))
+
+ $result = db_save_group($name,$groupid);
+ if(!$result)
+ return $result;
+
+ update_host_groups_by_groupid($groupid,$hosts);
+
+ return $result;
+ }
+
+/* HOST finction */
+ function check_circle_host_link($hostid, $templateid)
+ {
+ if($templateid <= 0) return FALSE;
+ if($hostid == $templateid) return TRUE;
+ $template = get_host_by_hostid($templateid);
+ if($template["templateid"] > 0)
+ return check_circle_host_link($hostid, $template["templateid"]);
+
+ return FALSE;
+ }
+
+ function db_save_host($host,$port,$status,$useip,$ip,$templateid,$hostid=NULL)
+ {
+ if (!eregi('^([0-9a-zA-Z\_\.-]+)$', $host))
{
error("Hostname should contain 0-9a-zA-Z_.- characters only");
- return 0;
+ return FALSE;
}
- $sql="select * from hosts where host=".zbx_dbstr($host)." and hostid<>$hostid";
- $result=DBexecute($sql);
+ if($hostid==NULL)
+ $result=DBexecute("select * from hosts where host=".zbx_dbstr($host));
+ else
+ $result=DBexecute("select * from hosts where host=".zbx_dbstr($host).
+ " and hostid<>$hostid");
+
if(DBnum_rows($result)>0)
{
error("Host '$host' already exists");
- return 0;
+ return FALSE;
}
+ if($useip=="on" || $useip=="yes" || $useip==1) $useip=1;
+ else $useip=0;
- if($useip=="on" || $useip=="yes" || $useip==1)
+ if($hostid==NULL)
{
- $useip=1;
+ $result = DBexecute("insert into hosts".
+ " (host,port,status,useip,ip,disable_until,available,templateid)".
+ " values (".zbx_dbstr($host).",$port,$status,$useip,".zbx_dbstr($ip).",0,"
+ .HOST_AVAILABLE_UNKNOWN.",$templateid)");
}
else
{
- $useip=0;
+ if(check_circle_host_link($hostid, $templateid))
+ {
+ error("Circle link can't be created");
+ return FALSE;
+ }
+
+ $result = DBexecute("update hosts set host=".zbx_dbstr($host).",".
+ "port=$port,useip=$useip,ip=".zbx_dbstr($ip).",templateid=$templateid".
+ " where hostid=$hostid");
+
+ update_host_status($hostid, $status);
}
+ return $result;
+ }
- $sql="update hosts set host=".zbx_dbstr($host).",port=$port,useip=$useip,ip=".zbx_dbstr($ip)." where hostid=$hostid";
- $result=DBexecute($sql);
+ function add_host($host,$port,$status,$useip,$ip,$templateid,$newgroup,$groups)
+ {
+ if(!check_right("Host","A",0))
+ {
+ error("Insufficient permissions");
+ return FALSE;
+ }
+ $result = db_save_host($host,$port,$status,$useip,$ip,$templateid);
+ if(!$result)
+ return $result;
+
+ $hostid = DBinsert_id($result,"hosts","hostid");
- update_host_status($hostid, $status);
update_host_groups($hostid,$groups);
- if($newgroup != "")
+
+ add_group_to_host($hostid,$newgroup);
+
+ sync_host_with_templates($hostid);
+
+ update_profile("HOST_PORT",$port);
+
+ return $hostid;
+ }
+
+ function update_host($hostid,$host,$port,$status,$useip,$ip,$templateid,$newgroup,$groups)
+ {
+ if(!check_right("Host","U",$hostid))
{
- add_group_to_host($hostid,$newgroup);
+ error("Insufficient permissions");
+ return FALSE;
}
+
+ $old_host = get_host_by_hostid($hostid);
+
+ $result = db_save_host($host,$port,$status,$useip,$ip,$templateid,$hostid);
+ if(!$result)
+ return $result;
+
+ update_host_groups($hostid, $groups);
+
+ add_group_to_host($hostid,$newgroup);
+
+ if($old_host["templateid"] != $templateid)
+ sync_host_with_templates($hostid);
+
return $result;
}
- # Add templates linked to template host to the host
-
- function add_templates_to_host($hostid,$host_templateid)
+# Sync host with linked template
+ function sync_host_with_templates($hostid)
{
- $sql="select * from hosts_templates where hostid=$host_templateid";
- $result=DBselect($sql);
- while($row=DBfetch($result))
+ $host = get_host_by_hostid($hostid);
+ delete_template_items_by_hostid($hostid);
+// TODO delete_template_triggers_by_hostid($hostid);
+// TODO delete_template_hosts_by_hostid($hostid);
+
+ if($host["templateid"] > 0)
{
- add_template_linkage($hostid,$row["templateid"],$row["items"],$row["triggers"],
- $row["graphs"]);
+// start host syncing
+ sync_items_with_template($hostid);
+// TODO sync_triggers_with_template($hostid);
+// TODO sync_hosts_with_teplates($hostid);
+// end host syncing
}
}
@@ -243,13 +355,24 @@
if($status != $old_status)
{
update_trigger_value_to_unknown_by_hostid($hostid);
- $sql="update hosts set status=$status where hostid=$hostid and status!=".HOST_STATUS_DELETED;
info("Updated status of host ".$row["host"]);
- return DBexecute($sql);
+ return DBexecute("update hosts set status=$status".
+ " where hostid=$hostid and status!=".HOST_STATUS_DELETED);
}
else
{
return 1;
}
}
+
+ function get_template_path($hostid)
+ {
+ $host = get_host_by_hostid($hostid);
+
+ if ($host["templateid"]==0)
+ return "/";
+
+ $tmp_host = get_host_by_hostid($host["templateid"]);
+ return get_template_path($tmp_host["hostid"]).$tmp_host["host"]."/";
+ }
?>
diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php
index 19751f62..4c888aaa 100644
--- a/frontends/php/include/html.inc.php
+++ b/frontends/php/include/html.inc.php
@@ -44,7 +44,7 @@
function nbsp($str)
{
- return str_replace(" ","&nbsp;",$str);;
+ return str_replace(" ",SPACE,$str);;
}
function form_select($var, $value, $label)
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index cdcdb6c4..8cdd3d26 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -47,11 +47,12 @@
return 0;
}
- $sql="select i.itemid from hosts_groups hg,items i where hg.groupid=$groupid and i.key_=".zbx_dbstr($item["key_"])." and hg.hostid=i.hostid";
+ $sql="select i.itemid from hosts_groups hg,items i".
+ " where hg.groupid=$groupid and i.key_=".zbx_dbstr($item["key_"]).
+ " and hg.hostid=i.hostid";
$result=DBexecute($sql);
while($row=DBfetch($result))
{
- delete_item_from_templates($row["itemid"]);
delete_item($row["itemid"]);
}
return 1;
@@ -72,35 +73,30 @@
# Add Item definition
- function add_item($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,$formula,$trends,$logtimefmt)
+ function add_item(
+ $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,$formula,$trends,$logtimefmt,
+ $templateid=0)
{
- if(!check_right("Item","A",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$host=get_host_by_hostid($hostid);
- $sql="select count(*) as cnt from items where hostid=$hostid and key_=".zbx_dbstr($key);
- $result=DBexecute($sql);
- $row = DBfetch($result);
- if($row["cnt"]>0)
+ if(!check_right("Item","A",0))
{
- error("An item with the same Key already exists for host ".$host["host"].". The key must be unique.");
- return 0;
+ error("Insufficient permissions to item '".$host["host"].":$key'");
+ return FALSE;
}
if($delay<1)
{
error("Delay cannot be less than 1 second");
- return 0;
+ return FALSE;
}
if( ($snmp_port<1)||($snmp_port>65535))
{
error("Invalid SNMP port");
- return 0;
+ return FALSE;
}
if($value_type == ITEM_VALUE_TYPE_STR)
@@ -108,14 +104,70 @@
$delta=0;
}
- $sql="insert into items (description,key_,hostid,delay,history,nextcheck,status,type,snmp_community,snmp_oid,value_type,trapper_hosts,snmp_port,units,multiplier,delta,snmpv3_securityname,snmpv3_securitylevel,snmpv3_authpassphrase,snmpv3_privpassphrase,formula,trends,logtimefmt) values (".zbx_dbstr($description).",".zbx_dbstr($key).",$hostid,$delay,$history,0,$status,$type,".zbx_dbstr($snmp_community).",".zbx_dbstr($snmp_oid).",$value_type,".zbx_dbstr($trapper_hosts).",$snmp_port,".zbx_dbstr($units).",$multiplier,$delta,".zbx_dbstr($snmpv3_securityname).",$snmpv3_securitylevel,".zbx_dbstr($snmpv3_authpassphrase).",".zbx_dbstr($snmpv3_privpassphrase).",".zbx_dbstr($formula).",$trends,".zbx_dbstr($logtimefmt).")";
- $result=DBexecute($sql);
- if($result)
+ $db_items = DBexecute("select itemid,hostid from items".
+ " where hostid=$hostid and key_=".zbx_dbstr($key));
+ if(DBnum_rows($db_items) > 0 && $templateid == 0)
+ {
+ error("An item with the same Key already exists for host ".$host["host"].".".
+ " The key must be unique.");
+ return FALSE;
+ } elseif (DBnum_rows($db_items) > 0 && $templateid != 0){
+ $db_item = DBfetch($db_items);
+
+ $result = update_item(
+ $db_item["itemid"], $description, $key, $db_item["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, $formula,
+ $trends, $logtimefmt, $itemid);
+
+ return $result;
+ }
+
+ // first add mother item
+ $result=DBexecute("insert into items".
+ " (description,key_,hostid,delay,history,nextcheck,status,type,".
+ "snmp_community,snmp_oid,value_type,trapper_hosts,snmp_port,units,multiplier,".
+ "delta,snmpv3_securityname,snmpv3_securitylevel,snmpv3_authpassphrase,".
+ "snmpv3_privpassphrase,formula,trends,logtimefmt,templateid)".
+ " values (".zbx_dbstr($description).",".zbx_dbstr($key).",$hostid,$delay,$history,0,
+ $status,$type,".zbx_dbstr($snmp_community).",".zbx_dbstr($snmp_oid).",$value_type,".
+ zbx_dbstr($trapper_hosts).",$snmp_port,".zbx_dbstr($units).",$multiplier,$delta,".
+ zbx_dbstr($snmpv3_securityname).",$snmpv3_securitylevel,".
+ zbx_dbstr($snmpv3_authpassphrase).",".zbx_dbstr($snmpv3_privpassphrase).",".
+ zbx_dbstr($formula).",$trends,".zbx_dbstr($logtimefmt).",$templateid)");
+
+
+ if(!$result)
+ return $result;
+
+ $itemid = DBinsert_id($result,"items","itemid");
+ info("Added new item ".$host["host"].":$key");
+
+// add items to child hosts
+
+ $db_hosts = DBselect("select hostid from hosts where templateid=".$host["hostid"]);
+ while($db_host = DBfetch($db_hosts))
{
- $host=get_host_by_hostid($hostid);
- info("Added new item ".$host["host"].":$key");
+ // recursion
+ $result = add_item($description, $key, $db_host["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, $formula,
+ $trends, $logtimefmt, $itemid);
+ if(!$result)
+ break;
}
- return DBinsert_id($result,"items","itemid");
+ if($result)
+ return $itemid;
+
+ if($templateid == 0){
+ delete_item($itemid);
+ }
+
+ return $result;
}
# Update Item status
@@ -140,23 +192,26 @@
function 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,
- $formula,$trends,$logtimefmt)
+ $formula,$trends,$logtimefmt,$templateid=0)
{
+ $host = get_host_by_hostid($hostid);
+
if(!check_right("Item","U",$itemid))
{
- error("Insufficient permissions");
- return 0;
+ error("Insufficient permissions to item '".$host["host"].":$key'");
+ return FALSE;
}
+
if($delay<1)
{
error("Delay cannot be less than 1 second");
- return 0;
+ return FALSE;
}
if( ($snmp_port<1)||($snmp_port>65535))
{
error("Invalid SNMP port");
- return 0;
+ return FALSE;
}
if($value_type == ITEM_VALUE_TYPE_STR)
@@ -164,10 +219,52 @@
$delta=0;
}
+ $db_items = DBexecute("select itemid as cnt from items".
+ " where hostid=$hostid and itemid<>$itemid and key_=".zbx_dbstr($key));
+ if(DBnum_rows($db_items) > 0 && $templateid == 0)
+ {
+ error("An item with the same Key already exists for host ".$host["host"].".".
+ " The key must be unique.");
+ return FALSE;
+ }
+
+ // first update child items
+ $db_tmp_items = DBselect("select itemid, hostid from items where templateid=$itemid");
+ while($db_tmp_item = DBfetch($db_tmp_items))
+ {
+ // recursion
+ $result = update_item(
+ $db_tmp_item["itemid"], $description, $key, $db_tmp_item["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, $formula,
+ $trends, $logtimefmt, $itemid);
+
+ if(!$result)
+ return $result;
+ }
+
+ if(DBnum_rows($db_items) > 0 && $templateid != 0)
+ {
+ $result = delete_item($itemid);
+ if(!$result) {
+ error("Can't update item '".$host["host"].":$key'");
+ return FALSE;
+ }
+ $db_item = DBfetch($db_items);
+ $itemid = $db_item("itemid");
+ }
+
DBexecute("update items set lastlogsize=0 where itemid=$itemid and key_<>".zbx_dbstr($key));
- $sql="update items set description=".zbx_dbstr($description).",key_=".zbx_dbstr($key).",".
- "hostid=$hostid,delay=$delay,history=$history,nextcheck=0,status=$status,type=$type,".
+ if($templateid==0){
+ update_item_status($itemid, $status);
+ }
+
+ $result=DBexecute(
+ "update items set description=".zbx_dbstr($description).",key_=".zbx_dbstr($key).",".
+ "hostid=$hostid,delay=$delay,history=$history,nextcheck=0,type=$type,".
"snmp_community=".zbx_dbstr($snmp_community).",snmp_oid=".zbx_dbstr($snmp_oid).",".
"value_type=$value_type,trapper_hosts=".zbx_dbstr($trapper_hosts).",".
"snmp_port=$snmp_port,units=".zbx_dbstr($units).",multiplier=$multiplier,delta=$delta,".
@@ -176,35 +273,63 @@
"snmpv3_authpassphrase=".zbx_dbstr($snmpv3_authpassphrase).",".
"snmpv3_privpassphrase=".zbx_dbstr($snmpv3_privpassphrase).",".
"formula=".zbx_dbstr($formula).",trends=$trends,logtimefmt=".zbx_dbstr($logtimefmt).
- " where itemid=$itemid";
- $result=DBexecute($sql);
+ ",templateid=$templateid where itemid=$itemid");
if($result)
{
- $host=get_host_by_hostid($hostid);
- info("Item ".$host["host"].":$key updated");
+ info("Item '".$host["host"].":$key' updated");
+
}
return $result;
}
- function sync_items_with_template_host($hostid,$host_templateid)
+ function delete_template_items_by_hostid($hostid)
{
- $sql="select itemid from items where hostid=$host_templateid";
- $result=DBselect($sql);
- while($row=DBfetch($result))
+ $db_items = DBselect("select itemid from items where hostid=$hostid and templateid<>0");
+ while($db_item = DBfetch($db_items))
{
- $item=get_item_by_itemid($row["itemid"]);
+ delete_item($db_item["itemid"]);
+ }
+ }
- $sql="select itemid from items where key_=".zbx_dbstr($item["key_"])." and hostid=$hostid";
- $result2=DBselect($sql);
- if(DBnum_rows($result2)==0)
- {
- add_item($item["description"],$item["key_"],$hostid,$item["delay"],$item["history"],$item["status"],$item["type"],$item["snmp_community"],$item["snmp_oid"],$item["value_type"],$item["trapper_hosts"],$item["snmp_port"],$item["units"],$item["multiplier"],$item["delta"],$item["snmpv3_securityname"],$item["snmpv3_securitylevel"],$item["snmpv3_authpassphrase"],$item["snmpv3_privpassphrase"],$item["formula"],$item["trends"],$item["logtimefmt"]);
- }
+ function sync_items_with_template($hostid)
+ {
+ $host = get_host_by_hostid($hostid);
+
+//SDI("sync host: ".$host['host']);
+
+ $db_tmp_items = DBselect("select * from items where hostid=".$host["templateid"]);
+
+ while($db_tmp_item = DBfetch($db_tmp_items))
+ {
+ add_item(
+ $db_tmp_item["description"],
+ $db_tmp_item["key_"],
+ $hostid,
+ $db_tmp_item["delay"],
+ $db_tmp_item["history"],
+ $db_tmp_item["status"],
+ $db_tmp_item["type"],
+ $db_tmp_item["snmp_community"],
+ $db_tmp_item["snmp_oid"],
+ $db_tmp_item["value_type"],
+ $db_tmp_item["trapper_hosts"],
+ $db_tmp_item["snmp_port"],
+ $db_tmp_item["units"],
+ $db_tmp_item["multiplier"],
+ $db_tmp_item["delta"],
+ $db_tmp_item["snmpv3_securityname"],
+ $db_tmp_item["snmpv3_securitylevel"],
+ $db_tmp_item["snmpv3_authpassphrase"],
+ $db_tmp_item["snmpv3_privpassphrase"],
+ $db_tmp_item["formula"],
+ $db_tmp_item["trends"],
+ $db_tmp_item["logtimefmt"],
+ $db_tmp_item["itemid"]);
}
}
# Add item to hardlinked hosts
-
+/*
function add_item_to_linked_hosts($itemid,$hostid=0)
{
if($itemid<=0)
@@ -244,9 +369,9 @@
}
}
}
-
+*/
# Add item to hardlinked hosts
-
+/*
function delete_item_from_templates($itemid)
{
if($itemid<=0)
@@ -270,9 +395,9 @@
}
}
}
-
+*/
# Update item in hardlinked hosts
-
+/*
function update_item_in_templates($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,
@@ -304,7 +429,7 @@
}
}
}
-
+*/
# Activate Item
function activate_item($itemid)
@@ -349,30 +474,33 @@
function delete_item($itemid)
{
- $result=delete_triggers_by_itemid($itemid);
- if(!$result)
- {
- return $result;
- }
- $result=delete_trends_by_itemid($itemid);
- $result=delete_history_by_itemid($itemid);
- $sql="delete from graphs_items where itemid=$itemid";
- if(!$result)
- {
- return $result;
- }
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
+ $item = get_item_by_itemid($itemid);
+ $host = get_host_by_itemid($itemid);
+
+ // first delete child items
+ $db_items = DBselect("select itemid from items where templateid=$itemid");
+ while($db_item = DBfetch($db_items))
+ {// recursion
+ $result = delete_item($db_item["itemid"]);
+ if(!$result) return $result;
}
- $item=get_item_by_itemid($itemid);
- $host=get_host_by_hostid($item["hostid"]);
- $sql="delete from items where itemid=$itemid";
- $result=DBexecute($sql);
+
+ $result = delete_triggers_by_itemid($itemid);
+ if(!$result) return $result;
+
+ $result = delete_trends_by_itemid($itemid);
+ if(!$result) return $result;
+
+ $result = delete_history_by_itemid($itemid);
+ if(!$result) return $result;
+
+ $result = DBexecute("delete from graphs_items where itemid=$itemid");
+ if(!$result) return $result;
+
+ $result = DBexecute("delete from items where itemid=$itemid");
if($result)
{
- info("Item ".$host["host"].":".$item["key_"]." deleted");
+ info("Item '".$host["host"].":".$item["key_"]."' deleted");
}
return $result;
}
@@ -405,4 +533,13 @@
return $descr;
}
+
+ function get_realhost_by_itemid($itemid)
+ {
+ $itme = get_item_by_itemid($itemid);
+ if($itme["templateid"] <> 0)
+ return get_realhost_by_itemid($itme["templateid"]);
+
+ return get_host_by_itemid($itemid);
+ }
?>
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 0a9c47c6..72944c65 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -342,7 +342,8 @@
"S_USE_IP_ADDRESS"=> "Use IP address",
"S_IP_ADDRESS"=> "IP address",
// "S_USE_THE_HOST_AS_A_TEMPLATE"=> "Use the host as a template",
- "S_USE_TEMPLATES_OF_THIS_HOST"=> "Use templates of this host",
+// "S_USE_TEMPLATES_OF_THIS_HOST"=> "Use templates of this host",
+ "S_LINK_WITH_HOST"=> "Link with host",
"S_USE_PROFILE"=> "Use profile",
"S_DELETE_SELECTED_HOST_Q"=> "Delete selected host?",
"S_DELETE_SELECTED_GROUP_Q"=> "Delete selected group?",
diff --git a/frontends/php/include/profiles.inc.php b/frontends/php/include/profiles.inc.php
index c0feaaa1..6ad187ee 100644
--- a/frontends/php/include/profiles.inc.php
+++ b/frontends/php/include/profiles.inc.php
@@ -21,7 +21,9 @@
<?php
# Add Host Profile
- function add_host_profile($hostid,$devicetype,$name,$os,$serialno,$tag,$macaddress,$hardware,$software,$contact,$location,$notes)
+ function add_host_profile(
+ $hostid,$devicetype,$name,$os,$serialno,$tag,$macaddress,
+ $hardware,$software,$contact,$location,$notes)
{
// If user has update permission then ok
if(!check_right("Host","U",0))
@@ -30,41 +32,19 @@
return 0;
}
- $sql="select * from hosts_profiles where hostid=$hostid";
- $result=DBexecute($sql);
+ $result=DBexecute("select * from hosts_profiles where hostid=$hostid");
if(DBnum_rows($result)>0)
{
error("Host profile already exists");
return 0;
}
- $sql="insert into hosts_profiles (hostid,devicetype,name,os,serialno,tag,macaddress,hardware,software,contact,location,notes) values ($hostid,".zbx_dbstr($devicetype).",".zbx_dbstr($name).",".zbx_dbstr($os).",".zbx_dbstr($serialno).",".zbx_dbstr($tag).",".zbx_dbstr($macaddress).",".zbx_dbstr($hardware).",".zbx_dbstr($software).",".zbx_dbstr($contact).",".zbx_dbstr($location).",".zbx_dbstr($notes).")";
- $result=DBexecute($sql);
-
- return $result;
- }
-
- # Update Host Profile
-
- function update_host_profile($hostid,$devicetype,$name,$os,$serialno,$tag,$macaddress,$hardware,$software,$contact,$location,$notes)
- {
- // If user has update permission then ok
- if(!check_right("Host","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="select * from hosts_profiles where hostid=$hostid";
- $result=DBexecute($sql);
- if(DBnum_rows($result)==0)
- {
- error("Host profile does not exist");
- return 0;
- }
-
- $sql="update hosts_profiles set devicetype=".zbx_dbstr($devicetype).",name=".zbx_dbstr($name).",os=".zbx_dbstr($os).",serialno=".zbx_dbstr($serialno).",tag=".zbx_dbstr($tag).",macaddress=".zbx_dbstr($macaddress).",hardware=".zbx_dbstr($hardware).",software=".zbx_dbstr($software).",contact=".zbx_dbstr($contact).",location=".zbx_dbstr($location).",notes=".zbx_dbstr($notes)." where hostid=$hostid";
- $result=DBexecute($sql);
+ $result=DBexecute("insert into hosts_profiles".
+ " (hostid,devicetype,name,os,serialno,tag,macaddress,hardware,software,contact,".
+ "location,notes) values ($hostid,".zbx_dbstr($devicetype).",".zbx_dbstr($name).",".
+ zbx_dbstr($os).",".zbx_dbstr($serialno).",".zbx_dbstr($tag).",".zbx_dbstr($macaddress).
+ ",".zbx_dbstr($hardware).",".zbx_dbstr($software).",".zbx_dbstr($contact).",".
+ zbx_dbstr($location).",".zbx_dbstr($notes).")");
return $result;
}
@@ -78,8 +58,7 @@
error("Insufficient permissions");
return 0;
}
- $sql="delete from hosts_profiles where hostid=$hostid";
- $result=DBexecute($sql);
+ $result=DBexecute("delete from hosts_profiles where hostid=$hostid");
return $result;
}
diff --git a/frontends/php/include/services.inc.php b/frontends/php/include/services.inc.php
index 60990702..c5a36eed 100644
--- a/frontends/php/include/services.inc.php
+++ b/frontends/php/include/services.inc.php
@@ -312,15 +312,15 @@
}
elseif($status==4)
{
- $desc="<font color=\"#FF8888\">Serious&nbsp;problem</a>";
+ $desc="<font color=\"#FF8888\">Serious".SPACE."problem</a>";
}
elseif($status==3)
{
- $desc="<font color=\"#AA0000\">Average&nbsp;problem</a>";
+ $desc="<font color=\"#AA0000\">Average".SPACE."problem</a>";
}
elseif($status==2)
{
- $desc="<font color=\"#AA5555\">Minor&nbsp;problem</a>";
+ $desc="<font color=\"#AA5555\">Minor".SPACE."problem</a>";
}
elseif($status==1)
{
diff --git a/frontends/php/items.php b/frontends/php/items.php
index 5f18a025..282d0c93 100644
--- a/frontends/php/items.php
+++ b/frontends/php/items.php
@@ -43,7 +43,7 @@
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
"groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL),
- "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,'isset({save})'),
+ "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,'isset({form})'),
"add_groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,'{register}=="go"'),
"action"=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,'{register}=="go"'),
@@ -51,7 +51,6 @@
"itemid"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID,'{form}=="update"'),
"description"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,'isset({save})'),
"key"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,'isset({save})'),
- "host"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,'isset({save})'),
"delay"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'isset({save})&&{type}!=2'),
"history"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'isset({save})'),
"status"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'isset({save})'),
@@ -101,9 +100,7 @@
$result = 0;
if(isset($_REQUEST["delete"])&&isset($_REQUEST["itemid"]))
{
- delete_item_from_templates($_REQUEST["itemid"]);
-
- $result=delete_item($_REQUEST["itemid"]);
+ $result = delete_item($_REQUEST["itemid"]);
show_messages($result, S_ITEM_DELETED, S_CANNOT_DELETE_ITEM);
if($result){
unset($_REQUEST["itemid"]);
@@ -114,16 +111,6 @@
{
if(isset($_REQUEST["itemid"]))
{
- $result=update_item_in_templates($_REQUEST["itemid"],
- $_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],
- $_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],
- $_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],
- $_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],
- $_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],
- $_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],
- $_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],
- $_REQUEST["logtimefmt"]);
-
$result=update_item($_REQUEST["itemid"],
$_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],
$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],
@@ -148,7 +135,6 @@
$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],
$_REQUEST["logtimefmt"]);
- add_item_to_linked_hosts($itemid);
$result = $itemid;
show_messages($result, S_ITEM_ADDED, S_CANNOT_ADD_ITEM);
}
@@ -247,7 +233,8 @@
$group_itemid = $_REQUEST["group_itemid"];
foreach($group_itemid as $id)
{
- delete_item_from_templates($id);
+ $item = get_item_by_itemid($id);
+ if($item["templateid"]<>0) continue;
$result2=delete_item($id);
}
show_messages(TRUE, S_ITEMS_DELETED, S_CANNOT_DELETE_ITEMS);
@@ -278,8 +265,11 @@
$db_hosts=DBselect("select hostid from hosts");
if(isset($_REQUEST["form"])&&isset($_REQUEST["hostid"])&&DBnum_rows($db_hosts)>0)
{
+// FORM
insert_item_form();
} else {
+
+// Table HEADER
$form = new CForm();
$_REQUEST["groupid"] = get_request("groupid",0);
@@ -342,107 +332,113 @@
$form->AddItem(new CButton("form",S_CREATE_ITEM));
show_header2(S_CONFIGURATION_OF_ITEMS_BIG, $form);
- ?>
-
- <?php
- if(isset($_REQUEST["hostid"]))
+// TABLE
+ $form = new CForm('items.php');
+ $form->SetName('items');
+ $form->AddVar('hostid',$_REQUEST["hostid"]);
+
+ $table = new CTableInfo();
+ $table->setHeader(array(
+ array( new CCheckBox("all_items",NULL,NULL,
+ "CheckAll('".$form->GetName()."','all_items');"),
+ S_ID),
+ S_DESCRIPTION,S_KEY,nbsp(S_UPDATE_INTERVAL),
+ S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR));
+
+ $db_items = DBselect("select i.* from hosts h,items i where h.hostid=i.hostid and".
+ " h.hostid=".$_REQUEST["hostid"]." order by i.description, i.key_");
+ while($db_item = DBfetch($db_items))
{
- $form = new CForm('items.php');
- $form->SetName('items');
- $form->AddVar('hostid',$_REQUEST["hostid"]);
-
- $table = new CTableInfo();
- $table->setHeader(array(
- array( new CCheckBox("all_items",NULL,NULL,
- "CheckAll('".$form->GetName()."','all_items');"),
- S_ID),
- S_DESCRIPTION,S_KEY,nbsp(S_UPDATE_INTERVAL),
- S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR));
-
- $result=DBselect("select h.host,i.key_,i.itemid,i.description,i.delay,".
- "i.history,i.lastvalue,i.lastclock,i.status,i.nextcheck,h.hostid,i.type,".
- "i.trends,i.error from hosts h,items i where h.hostid=i.hostid and".
- " h.hostid=".$_REQUEST["hostid"]." order by i.description, i.key_");
- while($row=DBfetch($result))
+ if(!check_right("Item","R",$db_item["itemid"]))
{
- if(!check_right("Item","R",$row["itemid"]))
- {
- continue;
- }
-
-
- switch($row["type"]){
- case 0: $type = S_ZABBIX_AGENT; break;
- case 7: $type = S_ZABBIX_AGENT_ACTIVE; 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 6: $type = S_SNMPV3_AGENT; break;
- case 5: $type = S_ZABBIX_INTERNAL; break;
- default:$type = S_UNKNOWN; break;
- }
+ continue;
+ }
- switch($row["status"]){
- case 0: $status=new CCol(new CLink(S_ACTIVE,
- "items.php?group_itemid%5B%5D=".$row["itemid"].
- "&hostid=".$_REQUEST["hostid"].
- "&group_task=Disable+selected",
- "off"),"off");
- break;
- case 1: $status=new CCol(new CLink(S_DISABLED,
- "items.php?group_itemid%5B%5D=".$row["itemid"].
- "&hostid=".$_REQUEST["hostid"].
- "&group_task=Activate+selected",
- "on"),"on");
- break;
- case 3: $status=new CCol(S_NOT_SUPPORTED,"unknown");
- break;
- default:$status=S_UNKNOWN;
- }
-
- if($row["error"] == "")
- {
- $error=new CCol("&nbsp;","off");
- }
- else
- {
- $error=new CCol($row["error"],"on");
- }
- $table->AddRow(array(
- array(
- new CCheckBox("group_itemid[]",NULL,NULL,NULL,$row["itemid"]),
- $row["itemid"]
- ),
- new CLink($row["description"],"items.php?form=update&itemid=".
- $row["itemid"].url_param("hostid").url_param("groupid"),
+ if($db_item["templateid"]==0)
+ {
+ $description = new CLink($db_item["description"],"items.php?form=update&itemid=".
+ $db_item["itemid"].url_param("hostid").url_param("groupid"),
+ 'action');
+ } else {
+ $template_host = get_realhost_by_itemid($db_item["templateid"]);
+ $description = array(
+ new CLink($template_host["host"],"items.php?".
+ "hostid=".$template_host["hostid"],
'action'),
- $row["key_"],
- $row["delay"],
- $row["history"],
- $row["trends"],
- $type,
- $status,
- $error
- ));
+ ":",
+ $db_item["description"]
+ );
+ }
+
+ switch($db_item["type"]){
+ case 0: $type = S_ZABBIX_AGENT; break;
+ case 7: $type = S_ZABBIX_AGENT_ACTIVE; 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 6: $type = S_SNMPV3_AGENT; break;
+ case 5: $type = S_ZABBIX_INTERNAL; break;
+ default:$type = S_UNKNOWN; break;
}
- $footerButtons = array();
- array_push($footerButtons, new CButton('group_task','Activate selected',
- "return Confirm('".S_ACTIVATE_SELECTED_ITEMS_Q."');"));
- array_push($footerButtons, SPACE);
- array_push($footerButtons, new CButton('group_task','Disable selected',
- "return Confirm('".S_DISABLE_SELECTED_ITEMS_Q."');"));
- array_push($footerButtons, SPACE);
- array_push($footerButtons, new CButton('group_task','Delete selected',
- "return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');"));
- $table->SetFooter(new CCol($footerButtons),'table_footer');
-
- $form->AddItem($table);
- $form->Show();
+ switch($db_item["status"]){
+ case 0: $status=new CCol(new CLink(S_ACTIVE,
+ "items.php?group_itemid%5B%5D=".$db_item["itemid"].
+ "&hostid=".$_REQUEST["hostid"].
+ "&group_task=Disable+selected",
+ "off"),"off");
+ break;
+ case 1: $status=new CCol(new CLink(S_DISABLED,
+ "items.php?group_itemid%5B%5D=".$db_item["itemid"].
+ "&hostid=".$_REQUEST["hostid"].
+ "&group_task=Activate+selected",
+ "on"),"on");
+ break;
+ case 3: $status=new CCol(S_NOT_SUPPORTED,"unknown");
+ break;
+ default:$status=S_UNKNOWN;
+ }
+
+ if($db_item["error"] == "")
+ {
+ $error=new CCol(SPACE,"off");
+ }
+ else
+ {
+ $error=new CCol($db_item["error"],"on");
+ }
+ $table->AddRow(array(
+ array(
+ new CCheckBox("group_itemid[]",NULL,NULL,NULL,$db_item["itemid"]),
+ $db_item["itemid"]
+ ),
+ $description,
+ $db_item["key_"],
+ $db_item["delay"],
+ $db_item["history"],
+ $db_item["trends"],
+ $type,
+ $status,
+ $error
+ ));
}
+ $footerButtons = array();
+ array_push($footerButtons, new CButton('group_task','Activate selected',
+ "return Confirm('".S_ACTIVATE_SELECTED_ITEMS_Q."');"));
+ array_push($footerButtons, SPACE);
+ array_push($footerButtons, new CButton('group_task','Disable selected',
+ "return Confirm('".S_DISABLE_SELECTED_ITEMS_Q."');"));
+ array_push($footerButtons, SPACE);
+ array_push($footerButtons, new CButton('group_task','Delete selected',
+ "return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');"));
+ $table->SetFooter(new CCol($footerButtons),'table_footer');
+
+ $form->AddItem($table);
+ $form->Show();
+
}
?>
<?php
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index 8b2e577c..e60080d8 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -74,9 +74,9 @@
?>
<?php
- $h1="&nbsp;".S_LATEST_DATA_BIG;
+ $h1=SPACE.S_LATEST_DATA_BIG;
- $h2=S_GROUP."&nbsp;";
+ $h2=S_GROUP.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
$h2=$h2.form_select("groupid",0,S_ALL_SMALL);
$result=DBselect("select groupid,name from groups order by name");
@@ -100,7 +100,7 @@
}
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_HOST."&nbsp;";
+ $h2=$h2.SPACE.S_HOST.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
$h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
diff --git a/frontends/php/overview.php b/frontends/php/overview.php
index b48618d5..cf1996b5 100644
--- a/frontends/php/overview.php
+++ b/frontends/php/overview.php
@@ -71,9 +71,9 @@
?>
<?php
- $h1="&nbsp;".S_OVERVIEW_BIG;
+ $h1=SPACE.S_OVERVIEW_BIG;
- $h2=S_GROUP."&nbsp;";
+ $h2=S_GROUP.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
$h2=$h2.form_select("groupid",0,S_SELECT_GROUP_DOT_DOT_DOT);
$result=DBselect("select groupid,name from groups order by name");
@@ -97,7 +97,7 @@
}
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_TYPE."&nbsp;";
+ $h2=$h2.SPACE.S_TYPE.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"type\" onChange=\"submit()\">";
$h2=$h2.form_select("type",0,S_TRIGGERS);
$h2=$h2.form_select("type",1,S_DATA);
@@ -115,7 +115,7 @@
if(isset($_REQUEST["groupid"])&&isset($_REQUEST["type"])&&($_REQUEST["type"]==SHOW_DATA))
{
$table = new CTableInfo();
- $header=array("&nbsp;");
+ $header=array(SPACE);
$hosts=array();
$sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host";
$result=DBselect($sql);
@@ -193,7 +193,7 @@
else if(isset($_REQUEST["groupid"])&&isset($_REQUEST["type"])&&($_REQUEST["type"]==SHOW_TRIGGERS))
{
$table = new CTableInfo();
- $header=array("&nbsp;");
+ $header=array(SPACE);
$hosts=array();
$sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg,functions f,triggers t where h.status=".HOST_STATUS_MONITORED." and t.status=".TRIGGER_STATUS_ENABLED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and t.triggerid=f.triggerid and f.itemid=i.itemid group by h.hostid,h.host order by h.host";
$result=DBselect($sql);
@@ -233,26 +233,19 @@
{
$sql="select t.status,t.value,t.lastchange from triggers t,functions f,items i where f.triggerid=t.triggerid and i.itemid=f.itemid and t.status=".TRIGGER_STATUS_ENABLED." and i.hostid=$hostid and t.description=".zbx_dbstr($row["description"]);
$result2=DBselect($sql);
+ $value=SPACE;
if(DBnum_rows($result2)==1)
{
$row2=DBfetch($result2);
if($row2["status"]==0)
{
if($row2["value"] == TRIGGER_VALUE_FALSE)
- $value=new CCol("&nbsp;","normal");
+ $value=new CCol(SPACE,"normal");
else if($row2["value"] == TRIGGER_VALUE_UNKNOWN)
- $value=new CCol("&nbsp;","unknown_trigger");
+ $value=new CCol(SPACE,"unknown_trigger");
else
- $value=new CCol("&nbsp;","high");
+ $value=new CCol(SPACE,"high");
}
- else
- {
- $value="&nbsp;";
- }
- }
- else
- {
- $value="&nbsp;";
}
$rows=array_merge($rows,array($value));
}
diff --git a/frontends/php/popup.php b/frontends/php/popup.php
index db304872..9e3e4f8d 100644
--- a/frontends/php/popup.php
+++ b/frontends/php/popup.php
@@ -38,12 +38,12 @@
<?php
- $h1="&nbsp;".S_HOSTS_BIG;
+ $h1=SPACE.S_HOSTS_BIG;
// $h2_form1="<form name=\"form2\" method=\"get\" action=\"popup.php\">";
- $h2=S_GROUP."&nbsp;";
+ $h2=S_GROUP.SPACE;
$h2=$h2."<input name=\"form\" type=\"hidden\" value=".$_REQUEST["form"].">";
$h2=$h2."<input name=\"field1\" type=\"hidden\" value=".$_REQUEST["field1"].">";
$h2=$h2."<input name=\"field2\" type=\"hidden\" value=".$_REQUEST["field2"].">";
diff --git a/frontends/php/queue.php b/frontends/php/queue.php
index a1815cb4..b3eaec82 100644
--- a/frontends/php/queue.php
+++ b/frontends/php/queue.php
@@ -52,7 +52,7 @@
$h1=S_QUEUE_OF_ITEMS_TO_BE_UPDATED_BIG;
-# $h2=S_GROUP."&nbsp;";
+# $h2=S_GROUP.SPACE;
$h2="";
$h2=$h2."<select class=\"biginput\" name=\"show\" onChange=\"submit()\">";
$h2=$h2.form_select("show",0,S_OVERVIEW);
diff --git a/frontends/php/report2.php b/frontends/php/report2.php
index 96cf6020..8911c461 100644
--- a/frontends/php/report2.php
+++ b/frontends/php/report2.php
@@ -50,9 +50,9 @@
?>
<?php
- $h1="&nbsp;".S_AVAILABILITY_REPORT_BIG;
+ $h1=SPACE.S_AVAILABILITY_REPORT_BIG;
- $h2=S_GROUP."&nbsp;";
+ $h2=S_GROUP.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
$h2=$h2.form_select("groupid",0,S_ALL_SMALL);
$result=DBselect("select groupid,name from groups order by name");
@@ -76,7 +76,7 @@
}
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_HOST."&nbsp;";
+ $h2=$h2.SPACE.S_HOST.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
$h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
diff --git a/frontends/php/report3.php b/frontends/php/report3.php
index 6c1fc8ce..0140d4c2 100644
--- a/frontends/php/report3.php
+++ b/frontends/php/report3.php
@@ -53,8 +53,8 @@
$h1=S_IT_SERVICES_AVAILABILITY_REPORT_BIG;
$h1=$h1.":"."<a href=\"srv_status.php?serviceid=".$service["serviceid"]."\">".$service["name"]."</a>";
-# $h2=S_GROUP."&nbsp;";
- $h2=S_YEAR."&nbsp;";
+# $h2=S_GROUP.SPACE;
+ $h2=S_YEAR.SPACE;
$h2=$h2."<input name=\"serviceid\" type=\"hidden\" value=".$_REQUEST["serviceid"].">";
$h2=$h2."<select class=\"biginput\" name=\"year\" onChange=\"submit()\">";
$result=DBselect("select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid group by h.hostid,h.host order by h.host");
@@ -66,7 +66,7 @@
}
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_PERIOD."&nbsp;";
+ $h2=$h2.SPACE.S_PERIOD.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"period\" onChange=\"submit()\">";
$h2=$h2.form_select("period","daily",S_DAILY);
$h2=$h2.form_select("period","weekly",S_WEEKLY);
diff --git a/frontends/php/services.php b/frontends/php/services.php
index 50976b8f..35168d54 100644
--- a/frontends/php/services.php
+++ b/frontends/php/services.php
@@ -378,7 +378,7 @@
$h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
}
}
- $h2=$h2."</select>&nbsp;";
+ $h2=$h2."</select>".SPACE;
$h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
$h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
@@ -401,13 +401,13 @@
}
$h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
}
- $h2=$h2."</select>&nbsp;";
+ $h2=$h2."</select>".SPACE;
echo $h2;
if(isset($_REQUEST["hostid"]))
{
show_table2_v_delimiter($col++);
- echo "&nbsp;";
+ echo SPACE;
show_table2_h_delimiter();
$result=DBselect("select t.triggerid,t.description from triggers t,functions f, hosts h, items i where h.hostid=i.hostid and f.itemid=i.itemid and t.triggerid=f.triggerid and h.hostid=".$_REQUEST["hostid"]." order by t.description");
echo "<select class=\"biginput\" name=\"triggerid\" size=1>";
diff --git a/frontends/php/srv_status.php b/frontends/php/srv_status.php
index f0ec84ab..61f46001 100644
--- a/frontends/php/srv_status.php
+++ b/frontends/php/srv_status.php
@@ -63,7 +63,7 @@
$status=get_service_status_description($service["status"]);
- $reason="&nbsp;";
+ $reason=SPACE;
if($service["showsla"]==1)
{
$sla="<img src=\"chart_sla.php?serviceid=".$service["serviceid"]."\">";
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index 97d93381..d357c3d3 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -186,12 +186,12 @@
?>
<?php
- $h1="&nbsp;".S_STATUS_OF_TRIGGERS_BIG;
+ $h1=SPACE.S_STATUS_OF_TRIGGERS_BIG;
$h2="";
$h2=$h2."<input name=\"onlytrue\" type=\"hidden\" value=\"".$_REQUEST["onlytrue"]."\">";
$h2=$h2."<input name=\"noactions\" type=\"hidden\" value=\"".$_REQUEST["noactions"]."\">";
- $h2=$h2.S_GROUP."&nbsp;";
+ $h2=$h2.S_GROUP.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
$h2=$h2.form_select("groupid",0,S_ALL_SMALL);
@@ -216,7 +216,7 @@
}
$h2=$h2."</select>";
- $h2=$h2."&nbsp;".S_HOST."&nbsp;";
+ $h2=$h2.SPACE.S_HOST.SPACE;
$h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
$h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php
index b6f4eef7..b82691a7 100644
--- a/frontends/php/triggers.php
+++ b/frontends/php/triggers.php
@@ -315,7 +315,7 @@
$result1=DBselect($sql);
if(DBnum_rows($result1)>0)
{
- array_push($description,BR.BR."<strong>".S_DEPENDS_ON."</strong>:&nbsp;".BR);
+ array_push($description,BR.BR."<strong>".S_DEPENDS_ON."</strong>".SPACE.BR);
while($row1=DBfetch($result1))
{
array_push($description,expand_trigger_description($row1["triggerid"]).BR);
@@ -353,9 +353,9 @@
'enabled');
}
- if($row["status"] != TRIGGER_STATUS_UNKNOWN) $row["error"]="&nbsp;";
+ if($row["status"] != TRIGGER_STATUS_UNKNOWN) $row["error"]=SPACE;
- if($row["error"]=="") $row["error"]="&nbsp;";
+ if($row["error"]=="") $row["error"]=SPACE;
$table->addRow(array(
$id,
diff --git a/src/libs/zbxsysinfo/osf/proc.c b/src/libs/zbxsysinfo/osf/proc.c
index 0166b8a3..73ba9658 100644
--- a/src/libs/zbxsysinfo/osf/proc.c
+++ b/src/libs/zbxsysinfo/osf/proc.c
@@ -295,6 +295,8 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
char usrname[MAX_STRING_LEN];
char procstat[MAX_STRING_LEN];
+ struct passwd *usrinfo = NULL;
+
assert(result);
init_result(result);
@@ -328,10 +330,16 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
}
else
{
+ usrinfo = getpwnam(line);
+ if(usrinfo == NULL)
+ {
+ /* incorrect user name */
+ return SYSINFO_RET_FAIL;
+ }
if(procname[0]=='\0')
- snprintf(usrname,MAX_STRING_LEN-1,"$2==\"%s\"",line);
+ snprintf(usrname,MAX_STRING_LEN-1,"$2==\"%u\"",usrinfo->uid_t);
else
- snprintf(usrname,MAX_STRING_LEN-1,"&&$2==\"%s\"",line);
+ snprintf(usrname,MAX_STRING_LEN-1,"&&$2==\"%u\"",usrinfo->uid_t);
}
if(get_param(param, 3, procstat, MAX_STRING_LEN) != 0)
@@ -399,7 +407,7 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
snprintf(proccomm,MAX_STRING_LEN-1,"c=$4;for(i=5;i<=NF;i++)c=c" "$i;if(match(c,\"%s\")==0)next;",line);
}
- snprintf(line, MAX_STRING_LEN-1,"ps -eostate,user,comm,args|tail -n+2|cut -b1,5-|awk 'BEGIN{j=0}%s%s%s{%sj++}END{print j}'",procname,usrname,procstat,proccomm);
+ snprintf(line, MAX_STRING_LEN-1,"ps -eostate,uid,comm,args|tail -n+2|cut -b1,5-|awk 'BEGIN{j=0}%s%s%s{%sj++}END{print j}'",procname,usrname,procstat,proccomm);
return EXECUTE(cmd, line, flags, result);