function Analyze-Volumes([PSCustomObject]$volStatResp, [string]$metricName="readresponsetime")
{
try
{
# iterate over the analyzed volume stats
foreach ($line in $volStatResp)
{
$script:volumeCount++
$volumeName=$line.volumename
# slight of hand here - dereference the name of the metric so it can be accessed from the stat line.
$reading=$line.$($metricName)
# Formatting theReading changes the type from double to string.
# which means it cannot be compared (accurately) to the $Threshold
# limit.
$theFormattedReading = "{00:N4}" -f $reading
if ($Trace)
{
$m=@"
Array,Volume,$perfAbbrev,Metric,Threshold
$arrayName,$volumename,$theFormattedReading,$Metric,$Threshold
"@
Log $m
}
if ($reading -gt [double]$Threshold)
{
$volumeList.Add($volumeName,$theFormattedReading)
}
}
} catch [system.exception] {
# Fill out property bag with a message that stats were unable to be obtained.
# The array will
LogError "Exception getting vol stats for $arrayWwn"
continue
}
}
function Get-WebServerPort([string] $dir)
{
[xml]$wsConfig=Get-Content "$dir/webserver/wsconfig.xml" -ErrorAction SilentlyContinue
$val=$wsConfig.config.port
if ($val -eq $null)
{
LogError "Error parsing wsConfig.xml in $dir"
}
$val
}
# - - Script Start - - #
$script:volumeCount=0
# init a timer
$watch=[System.Diagnostics.Stopwatch]::StartNew()
# Get Disk System Data
$DSCredentials = @(Get-SDCredential -All)
# The logic is to iterate over array.
# For each array get analyzed volume statistics.
# The monitor (this script) will create a property bag for each array, not for
# each volume.
# While collecting volume stats, keep track of the volumes that exceed the
# threshold. The volumes will be posted in the alert for the storage array. If
# this cardinality is messed up (1 bag per volume, for instance), then the
# monitor on the RMS will always be 'Healthy'
# irm is a PoSH alias for Invoke-RestMethod.
# Call NetApp REST API
$statUrl="http://localhost:$wsPort/devmgr/v1/storage-systems/$arrayWWN/analysed-volume-statistics"
$statResp=irm -uri $statUrl -meth GET -credential $wsCred
$volStatResp = $statResp |Select-Object volumename,readresponsetime,writeresponsetime,readiops,writeiops,readthroughput,writethroughput
$volumeList=@{}
# Create propBag and fill out global stuff now
$bag = $api.CreatePropertyBag()
$bag.addValue("SSGUID",$DS.WWN)
$bag.addValue("PerformanceMetric",$Metric)
if ($Metric -eq "Volume Read Response")
{
$theReading= "readresponsetime"
$perfAbbrev="read response time (ms)"