forked from lensen/graphsky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster_view.php
51 lines (47 loc) · 2 KB
/
cluster_view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<span class="anchor" id="overview"></span>
<div class="block_title"><a href="#overview">Overview</a></div>
<div class="graph_block">
<?php
$graph_args = "env=$env&c=$c&l=$l";
if (isset($g)) { $graph_reports = array($g); }
elseif (isset($m)) { $metric_graph = $m; }
else { $graph_reports = find_dashboards($env, $c); }
if (isset($m)) {
print print_zoom_graph($graph_args, "m=$metric_graph", $z, $from, $until);
}
elseif (isset($graph_reports)) {
foreach ($graph_reports as $graph_report) {
print print_zoom_graph($graph_args, "g=$graph_report", $z, $from, $until);
}
}
?>
</div>
<span class="anchor" id="hosts"></span>
<div class="block_title"><a href="#hosts">Hosts</a></div>
<?php
$host_search = json_decode(file_get_contents($conf['graphite_search_url'] . $conf['graphite_prefix'] . "$env.$c.*"), TRUE);
$hosts = $host_search['results'];
natsort($hosts);
if (isset($g)) { print "<div class=\"graph_block\">"; }
foreach ($hosts as $host) {
$host_name = str_replace($conf['graphite_prefix'] . "$env.$c.", "", $host);
if ($host_name == $conf['cluster_hostname']) { continue; }
if (isset($graph_reports)) {
if (!isset($g)) { print "<a href=\"?$graph_args&h=$host_name&from=$gs&until=$ge\"><div class=\"banner_text\">$host_name</div></a><div class=\"graph_block\">"; }
foreach ($graph_reports as $graph_report) {
$current_graph_args = $graph_args . "&h=$host_name";
print print_graph($current_graph_args, "g=$graph_report", $z, $from, $until);
}
if (!isset($g)) { print "</div>"; }
}
elseif (isset($m)) {
$depth = $conf['host_metric_group_depth'] + 1;
$metric_group_elements = explode(".", $metric_graph, $depth);
array_pop($metric_group_elements);
$metric_group_name = implode(".", $metric_group_elements);
$current_graph_args = $graph_args . "&h=$host_name&dn=$host_name";
print print_graph($current_graph_args, "m=$metric_graph", $z, $from, $until);
}
}
if (isset($g)) { print "</div>"; }
?>