aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc
diff options
context:
space:
mode:
authorPim van den Berg2014-03-22 14:03:26 +0100
committerPim van den Berg2014-03-22 14:03:26 +0100
commita36eb12e230b7e52ea8466325edda1a13cec69a7 (patch)
treed0d1626310091d17a9eaa7e071732e64ed5c62a6 /inc
parentinc/collectd.inc.php: replace glob by php5 iterators (diff)
downloadapt-panopticon_cgp-a36eb12e230b7e52ea8466325edda1a13cec69a7.zip
apt-panopticon_cgp-a36eb12e230b7e52ea8466325edda1a13cec69a7.tar.gz
apt-panopticon_cgp-a36eb12e230b7e52ea8466325edda1a13cec69a7.tar.bz2
apt-panopticon_cgp-a36eb12e230b7e52ea8466325edda1a13cec69a7.tar.xz
inc/collectd.inc.php: use RegexIterator + strip $dir from result
Diffstat (limited to 'inc')
-rw-r--r--inc/collectd.inc.php15
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
25function get_host_rrd_files($dir) { 25function 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