forked from pommi/CGP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
61 lines (46 loc) · 1.12 KB
/
index.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
<?php
include_once 'conf/common.inc.php';
include_once 'inc/collectd.inc.php';
require_once 'inc/html.inc.php';
header("Content-Type: text/html");
html_start();
$h = array();
# show all categorized hosts
if (isset($CONFIG['cat']) && is_array($CONFIG['cat'])) {
foreach($CONFIG['cat'] as $cat => $hosts) {
if(is_array($hosts)) {
host_summary($cat, $hosts);
$h = array_merge($h, $hosts);
} else {
// Asume regexp
$regexp = $hosts;
$ahosts = collectd_hosts();
$rhosts = array();
foreach($ahosts as $host) {
if(preg_match($regexp, $host)) {
array_push($rhosts, $host);
}
}
host_summary($cat, $rhosts);
$h = array_merge($h, $rhosts);
}
}
}
# search for uncategorized hosts
if(!$chosts = collectd_hosts())
printf('<p class="warn">Error: No Collectd hosts found in <em>%s</em></p>', $CONFIG['datadir']);
$uhosts = array_diff($chosts, $h);
# show all uncategorized hosts
if ($uhosts) {
host_summary('uncategorized', $uhosts);
}
if ($CONFIG['showtime']) {
echo <<<EOT
<script>
jQuery(document).ready(function() {
jQuery("time.timeago").timeago();
});
</script>
EOT;
}
html_end(true);