aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/collectd.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--inc/collectd.inc.php25
1 files changed, 23 insertions, 2 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php
index 7269e68..fa1cb85 100644
--- a/inc/collectd.inc.php
+++ b/inc/collectd.inc.php
@@ -19,6 +19,27 @@ function collectd_hosts() {
19 return($dir); 19 return($dir);
20} 20}
21 21
22
23# return files in directory. this will recurse into subdirs
24# infinite loop may occur
25function get_host_rrd_files($dir) {
26
27 $files = array();
28
29 $objects = new RecursiveIteratorIterator(
30 new RecursiveDirectoryIterator($dir),
31 RecursiveIteratorIterator::SELF_FIRST);
32
33 foreach($objects as $name => $object) {
34 if ( $object->getExtension() == 'rrd') {
35 $files[] = $object->getPathname();
36 }
37 }
38
39 return $files;
40}
41
42
22# returns an array of plugins/pinstances/types/tinstances 43# returns an array of plugins/pinstances/types/tinstances
23function collectd_plugindata($host, $plugin=NULL) { 44function collectd_plugindata($host, $plugin=NULL) {
24 global $CONFIG; 45 global $CONFIG;
@@ -26,8 +47,8 @@ function collectd_plugindata($host, $plugin=NULL) {
26 if (!is_dir($CONFIG['datadir'].'/'.$host)) 47 if (!is_dir($CONFIG['datadir'].'/'.$host))
27 return false; 48 return false;
28 49
29 chdir($CONFIG['datadir'].'/'.$host); 50 $hostdir = $CONFIG['datadir'].'/'.$host;
30 $files = glob("*/*.rrd"); 51 $files = get_host_rrd_files( $hostdir );
31 if (!$files) 52 if (!$files)
32 return false; 53 return false;
33 54