diff options
Diffstat (limited to 'inc/collectd.inc.php')
-rw-r--r-- | inc/collectd.inc.php | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index fa1cb85..327b5e6 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php | |||
@@ -23,17 +23,16 @@ function collectd_hosts() { | |||
23 | # return files in directory. this will recurse into subdirs | 23 | # return files in directory. this will recurse into subdirs |
24 | # infinite loop may occur | 24 | # infinite loop may occur |
25 | function get_host_rrd_files($dir) { | 25 | function get_host_rrd_files($dir) { |
26 | |||
27 | $files = array(); | 26 | $files = array(); |
28 | 27 | ||
29 | $objects = new RecursiveIteratorIterator( | 28 | $objects = new RegexIterator( |
29 | new RecursiveIteratorIterator( | ||
30 | new RecursiveDirectoryIterator($dir), | 30 | new RecursiveDirectoryIterator($dir), |
31 | RecursiveIteratorIterator::SELF_FIRST); | 31 | RecursiveIteratorIterator::SELF_FIRST), |
32 | '/\.rrd$/'); | ||
32 | 33 | ||
33 | foreach($objects as $name => $object) { | 34 | foreach($objects as $object) { |
34 | if ( $object->getExtension() == 'rrd') { | 35 | $files[] = str_replace($dir.'/', '', $object->getPathname()); |
35 | $files[] = $object->getPathname(); | ||
36 | } | ||
37 | } | 36 | } |
38 | 37 | ||
39 | return $files; | 38 | return $files; |
@@ -48,7 +47,7 @@ function collectd_plugindata($host, $plugin=NULL) { | |||
48 | return false; | 47 | return false; |
49 | 48 | ||
50 | $hostdir = $CONFIG['datadir'].'/'.$host; | 49 | $hostdir = $CONFIG['datadir'].'/'.$host; |
51 | $files = get_host_rrd_files( $hostdir ); | 50 | $files = get_host_rrd_files($hostdir); |
52 | if (!$files) | 51 | if (!$files) |
53 | return false; | 52 | return false; |
54 | 53 | ||