SCOM 2007 R2 added a fragmentation analsysis health check that is producing warnings on many of my servers. To try to understand how SCOM is determines the fragmentation level, I created the following Powershell script that reproduces the same data:
$vols = Get-WmiObject -computername "Z002" Win32_Volume -filter "DriveType=3"
$defragInfo = $vols | %{$_.DefragAnalysis() | add-member -membertype noteproperty vname $_.name -passThru}
$defragInfo | %{$_.DefragAnalysis | add-member -membertype noteproperty DefragRecommended $_.DefragRecommended -passThru | add-member -membertype noteproperty vname $_.vname -passThru} | out-file ./tmp.txt
Sample output below. SCOM uses the FilePercentFragmentation number to warn on anything over 10%, what I'm wondering is how is the percentage calculated since it certainly isn't fragmented files divided by total files.
DefragRecommended : True
vname : I:\
AverageFileSize : 20277223990
AverageFragmentsPerFile : 1.11
ClusterSize : 4096
ExcessFolderFragments : 0
FilePercentFragmentation : 54
FragmentedFolders : 1
FreeSpace : 131237363712
FreeSpacePercent : 24
FreeSpacePercentFragmentation : 0
MFTPercentInUse : 10
MFTRecordCount : 65
PageFileSize : 0
TotalExcessFragments : 4
TotalFiles : 35
TotalFolders : 14
TotalFragmentedFiles : 2
TotalMFTFragments : 2
TotalMFTSize : 606208
TotalPageFileFragments : 0
TotalPercentFragmentation : 27
UsedSpace : 405626204160
VolumeName :
VolumeSize : 53686356787
I'm making an educated guess here, but I think it has to do with average fragmented file size (e.g. how many files are fragmented vs not), and their size as a percentage of total files.
For example, on one of my production servers, I have 0% fragmentation for all files bar one, which happens to be the database MDF file. The 60GB file is in two fragments, but the total fragmentation report states 73%.
Hope that makes sense.