Thanks
paulbort!
SysInternals has a tool called "contig" that was close enough that with a little Perl, I could make it Do The Right Thing.
contig reports the number of fragments that comprise each file in a directory. It's normal output was surprisingly unreliable-- it skipped files apparently randomly sometimes-- but the verbose output seems to be more consistent. Also, it doesn't run continuously. In order to get a picture of fragmentation over time, the user has to run contig manually over and over.
So I wrote a little controller script in Perl that runs contig every 5 seconds in verbose/recursive/analyze mode, parses the output, and writes the interesting parts to an output file. Here's the script:
use warnings;
use strict;
open OUT, ">out.txt";
while (1) {
$| = 1;
my @out = qx/contig.exe -a -s -v *"/;
foreach my $line(@out) {
if ($line =~ "is in") {
print OUT $line;
}
}
sleep 5;
print OUT "\n";
I was pleasantly surprised to find that @out actually contained what I wanted it to. Made parsing the output really easy.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.