diff options
author | Pim van den Berg | 2016-01-05 21:54:22 +0100 |
---|---|---|
committer | Pim van den Berg | 2016-01-05 21:54:22 +0100 |
commit | 192cb0bc5381377dc6e646c68730d5d9b686cc8f (patch) | |
tree | 5879af858962416f6bcbc335e3c24f9478188a7b /index.php | |
parent | explicitly set Content-Type header to text/html (diff) | |
parent | Support for host categories bases on regular expression matching against host... (diff) | |
download | apt-panopticon_cgp-192cb0bc5381377dc6e646c68730d5d9b686cc8f.zip apt-panopticon_cgp-192cb0bc5381377dc6e646c68730d5d9b686cc8f.tar.gz apt-panopticon_cgp-192cb0bc5381377dc6e646c68730d5d9b686cc8f.tar.bz2 apt-panopticon_cgp-192cb0bc5381377dc6e646c68730d5d9b686cc8f.tar.xz |
Merge pull request #127 from mnellemann/master
Support for host categories based on regular expression matching
Diffstat (limited to '')
-rw-r--r-- | index.php | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -13,11 +13,30 @@ $h = array(); | |||
13 | # show all categorized hosts | 13 | # show all categorized hosts |
14 | if (isset($CONFIG['cat']) && is_array($CONFIG['cat'])) { | 14 | if (isset($CONFIG['cat']) && is_array($CONFIG['cat'])) { |
15 | foreach($CONFIG['cat'] as $cat => $hosts) { | 15 | foreach($CONFIG['cat'] as $cat => $hosts) { |
16 | host_summary($cat, $hosts); | 16 | |
17 | $h = array_merge($h, $hosts); | 17 | if(is_array($hosts)) { |
18 | host_summary($cat, $hosts); | ||
19 | $h = array_merge($h, $hosts); | ||
20 | } else { | ||
21 | // Asume regexp | ||
22 | $regexp = $hosts; | ||
23 | $ahosts = collectd_hosts(); | ||
24 | $rhosts = array(); | ||
25 | |||
26 | foreach($ahosts as $host) { | ||
27 | if(preg_match($regexp, $host)) { | ||
28 | array_push($rhosts, $host); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | host_summary($cat, $rhosts); | ||
33 | $h = array_merge($h, $rhosts); | ||
34 | } | ||
35 | |||
18 | } | 36 | } |
19 | } | 37 | } |
20 | 38 | ||
39 | |||
21 | # search for uncategorized hosts | 40 | # search for uncategorized hosts |
22 | if(!$chosts = collectd_hosts()) | 41 | if(!$chosts = collectd_hosts()) |
23 | printf('<p class="warn">Error: No Collectd hosts found in <em>%s</em></p>', $CONFIG['datadir']); | 42 | printf('<p class="warn">Error: No Collectd hosts found in <em>%s</em></p>', $CONFIG['datadir']); |