Page 1 of 2

small problem i think

Posted: Fri Jun 11, 2004 10:20 pm
by hward

Code: Select all

$str = file_get_contents("/proc/mdstat"); 
preg_match("/.*resync = ([0-9.]*)%.*finish=([0-9.]*)min/m", $str, $matches);

//$str = file_get_contents("/proc/mdstat"); 
//preg_match("/.*resync = ([0-9.]*)%.*finish=([0-9.]*)min/m", $str, $matches); 
//echo "resync = $matches[1]%\nfinish=$matches[2]min\n"; 

if( $matches[1] > '0' )
{
need my if statement to go when the resync value is about 0 but it is not going until it is at 10

what am i missing here

everything works fine once it gets past 10

Posted: Sat Jun 12, 2004 8:30 am
by jason
About 0? What do you mean about 0? 0 would be

Code: Select all

if( $matches[1] == '0' )

Posted: Sat Jun 12, 2004 9:44 am
by hward
the if statement isn't the problem

Code: Select all

<?php
  $str = file_get_contents("/proc/mdstat", "r"); 
preg_match("/.*active raid1.*resync = (&#1111;0-9.]*)%.*finish=(&#1111;0-9.]*)min/m", $str, $matches); 
echo "resync = $matches&#1111;1]%\nfinish=$matches&#1111;2]min\n";

?>
Even this only starts to return after the resync is above 10%

Posted: Sat Jun 12, 2004 9:56 am
by hward

Code: Select all

<?php

$str = file_get_contents("/proc/mdstat"); 
preg_match("/.*resync = (&#1111;0-9.]*)%.*finish=(&#1111;0-9.]*)min/m", $str, $matches); 
echo "resync = $matches&#1111;1]%\nfinish=$matches&#1111;2]min\n"; 


?>
I ment to send this one

Posted: Sat Jun 12, 2004 10:37 am
by feyd
have you tried changing it to a float before checking against it?

Posted: Sat Jun 12, 2004 11:48 am
by hward
no i haven't i not sure how to change it to a float

Posted: Sat Jun 12, 2004 1:11 pm
by feyd
$matches[1] = (float)$matches[1];
$matches[2] = (float)$matches[2];

Posted: Sat Jun 12, 2004 1:16 pm
by hward
still nothing

Posted: Sat Jun 12, 2004 1:18 pm
by hward
this is what its reading before resync gets up to 10.0%

Personalities : [raid1] read_ahead 1024 sectors md0 : active raid1 hde1[1] hdg1[0] 39078016 blocks [2/2] [UU] [>....................] resync = 2.4% (942896/39078016) finish=61.4min speed=10333K/sec unused devices:

after 10%

Personalities : [raid1] read_ahead 1024 sectors md0 : active raid1 hde1[1] hdg1[0] 39078016 blocks [2/2] [UU] [======>..............] resync = 34.9% (13670876/39078016) finish=41.0min speed=10324K/sec unused devices:

Posted: Sat Jun 12, 2004 1:41 pm
by feyd
try (untested)

Code: Select all

preg_match('#resync\s*?=\s*?([\d.]+?)%.*?finish\s*?=\s*?([\d.]+?)\s*?min#is', $str, $matches);
print_r($matches);

Posted: Sat Jun 12, 2004 2:00 pm
by hward
prints Array ( )

Posted: Sat Jun 12, 2004 2:07 pm
by hward
actually it prints

Array ( [0] => resync = 8.6% (3395120/39078016) finish=59.4min [1] => 8.6 [2] => 59.4 )

i forgot to ad

$str = file_get_contents("/proc/mdstat");

Posted: Sat Jun 12, 2004 2:14 pm
by hward
think it works now

Code: Select all

<?php
  	
	$str = file_get_contents("/proc/mdstat");	  
	preg_match('#resync\s*?=\s*?([\d.]+?)%.*?finish\s*?=\s*?([\d.]+?)\s*?min#is', $str, $matches); 

?>
<html><body>
<? echo "$matches[1]"; ?><br>
<? echo "$matches[2]"; ?>
</body></html>


?>

?>

Posted: Sat Jun 12, 2004 2:35 pm
by John Cartwright
get in the habbit of using EDIT function

Posted: Sat Jun 12, 2004 3:09 pm
by hward
man i am just not grasping all of this

Code: Select all

<?php
 preg_match('#resync\s*?=\s*?([\d.]+?)%.*?finish\s*?=\s*?([\d.]+?)\s*?min#is', $str, $matches);

?>
How can I pull out the : active raid1 hde1[1] hdg1[0] out and have the

$matches[1] = hde1[1]
$matches[2] = hde1[0]

Personalities : [raid1] read_ahead 1024 sectors md0 : active raid1 hde1[1] hdg1[0] 39078016 blocks [2/2] [UU] [======>..............] resync = 34.9% (13670876/39078016) finish=41.0min speed=10324K/sec unused devices: