From ed15d949ac692dd64d85efb4782083ef89d41e1a Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Wed, 15 Dec 2010 17:57:42 +0000 Subject: [PATCH] commit sensor fix script that should have gone along with the previous ones git-svn-id: http://www.observium.org/svn/observer/trunk@1760 61d68cd4-352d-0410-923a-c4978735b2b8 --- fix-sensor-rrd.php | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 fix-sensor-rrd.php diff --git a/fix-sensor-rrd.php b/fix-sensor-rrd.php new file mode 100644 index 000000000..caf94e2d9 --- /dev/null +++ b/fix-sensor-rrd.php @@ -0,0 +1,84 @@ + 1) + echo(round(($i / $count) * 100, 2) . "% \r"); + } + + function sensor_getDirectoryTree( $outerDir, &$files = array()){ + + $dirs = array_diff( scandir( $outerDir ), Array( ".", ".." ) ); + foreach( $dirs as $d ){ + if( is_dir($outerDir."/".$d) ){ + sensor_getDirectoryTree($outerDir.'/'. $d, $files); + } else { + if ( (preg_match('/^fan-.*.rrd$/', $d)) || + (preg_match('/^current-.*.rrd$/', $d)) || + (preg_match('/^freq-.*.rrd$/', $d)) || + (preg_match('/^humidity-.*.rrd$/', $d)) || + (preg_match('/^volt-.*.rrd$/', $d)) || + (preg_match('/^temp-.*.rrd$/', $d)) ) + array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'. $d)); + + } + } + return $files; + } + + + function sensor_fixRdd($file){ + global $config; + global $rrdcached; + $fileC = shell_exec( "{$config['rrdtool']} dump $file $rrdcached"); + if(preg_match('/ fan/', $fileC)) + { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r fan:sensor"); + rename($file,str_replace('/fan-','/fanspeed-',$file)); + } + elseif(preg_match('/ volt/', $fileC)) + { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r volt:sensor"); + rename($file,str_replace('/volt-','/voltage-',$file)); + } + elseif(preg_match('/ current/', $fileC)) + { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r current:sensor"); + } + elseif(preg_match('/ freq/', $fileC)) + { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r freq:sensor"); + rename($file,str_replace('/freq-','/frequency-',$file)); + } + elseif(preg_match('/ humidity/', $fileC)) + { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r humidity:sensor"); + } + elseif(preg_match('/ temp/', $fileC)) + { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r temp:sensor"); + rename($file,str_replace('/temp-','/temperature-',$file)); + } + } + + echo("\n"); + +?> +