-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid_hosts_view.php
100 lines (76 loc) · 2.02 KB
/
grid_hosts_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/* $Id: meta_view.php 1710 2008-08-21 16:44:54Z bernardli $ */
$tpl = new TemplatePower( template("grid_hosts_view.tpl") );
$tpl->prepare();
// Store context for later
$oldContext = $context;
// Loop through clusters to get all grid hosts
$gridClusterHosts = array();
$gridHosts = array();
foreach ($grid as $gridItem) {
// Skip fake grid cluster
if ($gridItem['NAME'] == 'ITSIS') {
continue;
}
$clusterName = $gridItem['NAME'];
$gridData[$clusterName] = array();
// Get cluster hosts
$context = 'cluster';
$clustername = $clusterName;
$metrics = array();
Gmetad();
// Assign to array
foreach ($metrics as $hostName => $hostData) {
$gridClusterHosts[$clusterName][$hostName] = $hostName;
$gridHosts[$hostName] = $clusterName;
}
}
// Get max y value for RRD graph
if (isset($_GET['maxY']) && ($_GET['maxY'] != '')) {
$maxY = $_GET['maxY'];
} else {
$maxY = '';
}
$tpl->assign('maxY', $maxY);
// Draw graphs
$metricType = 'm';
if (isset($reportArray[$metricname])) {
$metricType = 'g';
}
$hostsInLine = 0;
$lastClusterName = '';
foreach ($gridHosts as $hostName => $clusterName) {
$hostsInLine++;
/*
// Each cluster goes to new row
if ($lastClusterName == '') {
$hostsInLine = 1;
$lastClusterName = $clusterName;
}
if ($clusterName != $lastClusterName) {
$hostsInLine = 1;
$tpl->assign('new_row_end', '</tr> <tr>');
}
*/
// Assign vars
$tpl->newBlock('host_metric_graph');
$tpl->assign('hostname', $hostName);
$tpl->assign('cluster', $clusterName);
$tpl->assign('metrictype', $metricType);
$tpl->assign('metricname', $metricname);
$tpl->assign('range', $range);
// Add common Y scale
$graphVars = '';
if ($maxY) {
$graphVars .= "maxY=$maxY";
}
$tpl->assign('graphvars', $graphVars);
// Line break hack
if ($hostsInLine >= 4) {
$hostsInLine = 0;
$tpl->assign('new_row_end', '</tr> <tr>');
}
// Save state data
$lastClusterName = $clusterName;
}
$tpl->printToScreen();