Showing posts with label Diskspace. Show all posts
Showing posts with label Diskspace. Show all posts

Wednesday, February 17, 2016

Monitor DPM Storage Pool

Hi,

I've created a small PowerShell-script that is ready to be used as a Performance Rule in System Center Operations Manager to monitor the amount of freespace in the storage pool on your DPM-server.

I will post a complete guide later on how to create the rule in SCOM!



-----------------------------------

#Load the MOMScript API and the PropertBag provider
$API = New-Object -comObject "MOM.ScriptAPI"
$bag = $api.CreatePropertyBag()

#Log an event at script-start
$api.LogScriptEvent("FreeDiskSpace.ps1",3280,0,"Collect FreeSpace in DPM-storagepool Script is starting")

#Main PowerShell-script
$FS = get-dpmdisk | where {$_.DiskTypeLabel -ne "Basic"} | Select UnallocatedSpaceLabel | ft -HideTableHeaders| Out-String -Stream
$FS = $FS | ForEach-Object {$_ -replace "GB", ""} 
$FreeSpace = ($FS | Measure-Object -Sum | select sum | ft -HideTableHeaders | Out-String).trim()

$TS = get-dpmdisk | where {$_.DiskTypeLabel -ne "Basic"} | Select TotalCapacityLabel | ft -HideTableHeaders| Out-String -Stream
$TS = $TS | ForEach-Object {$_ -replace "GB", ""} 
$TotalSpace = ($TS | Measure-Object -Sum | select sum | ft -HideTableHeaders | Out-String).trim()

#Add the data into the PropertyBag
$bag.AddValue("FreeSpace",$FreeSpace)
$bag.AddValue("TotalSpace",$TotalSpace)

#Log an event that our script is complete
$api.LogScriptEvent("FreeDiskSpace.ps1",3281,0,"Collect FreeSpace in DPM-storagepool Script is complete.  
$FreeSpace GB of $TotalSpace GB free in diskpool on $env:computername")

#Output the PropertyBag data for SCOM consumption
$bag

-----------------------------------


Kind Regards
Markus Eliasson