aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--conf/config.php3
-rw-r--r--index.php23
2 files changed, 24 insertions, 2 deletions
diff --git a/conf/config.php b/conf/config.php
index ec55d30..0628bfe 100644
--- a/conf/config.php
+++ b/conf/config.php
@@ -18,6 +18,9 @@ $CONFIG['rrdtool_opts'] = array();
18# category of hosts to show on main page 18# category of hosts to show on main page
19#$CONFIG['cat']['category1'] = array('host1', 'host2'); 19#$CONFIG['cat']['category1'] = array('host1', 'host2');
20 20
21# category of hosts based on regular expression
22#$CONFIG['cat']['Mailservers'] = '/mail\d+/';
23
21# default plugins to show on host page 24# default plugins to show on host page
22$CONFIG['overview'] = array('load', 'cpu', 'memory', 'swap'); 25$CONFIG['overview'] = array('load', 'cpu', 'memory', 'swap');
23 26
diff --git a/index.php b/index.php
index b220241..71e09a0 100644
--- a/index.php
+++ b/index.php
@@ -13,11 +13,30 @@ $h = array();
13# show all categorized hosts 13# show all categorized hosts
14if (isset($CONFIG['cat']) && is_array($CONFIG['cat'])) { 14if (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
22if(!$chosts = collectd_hosts()) 41if(!$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']);