summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-02-07 10:20:58 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-02-07 10:20:58 +0000
commit8c292c56d192df144c551477b1cfda4e361084f3 (patch)
tree39f3a6c1806979086d86fa1b4fb5e464f7d88a2b /frontends/php/include
parent7d441a8c961a3042f389be4c745c85dff0254e19 (diff)
- fixed synchronisation of template graphs when using a template (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2619 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/config.inc.php3
-rw-r--r--frontends/php/include/forms.inc.php2
-rw-r--r--frontends/php/include/graphs.inc.php53
-rw-r--r--frontends/php/include/locales/en_gb.inc.php3
4 files changed, 53 insertions, 8 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index cc7a6d26..cf3318c7 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -1763,8 +1763,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } # DEBUG INFO!!!
$result=DBselect($sql);
while($row=DBfetch($result))
{
-// Hmm WHere is this function?
-// add_graph_item_to_linked_hosts($row["gitemid"],$hostid);
+ add_graph_item_to_linked_hosts($row["gitemid"],$hostid);
}
return TRUE;
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 01e2729d..f5f7be34 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -1852,7 +1852,7 @@
{
$cmbHosts->AddItem($host["hostid"],$host["host"]);
}
- $frmHost->AddRow(S_LINK_WITH_HOST,$cmbHosts);
+ $frmHost->AddRow(S_USE_TEMPLATES_OF_THIS_HOST,$cmbHosts);
$frmHost->AddRow(S_USE_PROFILE,new CCheckBox("useprofile",$useprofile,NULL,"submit()"));
if($useprofile=="yes")
diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php
index f60a8838..8418c297 100644
--- a/frontends/php/include/graphs.inc.php
+++ b/frontends/php/include/graphs.inc.php
@@ -268,7 +268,7 @@
add_item_to_graph($graph["graphid"],$item["itemid"],$color,$drawtype,$sortorder,$yaxisside);
$host_info=get_host_by_hostid($host["hostid"]);
info("Added item to graph '".$graph["name"]."' from linked host '".$host_info["host"]."'");
- remove_durpblicated_graphs($graph["graphid"]);
+ remove_duplicated_graphs($graph["graphid"]);
$find_graph=1;
}
@@ -287,7 +287,7 @@
$new_graph=get_graph_by_graphid($new_graphid);
$host_info=get_host_by_hostid($host["hostid"]);
info("Graph ".$new_graph["name"]." coped for linked host ".$host_info["host"]);
- remove_durpblicated_graphs($new_graphid);
+ remove_duplicated_graphs($new_graphid);
}
}
}
@@ -745,7 +745,7 @@
return TRUE;
}
- function remove_durpblicated_graphs($graphid=0)
+ function remove_duplicated_graphs($graphid=0)
{
$sql="select graphid from graphs";
if($graphid!=0)
@@ -772,4 +772,51 @@
}
}
+ function add_graph_item_to_linked_hosts($gitemid,$hostid=0)
+ {
+ if($gitemid<=0)
+ {
+ return;
+ }
+
+ $graph_item=get_graphitem_by_gitemid($gitemid);
+ $graph=get_graph_by_graphid($graph_item["graphid"]);
+ $item=get_item_by_itemid($graph_item["itemid"]);
+
+ if($hostid==0)
+ {
+ $sql="select hostid,templateid,graphs from hosts_templates where templateid=".$item["hostid"];
+ }
+ else
+ {
+ $sql="select hostid,templateid,graphs from hosts_templates where hostid=$hostid and templateid=".$item["hostid"];
+ }
+ $result=DBselect($sql);
+ while($row=DBfetch($result))
+ {
+ if($row["graphs"]&1 == 0) continue;
+
+ $sql="select i.itemid from items i where i.key_='".zbx_ads($item["key_"])."' and i.hostid=".$row["hostid"];
+ $result2=DBselect($sql);
+ if(DBnum_rows($result2)==0) continue;
+ $row2=DBfetch($result2);
+ $itemid=$row2["itemid"];
+
+ $sql="select distinct g.graphid from graphs g,graphs_items gi,items i where i.itemid=gi.itemid and i.hostid=".$row["hostid"]." and g.graphid=gi.graphid and g.name='".zbx_ads($graph["name"])."'";
+ $result2=DBselect($sql);
+ $host=get_host_by_hostid($row["hostid"]);
+ while($row2=DBfetch($result2))
+ {
+ add_item_to_graph($row2["graphid"],$itemid,$graph_item["color"],$graph_item["drawtype"],$graph_item["sortorder"],$graph_item["yaxisside"]);
+ info("Added graph element to graph ".$graph["name"]." of linked host ".$host["host"]);
+ }
+ if(DBnum_rows($result2)==0)
+ {
+ $graphid=add_graph($graph["name"],$graph["width"],$graph["height"],$graph["yaxistype"],$graph["yaxismin"],$graph["yaxismax"]);
+ info("Added graph ".$graph["name"]." of linked host ".$host["host"]);
+ add_item_to_graph($graphid,$itemid,$graph_item["color"],$graph_item["drawtype"],$graph_item["sortorder"],$graph_item["yaxisside"]);
+ info("Added graph element to graph ".$graph["name"]." of linked host ".$host["host"]);
+ }
+ }
+ }
?>
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 72944c65..0a9c47c6 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -342,8 +342,7 @@
"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_LINK_WITH_HOST"=> "Link with host",
+ "S_USE_TEMPLATES_OF_THIS_HOST"=> "Use templates of this host",
"S_USE_PROFILE"=> "Use profile",
"S_DELETE_SELECTED_HOST_Q"=> "Delete selected host?",
"S_DELETE_SELECTED_GROUP_Q"=> "Delete selected group?",