aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/index.php
diff options
context:
space:
mode:
authorMark Nellemann2015-08-26 12:29:30 +0200
committerMark Nellemann2015-08-26 12:29:30 +0200
commit26cd32c6deb372dc25e3c010b65d9697962edf16 (patch)
tree2ab8aba3d1e1091932ac2f6393968c7fb2efd0a8 /index.php
parentinc/functions: a host, pi and ti may contain colons (:) and spaces ( ) (diff)
downloadapt-panopticon_cgp-26cd32c6deb372dc25e3c010b65d9697962edf16.zip
apt-panopticon_cgp-26cd32c6deb372dc25e3c010b65d9697962edf16.tar.gz
apt-panopticon_cgp-26cd32c6deb372dc25e3c010b65d9697962edf16.tar.bz2
apt-panopticon_cgp-26cd32c6deb372dc25e3c010b65d9697962edf16.tar.xz
Support for host categories bases on regular expression matching against host names
Diffstat (limited to 'index.php')
-rw-r--r--index.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/index.php b/index.php
index 94ecf80..9069152 100644
--- a/index.php
+++ b/index.php
@@ -11,11 +11,30 @@ $h = array();
11# show all categorized hosts 11# show all categorized hosts
12if (isset($CONFIG['cat']) && is_array($CONFIG['cat'])) { 12if (isset($CONFIG['cat']) && is_array($CONFIG['cat'])) {
13 foreach($CONFIG['cat'] as $cat => $hosts) { 13 foreach($CONFIG['cat'] as $cat => $hosts) {
14 host_summary($cat, $hosts); 14
15 $h = array_merge($h, $hosts); 15 if(is_array($hosts)) {
16 host_summary($cat, $hosts);
17 $h = array_merge($h, $hosts);
18 } else {
19 // Asume regexp
20 $regexp = $hosts;
21 $ahosts = collectd_hosts();
22 $rhosts = array();
23
24 foreach($ahosts as $host) {
25 if(preg_match($regexp, $host)) {
26 array_push($rhosts, $host);
27 }
28 }
29
30 host_summary($cat, $rhosts);
31 $h = array_merge($h, $rhosts);
32 }
33
16 } 34 }
17} 35}
18 36
37
19# search for uncategorized hosts 38# search for uncategorized hosts
20if(!$chosts = collectd_hosts()) 39if(!$chosts = collectd_hosts())
21 printf('<p class="warn">Error: No Collectd hosts found in <em>%s</em></p>', $CONFIG['datadir']); 40 printf('<p class="warn">Error: No Collectd hosts found in <em>%s</em></p>', $CONFIG['datadir']);