Hi all,
I've finally finished implementing an interface for generating
customized graphs.
A patch against Ganglia 3.0.2 is attached (it should probably work with
3.0.3 as well). You can also grab it at http://wtf.ath.cx/custom_graph.diff
I suspect IE won't like the JavaScript in this one, but I didn't really
dig into that.
Feedback is most welcome!
Cheers,
Alex
diff -urN ganglia/custom_graph_interface.php ganglia.new/custom_graph_interface.php
--- ganglia/custom_graph_interface.php 1970-01-01 02:00:00.000000000 +0200
+++ ganglia.new/custom_graph_interface.php 2006-04-18 23:04:24.000000000 +0300
@@ -0,0 +1,457 @@
+
+<html>
+<body>
+
+ <script language="JavaScript">
+ function resubmit() {
+ document.myform.action="custom_graph_interface.php";
+ document.myform.submit();
+ }
+ function process() {
+ document.myform.action="custom_graph_processing.php";
+ document.myform.submit();
+ }
+ </script>
+
+ <form name="myform" action="custom_graph_processing.php" method="get">
+ <input type="hidden" name="action" value="custom_graph_interface">
+
+<?php
+
+#
+# The hard limit of 1000 logical metrics is totally random
+#
+$max_logical_metrics = 1000;
+$default_line_thickness = 2;
+
+#
+# Get directory containing RRDs
+#
+if (!empty($_GET['rrd_dir']))
+ $directory = escapeshellcmd(rawurldecode($_GET['rrd_dir']));
+else {
+ echo "Could not obtain directory containing RRDs.";
+ exit;
+}
+
+
+function table_entry($metric) {
+
+ global $max_logical_metrics;
+ global $default_line_thickness;
+
+ #
+ # Metric name
+ #
+ if (stristr($metric, "logical_metric_")) {
+ echo "<td>\n";
+ #
+ # logical_metric_0 is used for newly added values only
+ # if that's our $metric value, we need to reassign it to an empty
+ # slot in the logical_metric_$domain
+ #
+ if ($metric == "logical_metric_0") {
+ for ($i = 1; $i < $max_logical_metrics; $i++) {
+ if (empty($_GET["logical_metric_" ."$i"])) {
+ $logical_metric_num = $i;
+ break;
+ }
+ }
+ echo "<input type=\"checkbox\" checked=\"checked\" name=\"logical_metric_" ."$logical_metric_num\">\n";
+ echo "<input type=\"text\" name=\"logical_metric_" ."$logical_metric_num" ."_name\" value=\"logical_metric\">\n";
+ }
+ else {
+ echo "<input type=\"checkbox\" checked=\"checked\" name=\"$metric\">\n";
+ $metric_name = $_GET["$metric" ."_name"];
+ echo "<input type=\"text\" name=\"$metric" ."_name\" value=\"$metric_name\">\n";
+ }
+ echo "</td>\n";
+ }
+ else
+ echo "<td><input type=\"checkbox\" checked=\"checked\" name=\"$metric\">$metric</td>\n";
+ #
+ # Line thickness
+ #
+ echo "<td>\n";
+ if (stristr($metric, "logical_metric_") && $metric == "logical_metric_0")
+ echo "<select name=\"logical_metric_" ."$logical_metric_num" ."_line_thickness\">\n";
+ else
+ echo "<select name=\"$metric" ."_line_thickness\">\n";
+ if (isset($_GET["$metric" ."_line_thickness"])) {
+ $option_selected = "option_" .$_GET["$metric" ."_line_thickness"] ."_selected";
+ $$option_selected = "selected";
+ }
+ else {
+ $option_selected = "option_" ."$default_line_thickness" ."_selected";
+ $$option_selected = "selected";
+ }
+ echo "<option value=\"0\" $option_0_selected>none\n";
+ echo "<option value=\"1\" $option_1_selected>1\n";
+ echo "<option value=\"2\" $option_2_selected>2\n";
+ echo "<option value=\"3\" $option_3_selected>3\n";
+ unset ($$option_selected);
+ echo "</select>\n";
+ echo "</td>\n";
+ #
+ # Line color
+ #
+ echo "<td>\n";
+ if (stristr($metric, "logical_metric_") && $metric == "logical_metric_0")
+ color_dropdown(line_color, $metric, $logical_metric_num);
+ else
+ color_dropdown(line_color, $metric);
+ echo "</td>\n";
+ #
+ # Fill area
+ #
+ echo "<td>\n";
+ if (stristr($metric, "logical_metric_") && $metric == "logical_metric_0")
+ echo "<select name=\"logical_metric_" ."$logical_metric_num" ."_fill_area\">\n";
+ else
+ echo "<select name=\"$metric" ."_fill_area\">\n";
+ if (isset($_GET["$metric" ."_fill_area"])) {
+ $option_selected = "option_" .$_GET["$metric" ."_fill_area"] ."_selected";
+ $$option_selected = "selected";
+ }
+ echo "<option value=\"0\" $option_0_selected>no\n";
+ echo "<option value=\"1\" $option_1_selected>yes\n";
+ unset($$option_selected);
+ echo "</select>\n";
+ echo "</td>\n";
+ #
+ # Area color
+ #
+ echo "<td>\n";
+ if (stristr($metric, "logical_metric_") && $metric == "logical_metric_0")
+ color_dropdown(area_color, $metric, $logical_metric_num);
+ else
+ color_dropdown(area_color, $metric);
+ echo "</td>\n";
+ #
+ # CDEF field is used only for logical metrics
+ #
+ if (stristr($metric, "logical_metric_")) {
+ if ($metric == "logical_metric_0")
+ echo "<td><input type=\"text\" name=\"logical_metric_" ."$logical_metric_num" ."_cdef\"";
+ else
+ echo "<td><input type=\"text\" name=\"$metric" ."_cdef\"";
+ if (isset($_GET["$metric" ."_cdef"]))
+ $metric_cdef = $_GET["$metric" ."_cdef"];
+ else
+ $metric_cdef = "metric1,metric2,*";
+ echo "value=\"$metric_cdef\"></td>\n";
+ }
+ #
+ # Terminate row
+ #
+ echo "<tr>\n";
+}
+
+function choose_random_color($field_name, $color_codes) {
+ #
+ # Obtain all colors already set in the field
+ #
+ $get_keys = array_keys($_GET);
+ foreach ($get_keys as $key)
+ if (strpos($key, "$field_name"))
+ $colors_set[$key] = $_GET[$key];
+
+ #
+ # Generate array of colors that do not appear in $colors_set
+ #
+ if (count($colors_set))
+ $unused_colors = array_diff($color_codes, $colors_set);
+
+ #
+ # Choose a random color
+ #
+ if (isset($colors_set))
+ return array_rand($unused_colors);
+ else
+ return array_rand($color_codes);
+}
+
+function color_dropdown() {
+ $arg_list = func_get_args();
+ $field_name = $arg_list[0];
+ $metric = $arg_list[1];
+ if ($metric == "logical_metric_0")
+ $logical_metric_num = $arg_list[2];
+ $color_codes = array(
+ "black" => "#000000",
+ "white" => "#FFFFFF",
+ "grey" => "#AAAAAA",
+ "blue" => "#0000FF",
+ "green"=> "#00CC00",
+ "red" => "#FF0000",
+ "yellow" => "#FFFF00",
+ "cyan" => "#00FFFF",
+ "pink" => "#FF33FF",
+ "purple" => "#CC00CC"
+ );
+ $color_list = array_keys($color_codes);
+
+ if ($metric == "logical_metric_0")
+ echo "<select name=\"logical_metric_" .$logical_metric_num ."_$field_name\">\n";
+ else
+ echo "<select name=\"$metric" ."_$field_name\">\n";
+ foreach ($color_list as $color) {
+ echo "<option value=\"$color_codes[$color]\"";
+ if (isset($_GET["$metric" ."_$field_name"]) && $_GET["$metric" ."_$field_name"] == $color_codes[$color]) {
+ echo "selected";
+ $selected_color = 1;
+ }
+ echo ">$color\n";
+ }
+ if (! $selected_color) {
+ $random_color = choose_random_color($field_name, $color_codes);
+ echo "<option value=\"$color_codes[$random_color]\" selected>$random_color\n";
+ }
+ echo "</select>\n";
+}
+
+
+echo "<table border=0>\n";
+#
+# Who we're generating a custom graph for
+#
+echo "<td>Graph view: </td>\n";
+echo "<td><b>$_GET[custom_graph_view] </b></td>\n";
+echo "<tr>\n";
+
+#
+# Graph title
+#
+echo "<td>Graph title: </td>\n";
+echo "<td><input type=\"text\" name=\"title\"";
+if (!empty($_GET['title']))
+ echo " value=\"$_GET[title]\"";
+echo "> </td>\n";
+echo "<tr>\n";
+
+#
+# Start time
+#
+echo "<td>Start time: ";
+echo "<td><input type=\"text\" name=\"start_time\"";
+if (!empty($_GET['start_time']))
+ echo " value=\"$_GET[start_time]\"";
+else {
+ $time_array = gettimeofday();
+ $start_time = $time_array[sec];
+ switch ($_GET[$time_range]) {
+ case "hour": $start_time -= 3600; break;
+ case "day": $start_time -= 86400; break;
+ case "week": $start_time -= 604800; break;
+ case "month": $start_time -= 2419200; break;
+ case "year": $start_time -= 31449600; break;
+ default: $start_time -= 3600;
+ }
+ $human_time = date("j F Y H:i", $start_time);
+ echo " value=\"$human_time\"";
+}
+echo "> </td>\n";
+
+#
+# End time
+#
+echo "<td>End time: ";
+echo "<td><input type=\"text\" name=\"end_time\"";
+if (!empty($_GET['end_time']))
+ echo " value=\"$_GET[end_time]\"";
+else {
+ $human_time = date("j F Y H:i");
+ echo " value=\"$human_time\"";
+}
+echo "> </td>\n";
+echo "<tr>\n";
+
+#
+# Upper graph limit
+#
+echo "<td>Upper graph limit: </td>\n";
+echo "<td><input type=\"text\" name=\"upper_limit\"";
+if (!empty($_GET['upper_limit']))
+ echo " value=\"$_GET[upper_limit]\"";
+echo "> </td>\n";
+echo "<td>Rigid? </td>\n";
+echo "<td>\n";
+echo "<select name=\"upper_limit_rigid\">\n";
+if (!empty($_GET['upper_limit_rigid'])) {
+ $option_selected = "option_" .$_GET['upper_limit_rigid'] ."_selected";
+ $$option_selected = "selected";
+}
+echo "<option value=\"0\" $option_0_selected>no\n";
+echo "<option value=\"1\" $option_1_selected>yes\n";
+unset($$option_selected);
+echo "</select>\n";
+echo "</td>\n";
+echo "<tr>\n";
+
+#
+# Lower graph limit
+#
+echo "<td>Lower graph limit: </td>\n";
+echo "<td><input type=\"text\" name=\"lower_limit\"";
+if (!empty($_GET['lower_limit']))
+ echo " value=\"$_GET[lower_limit]\"";
+else
+ echo " value=\"0\"";
+echo "> </td>\n";
+echo "<td>Rigid? </td>\n";
+echo "<td>\n";
+echo "<select name=\"lower_limit_rigid\">\n";
+if (!empty($_GET['lower_limit_rigid'])) {
+ $option_selected = "option_" .$_GET['lower_limit_rigid'] ."_selected";
+ $$option_selected = "selected";
+}
+echo "<option value=\"1\" $option_1_selected>yes\n";
+echo "<option value=\"0\" $option_0_selected>no\n";
+unset($$option_selected);
+echo "</select>\n";
+echo "</td>\n";
+echo "<tr>\n";
+
+#
+# Base units for graph
+#
+echo "<td>Base: </td>\n";
+echo "<td><input type=\"text\" name=\"base\"";
+if (!empty($_GET['base']))
+ echo " value=\"$_GET[base]\"";
+else
+ echo " value=\"1000\"";
+echo "> </td>\n";
+echo "<tr>\n";
+
+#
+# Vertical label
+#
+echo "<td>Vertical label: </td>\n";
+echo "<td><input type=\"text\" name=\"vertical_label\"";
+if (!empty($_GET['vertical_label']))
+ echo " value=\"$_GET[vertical_label]\"";
+echo "> </td>\n";
+echo "<tr>\n";
+
+#
+# Graph height
+#
+echo "<td>Graph height: </td>\n";
+echo "<td><input type=\"text\" name=\"height\"";
+if (!empty($_GET['height']))
+ echo " value=\"$_GET[height]\"";
+else
+ echo " value=\"295\"";
+echo "> </td>\n";
+echo "<tr>\n";
+
+#
+# Graph width
+#
+echo "<td>Graph width: </td>\n";
+echo "<td><input type=\"text\" name=\"width\"";
+if (!empty($_GET['width']))
+ echo " value=\"$_GET[width]\"";
+else
+ echo " value=\"895\"";
+echo "> </td>\n";
+echo "<tr>\n";
+
+#
+# Where to send the graph output
+#
+echo "<td>Display graph to: </td>\n";
+echo "<td><input type=\"text\" name=\"output_file\"";
+if (!empty($_GET['output_file']))
+ echo " value=\"$_GET[output_file]\"";
+else
+ echo " value=\"stdout\"";
+echo "> </td>\n";
+echo "</table>\n";
+echo "<br>\n";
+
+#
+# Drop-down metric menu - when a value is selected the form is resubmitted to itself
+#
+echo "Add metric: <select name=\"added_metric\" onchange=\"resubmit()\">\n";
+
+#
+# Iterate over all files in dir and display them in the drop-down menu
+#
+if ($handle = opendir($directory)) {
+ echo "<option>Choose metric";
+ echo "<option value=\"logical_metric_0\">logical_metric";
+
+ $arr_size = 0;
+ while (false !== ($file = readdir($handle))) {
+ #
+ # Exclude "." and ".."
+ #
+ if ($file != "." && $file != "..") {
+ #
+ # Strip file extension and replace "." with "_"
+ #
+ $file = str_replace(".rrd", "", "$file");
+ $file = str_replace(".", "_", "$file");
+ $metrics[$arr_size] = $file;
+ echo "<option value=\"$file\">$file";
+ }
+ $arr_size++;
+ }
+ echo "</select>\n";
+ closedir($handle);
+}
+
+#
+# Table header - our added metrics will appear inside it
+#
+echo "<br><br>\n";
+echo "<table border=1>\n";
+echo "<th>Metric Name</th>\n";
+echo "<th>Line Thickness</th>\n";
+echo "<th>Line Color</th>\n";
+echo "<th>Fill Area</th>\n";
+echo "<th>Area Color</th>\n";
+echo "<th>CDEF</th>\n";
+echo "<tr>\n";
+
+#
+# Add metrics to table - if the GET variable we're checking exists, the form has been
+# submitted to itself and we have a metric to add to the table
+#
+if (isset($_GET['added_metric']))
+ table_entry($_GET['added_metric']);
+
+#
+# Popullate table with checked elements - this applies only to metrics which have
+# an rrd file in the scanned directory
+#
+for ($i = 0; $i < $arr_size; $i++)
+ if (isset($_GET[$metrics[$i]]))
+ table_entry($metrics[$i]);
+
+#
+# Add logical metrics to table
+#
+for ($i = 0; $i < $max_logical_metrics; $i++)
+ if (isset($_GET["logical_metric_" ."$i"]))
+ table_entry("logical_metric_" ."$i");
+
+#
+# Some hidden values to pass on
+#
+echo "<input type=\"hidden\" name=\"rrd_dir\" value=\"$directory\">\n";
+echo "<input type=\"hidden\" name=\"rrd_tool\" value=\"$_GET[rrd_tool]\">\n";
+echo "<input type=\"hidden\" name=\"max_logical_metrics\" value=\"$max_logical_metrics\">\n";
+echo "<input type=\"hidden\" name=\"custom_graph_view\" value=\"$_GET[custom_graph_view]\">\n";
+
+?>
+
+ </table>
+ <br>
+ <center><input type="submit" value="Generate graph!"></center>
+ </form>
+
+</body>
+</html>
diff -urN ganglia/custom_graph_processing.php ganglia.new/custom_graph_processing.php
--- ganglia/custom_graph_processing.php 1970-01-01 02:00:00.000000000 +0200
+++ ganglia.new/custom_graph_processing.php 2006-04-18 23:04:35.000000000 +0300
@@ -0,0 +1,194 @@
+<?php
+
+#
+# Obtain some variables
+#
+$rrd_dir = isset($_GET["rrd_dir"]) ?
+ escapeshellcmd(rawurldecode($_GET["rrd_dir"])) : NULL;
+$rrdtool = isset($_GET["rrd_tool"]) ?
+ escapeshellcmd(rawurldecode($_GET["rrd_tool"])) : NULL;
+$max_logical_metrics = isset($_GET["max_logical_metrics"]) ?
+ escapeshellcmd(rawurldecode($_GET["max_logical_metrics"])) : NULL;
+
+#
+# Obtain general graph parameters
+#
+$title = isset($_GET["title"]) ?
+ escapeshellcmd(rawurldecode($_GET["title"])) : NULL;
+$start_time = isset($_GET["start_time"]) ?
+ escapeshellcmd(rawurldecode($_GET["start_time"])) : NULL;
+$end_time = isset($_GET["end_time"]) ?
+ escapeshellcmd(rawurldecode($_GET["end_time"])) : NULL;
+$upper_limit = isset($_GET["upper_limit"]) ?
+ escapeshellcmd(rawurldecode($_GET["upper_limit"])) : NULL;
+$upper_limit_rigid = isset($_GET["upper_limit_rigid"]) ?
+ escapeshellcmd(rawurldecode($_GET["upper_limit_rigid"])) : NULL;
+$lower_limit = isset($_GET["lower_limit"]) ?
+ escapeshellcmd(rawurldecode($_GET["lower_limit"])) : NULL;
+$lower_limit_rigid = isset($_GET["lower_limit_rigid"]) ?
+ escapeshellcmd(rawurldecode($_GET["lower_limit_rigid"])) : NULL;
+$base = isset($_GET["base"]) ?
+ escapeshellcmd(rawurldecode($_GET["base"])) : NULL;
+$vertical_label = isset($_GET["vertical_label"]) ?
+ escapeshellcmd(rawurldecode($_GET["vertical_label"])) : NULL;
+$height = isset($_GET["height"]) ?
+ escapeshellcmd(rawurldecode($_GET["height"])) : NULL;
+$width = isset($_GET["width"]) ?
+ escapeshellcmd(rawurldecode($_GET["width"])) : NULL;
+$output_file = isset($_GET["output_file"]) ?
+ escapeshellcmd(rawurldecode($_GET["output_file"])) : NULL;
+
+#
+# If graphs are sent to stdout we need to parse the variable
+#
+if ($output_file == "stdout")
+ $output_file = "-";
+
+#
+# Convert time
+#
+$start_time = strtotime($start_time);
+$end_time = strtotime($end_time);
+if ($start_time == -1 or $end_time == -1) {
+ echo "Invalid time string supplied, convertion failed:<br>";
+ echo '$start_time ' ."($_GET[start_time]) = $start_time<br>";
+ echo '$end_time ' ."($_GET[end_time]) = $end_time<br>";
+ exit;
+}
+
+#
+# Optional parameters
+#
+if (!empty($upper_limit)) {
+ $opt_cmdline .= " --upper-limit $upper_limit";
+ if (!empty($upper_limit_rigid))
+ $opt_cmdline .= " --rigid";
+}
+if (!empty($lower_limit)) {
+ $opt_cmdline .= " --lower-limit $lower_limit";
+ if (!empty($lower_limit_rigid))
+ $opt_cmdline .= " --rigid";
+}
+if (!empty($title))
+ $opt_cmdline .= " --title '$title'";
+if (!empty($vertical_label))
+ $opt_cmdline .= " --vertical-label '$vertical_label'";
+
+#
+# Handle metrics
+#
+if ($handle = opendir($rrd_dir)) {
+ while (false !== ($file = readdir($handle))) {
+ #
+ # Exclude "." and ".."
+ #
+ if ($file != "." && $file != "..") {
+ #
+ # Strip file extension and replace "." with "_"
+ #
+ $file_no_ext = str_replace(".rrd", "", "$file");
+ $metric_name = str_replace(".", "_", "$file_no_ext");
+ $metric_status = escapeshellcmd(rawurldecode($_GET["$metric_name"]));
+
+ if ($metric_status == "on") {
+ #
+ # Graphical parameters of metric
+ #
+ $metric_line_thickness = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_line_thickness"]));
+ $metric_line_color = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_line_color"]));
+ $metric_fill_area = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_fill_area"]));
+ $metric_area_color = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_area_color"]));
+ #
+ # Parse metric parameters to rrdtool format
+ #
+ $metrics_cmdline .= " DEF:'$file_no_ext'='$rrd_dir/$file':sum:AVERAGE";
+ if (!empty($metric_line_thickness))
+ $metrics_cmdline .= " LINE$metric_line_thickness:'$file_no_ext'$metric_line_color:'$file_no_ext'";
+ if (!empty($metric_fill_area))
+ $metrics_cmdline .= " AREA:'$file_no_ext'$metric_area_color:'$file_no_ext'";
+ #
+ # Graph legend
+ #
+ $leading_spaces = 20 - strlen($file_no_ext);
+ $metrics_cmdline .= " VDEF:'$file_no_ext" ."min'=$file_no_ext,MINIMUM";
+ $metrics_cmdline .= " VDEF:'$file_no_ext" ."avg'=$file_no_ext,AVERAGE";
+ $metrics_cmdline .= " VDEF:'$file_no_ext" ."max'=$file_no_ext,MAXIMUM";
+ $metrics_cmdline .= " GPRINT:'$file_no_ext" ."min':\"%$leading_spaces.2lf\"";
+ $metrics_cmdline .= " GPRINT:'$file_no_ext" ."avg':\"\t%10.2lf\"";
+ $metrics_cmdline .= " GPRINT:'$file_no_ext" ."max':\"\t%10.2lf\\n\"";
+ }
+ }
+ }
+}
+
+#
+# Handle logical metrics
+#
+for ($i = 0; $i < $max_logical_metrics; $i++) {
+ if (isset($_GET["logical_metric_" ."$i"])) {
+ $metric_name = "logical_metric_" ."$i";
+ $logical_metric_name = $_GET["$metric_name" ."_name"];
+ $logical_metric_cdef = $_GET["$metric_name" ."_cdef"];
+ $metrics_cmdline .= " CDEF:'$logical_metric_name'=$logical_metric_cdef";
+ #
+ # Graphical parameters of metric
+ #
+ $metric_line_thickness = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_line_thickness"]));
+ $metric_line_color = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_line_color"]));
+ $metric_fill_area = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_fill_area"]));
+ $metric_area_color = escapeshellcmd(rawurldecode($_GET["$metric_name" ."_area_color"]));
+ #
+ # Parse graphical metric parameters to rrdtool format
+ #
+ if (!empty($metric_line_thickness))
+ $metrics_cmdline .= " LINE$metric_line_thickness:'$logical_metric_name'$metric_line_color:'$logical_metric_name'";
+ if (!empty($metric_fill_area))
+ $metrics_cmdline .= " AREA:'$logical_metric_name'$metric_area_color:'$logical_metric_name'";
+ #
+ # Graph legend
+ #
+ $leading_spaces = 20 - strlen($logical_metric_name);
+ $metrics_cmdline .= " VDEF:'$logical_metric_name" ."min'=$logical_metric_name,MINIMUM";
+ $metrics_cmdline .= " VDEF:'$logical_metric_name" ."avg'=$logical_metric_name,AVERAGE";
+ $metrics_cmdline .= " VDEF:'$logical_metric_name" ."max'=$logical_metric_name,MAXIMUM";
+ $metrics_cmdline .= " GPRINT:'$logical_metric_name" ."min':\"%$leading_spaces.2lf\"";
+ $metrics_cmdline .= " GPRINT:'$logical_metric_name" ."avg':\"\t%10.2lf\"";
+ $metrics_cmdline .= " GPRINT:'$logical_metric_name" ."max':\"\t%10.2lf\\n\"";
+ }
+}
+
+#
+# Legend header - nice formatting always seems to me like voodoo
+#
+$legend_header .= " COMMENT:\"\\t\\t\\t\""
+ ." COMMENT:\"Minimum \""
+ ." COMMENT:\"Average \""
+ ." COMMENT:\"Maximum\\n\"";
+
+#
+# Add metric parameters to command line
+#
+$command = "$rrdtool graph $output_file --start $start_time --end $end_time --width $width --height $height";
+$command .= "$opt_cmdline $legend_header $metrics_cmdline";
+
+
+$debug = 0;
+if (empty($debug)) {
+ #
+ # Prepare HTTP header
+ #
+ header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
+ header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
+ header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
+ header ("Pragma: no-cache"); // HTTP/1.0
+ header ("Content-type: image/gif");
+
+ #
+ # Execute command
+ #
+ passthru($command);
+}
+else
+ echo $command;
+
+?>
diff -urN ganglia/header.php ganglia.new/header.php
--- ganglia/header.php 2005-02-03 04:22:48.000000000 +0200
+++ ganglia.new/header.php 2006-04-18 23:04:10.000000000 +0300
@@ -328,6 +328,45 @@
# Assign template variable in cluster view.
}
+#
+# Button for custom graphs interface
+#
+if ($context != "node" and $context != "physical" ) {
+ switch ($context)
+ {
+ case "meta":
+ $rrd_dir = "$rrds/__SummaryInfo__";
+ $custom_graph_view = $self;
+ break;
+ case "grid":
+ $rrd_dir = "$rrds/$grid/__SummaryInfo__";
+ $custom_graph_view = $grid;
+ break;
+ case "cluster":
+ $rrd_dir = "$rrds/$clustername/__SummaryInfo__";
+ $custom_graph_view = $clustername;
+ break;
+ case "host":
+ $rrd_dir = "$rrds/$clustername/$hostname";
+ $custom_graph_view = $hostname;
+ break;
+ default:
+ exit;
+ }
+
+
+ $custom_graph_button = "<FORM METHOD=\"get\" ACTION=\"custom_graph_interface.php\" NAME=\"custom_graph\">"
+ ."<INPUT TYPE=\"hidden\" NAME=\"rrd_dir\" VALUE=\"$rrd_dir\">"
+ ."<INPUT TYPE=\"hidden\" NAME=\"rrd_tool\" VALUE=\"" .RRDTOOL ."\">"
+ ."<INPUT TYPE=\"hidden\" NAME=\"time_range\" VALUE=\"$range\">"
+ ."<INPUT TYPE=\"hidden\" NAME=\"custom_graph_view\" VALUE=\"$custom_graph_view\">"
+ ."<INPUT TYPE=\"submit\" VALUE=\"custom graph\">"
+ ."</FORM>";
+
+ $tpl->assign("custom_graph_button", $custom_graph_button);
+}
+
+
# Make sure that no data is cached..
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified
diff -urN ganglia/templates/default/header.tpl ganglia.new/templates/default/header.tpl
--- ganglia/templates/default/header.tpl 2005-02-03 04:22:48.000000000 +0200
+++ ganglia.new/templates/default/header.tpl 2006-04-18 13:16:34.000000000 +0300
@@ -47,5 +47,9 @@
<FONT SIZE="+1">
{node_menu}
+</FORM>
+<CENTER>
+{custom_graph_button}
+</CENTER>
</FONT>
<HR SIZE="1" NOSHADE>