Low Disk Space Incident Workflow

The local C: partition running out of free space is a very common incident that Service Desk teams have to deal with. In this article, I am going to show you how you can use SCSM together with the SCCM connector to build a workflow which will automatically raise new incidents when the free space on the C: drive on any client computer in your CMDB goes below a certain capacity.

Let me start with a disclaimer: I know that the monitoring guys out there might laugh at this post, claiming that this is a job for a monitoring tool such as SCOM. However, I am writing this post as there are customers out there who do not have a monitoring solution in place for clients. If you have SCOM plus the necessary SCOM Client CALs, you are certainly better off implementing the actual monitoring with SCOM and then using the SCOM alert connector to SCSM to raise the incidents.

Prerequisites: You must have a working SCCM connector running in your environment. Furthermore, the SMLets must be installed on the SCSM Management Server (SCSM PowerShell Cmdlets).

Part of the hardware inventory in SCCM is the information about your computers’ disks, their capacity and the free space. This information is imported into the SCSM CMDB to the Logical Disk class, which is related to the computers. You can find this information under “Logical hard drives” on the “Hardware” tab of the Computer form.

image

Let us build a workflow which raises a new incident whenever the free space on any C: drive goes below 1GB.

  1. Open the Authoring Tool and create a new Management Pack.
  2. Add a workflow to the Management Pack and give it a name.
  3. Choose “Run only when a database object meets specified conditions” as the trigger condition.
  4. Choose “Logical Disk (concrete)” as the class, and “When an object of the selected class is updated” as the change event.
  5. Under “Additional Criteria”, set Changed From to “Free Space is greater than or equal to 1000”, and set Changed To to “Free Space less than 1000” AND “Device Name equals C:”

    image

  6. Drag a “Windows PowerShell Script” Activity to the workflow and give it a name.

  7. In the Details window, click “Script Body” to edit the PowerShell script.

  8. First of all, we are going to need the ID of the logical disk which triggered the workflow as a parameter. So go to “Script Properties” and add a parameter called ID pointing to the “ID (Internal)” property.

    image

  9. Now, let us add the PowerShell script to the “Script Body”. You can copy the PowerShell code from further below in this post.

    image

  10. Save the Management Pack.

  11. In the directory where you stored your Management Pack, locate the [WorkflowName].dll DLL file. Copy this file to the Service Manager program directory (normally C:\Program Files\Microsoft System Center 2012\Service Manager).

  12. Now, import the Management Pack into SCSM and have fun with the workflow Smile

PowerShell script:

set-executionpolicy -executionPolicy ByPass -force
$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module SMLets -ErrorVariable err -force}

$class = Get-SCSMClass Microsoft.Windows.Computer$
$disk = Get-SCSMClass  Microsoft.Windows.Peripheral.LogicalDisk$

$p = Get-SCSMObject -class $disk -filter "Id -eq $ID" | select principalname
$hostname = $p.principalname
$computer = Get-SCSMObject -class $class -filter "PrincipalName -eq $hostname"

New-SCSMIncident -Title "Low free disk space on C:" -Description "Drive C: of computer $hostname is running low on free disk space." -Impact Low -Urgency Low -Classification "Hardware" -AffectedCIs $computer

Remove-Module SMLets -Force

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: