Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add upper and lower limits to graphs, aggregate graphs and views.
  • Loading branch information
vuksan committed Aug 24, 2011
1 parent b2875ef commit a38f80b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ganglia-web/aggregate_graphs.php
Expand Up @@ -97,6 +97,9 @@ function createAggregateGraph() {
<td colspan=2><input name="vl" id="vl" value="" size=60></td>
</tr>
<tr>
<td>Limits</td><td>Upper:<input name="x" id="x" value="" size=10></td><td>Lower:<input name="n" id="n" value="" size=10></td>
</tr>
<tr>
<td>Host Regular expression e.g. web-[0,4], web or (web|db):</td>
<td colspan=2><input name="hreg[]" id="hreg" size=60></td>
</tr>
Expand Down
6 changes: 6 additions & 0 deletions ganglia-web/functions.php
Expand Up @@ -772,6 +772,12 @@ function get_view_graph_elements($view) {
else
$graph_args_array[] = "gtype=line";

if (isset($item['upper_limit']))
$graph_args_array[] = "x=" .$item['upper_limit'];

if (isset($item['lower_limit']))
$graph_args_array[] = "n=" .$item['lower_limit'];

if (isset($item['vertical_label']))
$graph_args_array[] = "vl=" .$item['vertical_label'];

Expand Down
16 changes: 13 additions & 3 deletions ganglia-web/graph.php
Expand Up @@ -25,8 +25,8 @@

$metric_name = isset($_GET["m"]) ? sanitize ( $_GET["m"] ) : NULL;

$max = isset($_GET["x"]) ? clean_number ( sanitize ($_GET["x"] ) ) : NULL;
$min = isset($_GET["n"]) ? clean_number ( sanitize ($_GET["n"] ) ) : NULL;
$max = isset($_GET["x"]) && is_numeric($_GET["x"]) ? $_GET["x"] : NULL;
$min = isset($_GET["n"]) && is_numeric($_GET["n"]) ? $_GET["n"] : NULL;
$sourcetime = isset($_GET["st"]) ? clean_number ( sanitize( $_GET["st"] ) ) : NULL;

$load_color = isset($_GET["l"]) && is_valid_hex_color( rawurldecode( $_GET[ 'l' ] ) )
Expand Down Expand Up @@ -192,7 +192,9 @@
if ($range == "month")
$rrdtool_graph['end'] = floor($rrdtool_graph['end'] / 672) * 672;

///////////////////////////////////////////////////////////////////////////////
// Are we generating aggregate graphs
///////////////////////////////////////////////////////////////////////////////
if ( isset( $_GET["aggregate"] ) && $_GET['aggregate'] == 1 ) {

// Set start time
Expand Down Expand Up @@ -317,7 +319,7 @@
switch ( $conf['graph_engine'] ) {
case "flot":
case "rrdtool":

if ( ! isset($graph_config) ) {
if ( ($graph == "metric") &&
isset($_GET['title']) &&
Expand Down Expand Up @@ -372,6 +374,14 @@
$rrdtool_graph['title'] = $title . " " . $rrdtool_graph['title'] . " last $range";

$command = $conf['rrdtool'] . " graph - $rrd_options ";

if ( $max ) {
$rrdtool_graph['upper-limit'] = $max;
}
if ( $min )
$rrdtool_graph['lower-limit'] = $min;
if ( $max || $min )
$rrdtool_graph['extras'] = isset($rrdtool_graph['extras']) ? $rrdtool_graph['extras'] . " --rigid" : " --rigid" ;

// The order of the other arguments isn't important, except for the
// 'extras' and 'series' values. These two require special handling.
Expand Down
12 changes: 11 additions & 1 deletion ganglia-web/views.php
Expand Up @@ -119,10 +119,20 @@
foreach ( $_GET['hreg'] as $key => $value )
$host_regex_array[] = array("regex" => $value);

$view['items'][] = array( "aggregate_graph" => "true", "metric_regex" => $metric_regex_array,
$item_array = array( "aggregate_graph" => "true", "metric_regex" => $metric_regex_array,
"host_regex" => $host_regex_array, "graph_type" => $_GET['gtype'],
"vertical_label" => $_GET['vl'], "title" => $_GET['title']);

if ( isset($_GET['x']) && is_numeric($_GET['x'])) {
$item_array["upper_limit"] = $_GET['x'];
}
if ( isset($_GET['n']) && is_numeric($_GET['n'])) {
$item_array["lower_limit"] = $_GET['n'];
}

$view['items'][] = $item_array;
unset($item_array);

} else {
if ( $_GET['type'] == "metric" ) {
$items = array( "hostname" => $_GET['host_name'], "metric" => $_GET['metric_name'] );
Expand Down

0 comments on commit a38f80b

Please sign in to comment.