Ejemplo n.º 1
0
        # Find view settings
        if ($user['view_name'] == $view['view_name']) {
            break;
        }
    }
    unset($available_views);
    foreach ($view['items'] as $index => $graph_config) {
        if ($user['item_id'] == $graph_config['item_id']) {
            break;
        }
    }
    unset($view);
    $title = "";
} else {
    if (isset($_GET['aggregate'])) {
        $graph_config = build_aggregate_graph_config($graph_type, $line_width, $_GET['hreg'], $_GET['mreg']);
        foreach ($_GET['hreg'] as $index => $arg) {
            print "<input type=hidden name=hreg[] value='" . htmlspecialchars($arg) . "'>";
        }
        foreach ($_GET['mreg'] as $index => $arg) {
            print "<input type=hidden name=mreg[] value='" . htmlspecialchars($arg) . "'>";
        }
    } else {
        print '
      <div class="ui-widget">
			<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
				<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
				<strong>Alert:</strong> This graph can not be decomposed</p>
			</div>
      </div>
  ';
Ejemplo n.º 2
0
}
?>
',
  "uriPathPrefix": '<?php 
if (isset($conf['ganglia_url_suffix'])) {
    print $conf['ganglia_url_suffix'];
} else {
    print dirname($_SERVER["SCRIPT_NAME"]);
}
?>
/'} );

<?php 
# Most of the cubism graphs are like aggregate graphs so let's avoid redoing
# the logic
$graph_config = build_aggregate_graph_config("line", 1, array($hreg), array($mreg), "hide", false);
?>
var load_metrics = [
<?php 
$items = array();
foreach ($graph_config['series'] as $index => $item) {
    $cluster = $item['clustername'];
    $host = $item['hostname'];
    $metric = $item['metric'];
    $label = $host . "_" . $metric;
    $items[] = 'ganglia.metric( { 
    "clusterName": "' . $cluster . '", 
    "hostName": "' . $host . '", 
    "metricName": "' . $metric . '",
    "isReport": false} ).alias("' . $label . '")';
}
Ejemplo n.º 3
0
function build_aggregate_graph_config_from_url($conf_graph_colors)
{
    // If graph type is not specified default to line graph
    $graph_type = isset($_GET["gtype"]) && in_array($_GET["gtype"], array("stack", "line", "percent")) ? $_GET["gtype"] : 'line';
    // If line width not specified default to 2
    $line_width = isset($_GET["lw"]) && in_array($_GET["lw"], array("1", "2", "3")) ? $_GET["lw"] : '2';
    $graph_legend = isset($_GET["glegend"]) && in_array($_GET["glegend"], array("show", "hide")) ? $_GET["glegend"] : 'show';
    /////////////////////////////////////////////////////////////////////////////
    // In order to reduce the load on the machine when someone is doing host
    // compare we look whether host list has been supplied via hl arg.
    // That way we do not have get metric cache
    /////////////////////////////////////////////////////////////////////////////
    if (isset($_GET['hl'])) {
        $counter = 0;
        $color_count = sizeof($conf_graph_colors);
        $metric_name = str_replace("\$", "", str_replace("^", "", $_GET['mreg'][0]));
        $host_list = explode(",", $_GET['hl']);
        foreach ($host_list as $host_cluster) {
            $color_index = $counter % $color_count;
            $parts = explode("|", $host_cluster);
            $hostname = $parts[0];
            $clustername = $parts[1];
            $series = array("hostname" => $hostname, "clustername" => $clustername, "fill" => "true", "metric" => $metric_name, "color" => $conf_graph_colors[$color_index], "label" => $hostname, "type" => $graph_type);
            if ($graph_type == "line" || $graph_type == "area") {
                $series['line_width'] = $line_width;
            } else {
                if ($graph_type == "percent") {
                    $graph_config['percent'] = "1";
                } else {
                    $series['stack'] = "1";
                }
            }
            $graph_config['series'][] = $series;
            $counter++;
        }
    } else {
        $exclude_host_from_legend_label = array_key_exists('lgnd_xh', $_GET) && $_GET['lgnd_xh'] == "true" ? TRUE : FALSE;
        $graph_config = build_aggregate_graph_config($graph_type, $line_width, $_GET['hreg'], $_GET['mreg'], $graph_legend, $exclude_host_from_legend_label);
    }
    // Set up
    $graph_config["report_type"] = "standard";
    $graph_config["vertical_label"] = isset($_GET["vl"]) ? sanitize($_GET["vl"]) : NULL;
    $graph_config["graph_scale"] = isset($_GET["gs"]) ? sanitize($_GET["gs"]) : NULL;
    $graph_config["scale"] = isset($_GET["scale"]) ? sanitize($_GET["scale"]) : NULL;
    $graph_config["show_total"] = isset($_GET["show_total"]) ? sanitize($_GET["show_total"]) : NULL;
    if (isset($_GET['title']) && $_GET['title'] != "") {
        $graph_config["title"] = sanitize($_GET['title']);
    }
    return $graph_config;
}
Ejemplo n.º 4
0
            if ($graph_type == "line" || $graph_type == "area") {
                $series['line_width'] = $line_width;
            } else {
                if ($graph_type == "percent") {
                    $graph_config['percent'] = "1";
                } else {
                    $series['stack'] = "1";
                }
            }
            $graph_config['series'][] = $series;
            $counter++;
        }
        // end of foreach ( $host_list as
    } else {
        $exclude_host_from_legend_label = array_key_exists('lgnd_xh', $_GET) && $_GET['lgnd_xh'] == "true" ? TRUE : FALSE;
        $graph_config = build_aggregate_graph_config($graph_type, $line_width, $_GET['hreg'], $_GET['mreg'], $graph_legend, $exclude_host_from_legend_label);
    }
    // Set up
    $graph_config["report_type"] = "standard";
    $graph_config["vertical_label"] = $vlabel;
    $graph_config["graph_scale"] = $graph_scale;
    $graph_config["scale"] = $scale;
    $graph_config["show_total"] = $show_total;
    // Reset graph title
    if (isset($_GET['title']) && $_GET['title'] != "") {
        $title = "";
        $graph_config["title"] = sanitize($_GET['title']);
    } else {
        $title = "Aggregate";
    }
}