-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.php
83 lines (70 loc) · 2.15 KB
/
service.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
<?php
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
require_once 'conf/common.inc.php';
require_once 'inc/html.inc.php';
require_once 'inc/collectd.inc.php';
$host = validate_get(GET('h'), 'host');
$splugin = validate_get(GET('p'), 'plugin');
$subplugin = validate_get(GET('s'), 'plugin');
html_start();
$services = array();
$hosts = get_all_hosts();
foreach ($hosts as $h) {
$plugins = collectd_plugins($h);
foreach ($plugins as $plugin) {
$plugindata = collectd_plugindata($h, $plugin);
$plugindata = group_plugindata($plugindata);
$services[$plugin]['#hosts'][] = $h;
foreach($plugindata as $pd) {
if ($pd['t'] != $plugin) {
$services[$plugin][$pd['t']][md5($h)] = $h;
}
}
}
}
print '<div class="services"><ul class="services">';
foreach ($services as $service => $hs) {
if (substr($service, 0, 1) != '#') {
print '<li><a href="service.php?p=' . $service . '">' . $service . '</a><ul>';
foreach ($hs as $k => $s) {
if (substr($k, 0, 1) != '#') {
print '<li><a href="service.php?p=' . $service . '&s=' . $k . '">' . $k . '</a></li>';
}
}
print '</ul></li>';
}
}
print '</ul></div>';
if ($splugin && array_key_exists($splugin, $services)) {
print '<table><tr valign="top">';
foreach ($services[$splugin]['#hosts'] as $h) {
print '<td>';
print '<h2>' . $h . '</h2>';
if (isset($subplugin)) {
global $CONFIG;
$plugindata = collectd_plugindata($h, $splugin);
$plugindata = group_plugindata($plugindata);
foreach ($plugindata as $items) {
if ($items['t'] == $subplugin) {
$items['h'] = $h;
$time = array_key_exists($plugin, $CONFIG['time_range'])
? $CONFIG['time_range'][$plugin]
: $CONFIG['time_range']['default'];
printf('<a href="%s"><img src="%s"></a>'."\n",
build_url('detail.php', $items, $time),
build_url('graph.php', $items, $time)
);
}
}
}
else {
print graphs_from_plugin($h, $splugin);
}
print '</td>';
}
print '</tr></table>';
}
html_end();
?>