Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: measure Win32 disk fragmentation with Perl?

by paulbort (Hermit)
on Apr 26, 2004 at 19:15 UTC ( #348308=note: print w/replies, xml ) Need Help??

in reply to measure Win32 disk fragmentation with Perl?

Assuming you are at at least Windows 2000, SysInternals has a sample defrag with API explanation at their site.

They tend to have lots of good low-level Win32 hacking tools.

Spring: Forces, Coiled Again!
  • Comment on Re: measure Win32 disk fragmentation with Perl?

Replies are listed 'Best First'.
Solved! Re: Re: measure Win32 disk fragmentation with Perl?
by McMahon (Chaplain) on Apr 29, 2004 at 14:24 UTC
    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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://348308]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2019-07-17 12:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found