[PATCH] verify_blkparse: missing line break
[blktrace.git] / verify_blkparse
1 #!/usr/bin/php -q
2
3 <?php
4
5 // Parse time correctness of blkparse output
6 // Thomas Kenne <thomas@2ndfloor.dk>
7
8 if (!isset($argv[1])) {
9         die("need file as argument\n");
10 }
11
12 $file = $argv[1];
13
14 if (!is_file($file)) {
15         die("invalid file\n");
16 }
17
18 if (!is_readable($file)) {
19         die("file not readable\n");
20 }
21
22 $lastnum = false;
23 $fp = fopen($file, 'r');
24 while ($line = fgets($fp, 200)) {
25         $line = trim($line);
26         if ($line == '') {
27                 break;
28         }
29
30         $data = preg_split("/[\s]+/", $line);
31
32         $num = $data[3];
33         settype($num, 'float');
34
35         if ($lastnum && $num < $lastnum) {
36                 echo "$line\n";
37                 flush();
38         } else {        
39                 $lastnum = $num;
40         }
41 }
42
43 fclose($fp);
44
45 ?>