Commit | Line | Data |
---|---|---|
2671f35e TK |
1 | #!/usr/bin/php -q |
2 | ||
3 | <?php | |
4 | ||
5 | // Parse time correctness of blkparse output | |
6 | // Thomas Kenne <thomas@2ndfloor.dk> | |
7 | ||
8 | $file = $argv[1]; | |
9 | ||
10 | if (!is_file($file)) { | |
11 | die("invalid file\n"); | |
12 | } | |
13 | ||
14 | $lastnum = false; | |
15 | $fp = fopen($file, 'r'); | |
16 | while ($line = fgets($fp, 200)) { | |
17 | if (trim($line) == '') { | |
18 | break; | |
19 | } | |
20 | $data = preg_split("/[\s]+/", $line); | |
21 | $num = $data[4]; | |
22 | settype($num, 'float'); | |
23 | ||
24 | if ($lastnum && $num < $lastnum) { | |
25 | echo $line; | |
26 | flush(); | |
27 | } else { | |
28 | $lastnum = $num; | |
29 | } | |
30 | } | |
31 | ||
32 | fclose($fp); | |
33 | ||
34 | ?> |