Data Source Monitoring Script for OpsMgr (Cookdown)

  • RSS
  • Subscribe

Statistics

  • Entries (6)
  • Comments (0)
Posted by David Friday, August 13, 2010 1:00:00 PM Categories: PowerShell Scripts
Rate this Content 0 Votes
This script is for use in a Operations Manager monitor and requires the DPM Server Name to be passed to it.  For full details on how to use this script, see the article "Monitoring DPM using OpsMgr, Cookdown & PowerShell" here, http://www.scdpmonline.org/monitoring-dpm-using-opsmgr-cookdown-powershell.aspx.
View the script below or click here to download it.
I don't confess to being a PowerShell guru and I'm sure this script could be made more efficient.  If your PoSh skills are better than mine and you have suggestions for improving this, please let me know using the PowerShell Forum.  Thank you.


----------
param([string] $DPMServerName)

$scomapi = new-object -comObject "MOM.ScriptAPI"$scombag = $scomapi.CreatePropertyBag()
$logerror = 1$logwarning = 2$loginfo = 4
$scriptname = "DTTCheckDataSourceState.ps1"
If(!$DPMServerName)
{
$scomapi.LogScriptEvent($scriptname, 5800, $loginfo, "No DPM server name supplied, exiting script")
Exit 0
}
$dsl = Get-Datasource -DPMServerName $DPMServerName | Where-Object {$_.Protected -eq "True"}
If(!$dsl)
{
$scomapi.LogScriptEvent($scriptname, 5800, $loginfo, "No protected data sources found")
}

Foreach($ds in $dsl)
{
If($ds.Type.Name -eq "Volume")
{
If($ds.state -eq "Valid")
{
$state = "OK"
}
Elseif($ds.state -eq "Invalid")
{
If($ds.activity -eq "Validating")
{
$state = "OK"
}
Else
{
$state = "ERROR"
}
}
}
ElseIf($ds.Type.Name -match "SQL*")
{
If($ds.state -eq "Valid")
{
$state = "OK"
}
ElseIf($ds.state -eq "Invalid")
{
If($ds.activity -eq "Validating")
{
$state = "OK"
}
Else
{
$state = "ERROR"
}
}
}
EelseIf($ds.Type.Name -eq "FileGroup")
{
If($ds.state -eq "Valid")
{
$state = "OK"
}
ElseIf($ds.state -eq "Invalid")
{
If($ds.activity -eq "Validating")
{
$state = "OK"
}
Else
{
$state = "ERROR"
}
}
}
ElseIf($ds.Type.Name -eq "Storage group")
{
If($ds.state -eq "Valid")
{
$state = "OK"
}
ElseIf($ds.state -eq "Invalid")
{
If($ds.activity -eq "Validating")
{
$state = "OK"
}
Else
{
$state = "ERROR"
}
}
}
elseif($ds.Type.Name -eq "Sharepoint farm")
{
if($ds.state -eq "Valid")
{
$state = "OK"
}
elseif($ds.state -eq "Invalid")
{
if($ds.activity -eq "Validating")
{
$state = "OK"
}
else
{
$state = "ERROR"
}
}
}
elseif($ds.Type.Name -eq "Windows Sharepoint Services Search")
{
if($ds.state -eq "Valid")
{
$state = "OK"
}
elseif($ds.state -eq "Invalid")
{
if($ds.activity -eq "Validating")
{
$state = "OK"
}
else
{
$state = "ERROR"
}
}
}
elseif($ds.Type.Name -eq "Exchange Mailbox Database")
{
if($ds.state -eq "Valid")
{
$state = "OK"
}
elseif($ds.state -eq "Invalid")
{
if($ds.activity -eq "Validating")
{
$state = "OK"
}
else
{
$state = "ERROR"
}
}
}
elseif($ds.Type.Name -eq "System Protection")
{
if($ds.state -eq "Valid")
{
$state = "OK"
}
elseif($ds.state -eq "Invalid")
{
if($ds.activity -eq "Validating")
{
$state = "OK"
}
else
{
$state = "ERROR"
}
}
}
else
{
$scomapi.LogScriptEvent($scriptname, 5802, $loginfo, "Datasource type $($ds.Type.Name) for $($ds.Name) is not recognised")
}
$bag = $scomapi.CreatePropertyBag()
$bag.AddValue('DatasourceName',$ds.name)
$bag.AddValue('ProductionServerName',$ds.ProductionServerName)
$bag.AddValue('Status',$state)  $bag.AddValue('DSID',$ds.id.guid)

$bag
}

Copyright 2010 SCDPMOnline.org
Share This Using Popular Bookmarking Services
You must sign in to this site to post comments.
Site Map | Printable View | © 2008 - 2012 SCDPM Online |

Locations of visitors to this page

Powered by mojoPortal | HTML 5 | CSS | design by dcarter