Zabbix Devs,
I find it very useful to see more than one graph at a time so I went to go create a patch that would add 'All' to the graph drop down which would allow you to view all of the graphs for a host. While I thought this would be real simple, the form validation kept getting in the way because it converts $_REQUEST["graphid"] to zero whenever an invalid graphid is used. Furthermore, graphid 0 seems to be the default and thus is already used by the app.
To work around the validation I used graphid 0.1 as the graphid for displaying all of the graphs, but that foces me to use $_GET instead of $_REQUEST in one part of the app. Now this shouldn't cause a security problem because it is never used in a SQL query, it is still a hack.
Anyway, can someone look at my patch and tell me what the zabbix way of doing this is?
diff -ruN zabbix.orig/charts.php zabbix/charts.php
--- zabbix.orig/charts.php 2006-06-06 10:20:41.000000000 -0800
+++ zabbix/charts.php 2006-06-06 11:41:37.000000000 -0800
@@ -162,6 +162,7 @@
$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);
+ $h2=$h2.form_select("graphid",0.1,S_SELECT_GRAPH_A LL);
if($_REQUEST["hostid"] > 0)
{
@@ -201,7 +202,18 @@
echo "<TABLE BORDER=0 align=center COLS=4 WIDTH=100% BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
echo "<TR BGCOLOR=#DDDDDD>";
echo "<TD ALIGN=CENTER>";
- if($_REQUEST["graphid"] > 0)
+ if($_GET["graphid"] == 0.1)
+ {
+ echo "<script language=\"JavaScript\">";
+ $result=DBselect("select distinct gi.graphid as graphid from items i, graphs_items gi where gi.itemid = i.itemid and hostid=".$_REQUEST["hostid"]);
+ while($row=DBfetch($result))
+ {
+ echo "document.write(\"<IMG SRC='chart2.php?graphid=".$row["graphid"].url_param("stime")."&period=".$effectiveperiod."& from=".$_REQUEST["from"]."&width=\"+(document.width-108)+\"'><p>\");";
+ }
+ echo "</script>";
+ navigation_bar("charts.php");
+ }
+ elseif($_REQUEST["graphid"] > 0)
{
echo "<script language=\"JavaScript\">";
echo "document.write(\"<IMG SRC='chart2.php?graphid=".$_REQUEST["graphid"].url_param("stime")."&period=".$effectiveperiod."& from=".$_REQUEST["from"]."&width=\"+(document.width-108)+\"'>\")";
diff -ruN zabbix.orig/include/locales/en_gb.inc.php zabbix/include/locales/en_gb.inc.php
--- zabbix.orig/include/locales/en_gb.inc.php 2006-05-25 08:02:17.000000000 -0800
+++ zabbix/include/locales/en_gb.inc.php 2006-06-06 11:35:18.000000000 -0800
@@ -157,6 +157,7 @@
"S_RIGHT_DIR"=> "Right",
"S_LEFT_DIR"=> "Left",
"S_SELECT_GRAPH_DOT_DOT_DOT"=> "Select graph...",
+ "S_SELECT_GRAPH_ALL"=> "All",
// Colors
"S_BLACK"=> "Black",
I find it very useful to see more than one graph at a time so I went to go create a patch that would add 'All' to the graph drop down which would allow you to view all of the graphs for a host. While I thought this would be real simple, the form validation kept getting in the way because it converts $_REQUEST["graphid"] to zero whenever an invalid graphid is used. Furthermore, graphid 0 seems to be the default and thus is already used by the app.
To work around the validation I used graphid 0.1 as the graphid for displaying all of the graphs, but that foces me to use $_GET instead of $_REQUEST in one part of the app. Now this shouldn't cause a security problem because it is never used in a SQL query, it is still a hack.
Anyway, can someone look at my patch and tell me what the zabbix way of doing this is?
diff -ruN zabbix.orig/charts.php zabbix/charts.php
--- zabbix.orig/charts.php 2006-06-06 10:20:41.000000000 -0800
+++ zabbix/charts.php 2006-06-06 11:41:37.000000000 -0800
@@ -162,6 +162,7 @@
$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);
+ $h2=$h2.form_select("graphid",0.1,S_SELECT_GRAPH_A LL);
if($_REQUEST["hostid"] > 0)
{
@@ -201,7 +202,18 @@
echo "<TABLE BORDER=0 align=center COLS=4 WIDTH=100% BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
echo "<TR BGCOLOR=#DDDDDD>";
echo "<TD ALIGN=CENTER>";
- if($_REQUEST["graphid"] > 0)
+ if($_GET["graphid"] == 0.1)
+ {
+ echo "<script language=\"JavaScript\">";
+ $result=DBselect("select distinct gi.graphid as graphid from items i, graphs_items gi where gi.itemid = i.itemid and hostid=".$_REQUEST["hostid"]);
+ while($row=DBfetch($result))
+ {
+ echo "document.write(\"<IMG SRC='chart2.php?graphid=".$row["graphid"].url_param("stime")."&period=".$effectiveperiod."& from=".$_REQUEST["from"]."&width=\"+(document.width-108)+\"'><p>\");";
+ }
+ echo "</script>";
+ navigation_bar("charts.php");
+ }
+ elseif($_REQUEST["graphid"] > 0)
{
echo "<script language=\"JavaScript\">";
echo "document.write(\"<IMG SRC='chart2.php?graphid=".$_REQUEST["graphid"].url_param("stime")."&period=".$effectiveperiod."& from=".$_REQUEST["from"]."&width=\"+(document.width-108)+\"'>\")";
diff -ruN zabbix.orig/include/locales/en_gb.inc.php zabbix/include/locales/en_gb.inc.php
--- zabbix.orig/include/locales/en_gb.inc.php 2006-05-25 08:02:17.000000000 -0800
+++ zabbix/include/locales/en_gb.inc.php 2006-06-06 11:35:18.000000000 -0800
@@ -157,6 +157,7 @@
"S_RIGHT_DIR"=> "Right",
"S_LEFT_DIR"=> "Left",
"S_SELECT_GRAPH_DOT_DOT_DOT"=> "Select graph...",
+ "S_SELECT_GRAPH_ALL"=> "All",
// Colors
"S_BLACK"=> "Black",
Comment