If you have been using Operations Manager 2012 for a little while you have probably had that moment when you log into your servers on a Monday morning and see a plethora of new warning alerts related to fragmentation levels on drives. This is one of those items that generates a lot of alerts and is often disabled rather than tackling the underlying issue. Since the Operations Manager 2007 book, I have been interested in using Operations Manager to automate common tasks (as a matter of fact, the favorite chapter I wrote in that book is called “Automatically Adapting Your Environment” and it’s exciting to see this and other steps that are being taken towards the ideas presented in that chapter).
Most of this year when I could get spare time I’ve been working on providing an automated method to defragment servers based upon the alerts which Operations Manager raises for high fragmentation levels. This management pack is a relatively simple management pack which provides for automation of defragmentation in most of the scenarios that I have seen for companies. To determine whether you would want to use this management pack or not, I see five different approaches that may apply related to an organization’s requirements related to disk fragmentation.
1) We do not want to automate defragmentation, but we want to be alerted to when drives are highly fragmented. We will choose to manually defragment highly fragmented drives if required. This is the default configuration for the management pack and if this is working for you you do not want to use the automated defragmentation management pack.
2) We want to ignore disk fragmentation levels completely. In some environments, fragmentation levels have been determined to not require any form of defragmentation. This is often chosen the approach taken in organizations where the drives are residing on a SAN and there is no benefit expected from defragmenting the drive. An example of this discussion is available at: http://social.technet.microsoft.com/Forums/windowsserver/en-US/836e49b1-d36c-4012-86da-b47d4c8ee661/defrag-virtual-machine-on-san. My recommendation is to test performance before and after the defragmentation of a system to see if there are impacts on the performance of the system from defragmenting the drive. For organization which do not want to be alerted on fragmentation levels I recommend disabling the monitors for fragmentation (“Logical Disk Fragmentation Level”) within Operations Manager by creating an override to disable this functionality for all objects.
3) We want to autodefragment all drives. If you want to automatically defragment all drives this is the default configuration for Operations Manager once you import the automated defragmentation management pack. This is especially useful in environments such as labs where you want a “set it and forget it” approach to defragmentation. I do not recommend using automated defragmentation if you are using block level backups as defragmenting will change the block locations and impact the backups. If you want to autodefragment all drives in your environment, you will want to install the automated defragmentation management pack.
4) We want to autodefragment all drives but disable monitoring for fragmentation on specific drives . The automated defragmentation management pack facilitates this approach by providing two groups: “Drives to Autodefragment” and “Drives to disable fragmentation monitoring”. By adding drives to the “Drives to disable fragmentation monitoring” alerts about fragmentation are disabled and no automated defragmentation occurs on those drives. If you want to autodefragment all drives but disable monitoring for specific drives in your environment, you will want to install the automated defragmentation management pack.
5) We want to autodefragment all drives but disable automated defragmentation on specific drives. The automated defragmentation management pack facilitates this approach by providing two groups: “Drives to Autodefragment” and “Drives to disable fragmentation monitoring”. By adding the drives to the exclusions for the “Drives to Autodefragment” group, you will continue to receive alerts about the drive’s fragmentation but automated defragmentation will not occur for those drives. If you want to autodefragment all drives but not automatically defragment specific drives in your environment, you will want to install the automated defragmentation management pack.
What is the default behavior for Operations Manager related to disk fragmentation?
The default behavior in Operations Manager is to raise alerts on high levels of fragmentation Saturday at 3:00 am as shown with the monitor below.
The alerts are raised as warnings such as the one shown below:
There are tasks available when you highlight the alert which you can use to defragment the drive as shown below.
These alerts will stay open until the disk has been defragmented and successfully found to not be in a fragmented state at the 3 am check on Saturday morning. Realistically this means that the alerts will stay open forever unless you manually defragment the drive (or run the task to defragment the drive) and reset the health state of the monitor for that drive.
What happens once you add the automated defragmentation management pack?
After importing the management pack: When you add the automated defragmentation pack, two groups are created as shown below:
The “Drives to AutoDefragment” group includes all drives identified for Windows 2003, Windows 2008 or Windows 2012 systems as shown below:
Monday at noon: This pack will automatically reset the monitors for fragmentation to healthy at noon on Monday. This process also closes out any existing alerts for high fragmentation. This is done through an embedded PowerShell script written by John Curtiss and shown below:
$FragMonitors=Get-SCOMMonitor | where {$_.DisplayName -eq ‘Logical Disk Fragmentation Level’}
foreach ($FragMonitor in $FragMonitors) {
get-scomclass -name $FragMonitor.target.identifier.path |
Get-SCOMClassInstance | where {$_.HealthState.value__ -gt 1} |
foreach {$_.ResetMonitoringState($FragMonitor)}
}
Saturday at 3:00 am: When the monitor re-checks fragmentation status (Saturday at 3:00 am by default) and drives are found to be fragmented two actions occur.
1) An event is written to the event log on the server where the defragmentation will run using a diagnostic. This event is used to track what automated defragmentations have occurred in the environment.
2) An automated defragmentation is activated. This is done by enabling the existing recovery to defragment the drive with an override which is included in the automated defragmentation management pack.
Monday at noon: The monitors are reset and the process is ready to occur again the next week.
What’s included in the management pack?
Views:
There are five views included in this management pack. The first one “Drives defragmented by Operations Manager” is an event view which shows any events logged from the recovery task. The second “Logical Disk Health” is an Operations Manager 2007 R2 style dashboard which includes the other three views (Windows Server 2003 Logical Disks, Windows Server 2008 Logical Disk and Windows Server 2012 Logical Disks).
Rules:
There are two rules included in this management pack. “Reset Disk Fragmentation Health” which runs an embedded PowerShell script weekly to reset the health state of the fragmented drives. And “Collect autodefragmentation event information” which gathers the events logged to the event log on the system when a drive is autodefragmeted by this management pack.
Groups:
There are two groups included in this management pack: “Drives to AutoDefragment” and “Drives to disable fragmentation monitoring”. The two group approach provides a way that the OpsMgr administrator can approach any of the common disk defragmentation requirements that I have run into:
1) I don’t want to know if this drive is fragmented: Add the drive to the “Drives to disable fragmentation monitoring” group.
2) I want to know the drive is fragmented but don’t want to autodefragment the drive. Add the drive to the exclusions section of the “Drives to AutoDefragment” group.
Overrides:
There are six overrides included in this management pack. There is one for each of the operating system management packs (2003, 2008, 2012), so these are actually two sets of three overrides. The first three overrides disable monitoring of fragmentation for any members of the “Drives to disable fragmentation monitoring” group. The second three overrides enable the built-in recovery in Operations Manager to defragment a drive.
Current known management pack issues: The built-in report does not work because the source is blank. This report can be rebuilt by using the Microsoft Generic Report Library/Event Analysis report with the following parameters:
Where can I download this management pack? This pack is available for download at http://www.systemcentercentral.com/pack-catalog/automated-defragmentation-management-pack/.
Summary: The automated defragmentation management pack makes it simple to automate the process to defragment drives in Operations Manager and provides flexibility for drives that you do not want to automate defragmentation. Thank you to John Curtiss for his writing of the PowerShell script which resets these monitors and his embedding this script into the management pack! Your comments, thoughts or enhancement requests would be interesting – let me know with a comment on this blog post!