It did work! I totally forgot to reply with the solution I came up with, it was actually rather simple.
#ndmp_threadmon.ps1
#NDMP Session Tracking
#Ryan McDougall
#2/6/2013
Import-Module DataONTAP
#Filer hostnames as strings
<filer hostname strings>
#Mail Stuff
$sendMailAs = ""
$recipients = ""
$subjectLine = "Backup Filer NDMP Threshold Warning!"
$smtpServer = "10.11.23.15"
$priority = "high"
#Script Params
$thread_thresh = "194"
$sw = new-object system.diagnostics.stopwatch
#Filers object
$backup_filers = <filer name variables>
foreach($filer in $backup_filers)
{
#Determine number of NDMP sessions
$lcount = (Invoke-NaSsh -Name $filer "ndmpd status" | Select-String -AllMatches "Session: " | foreach {$_.matches}|select value | Measure-Object).Count
#Determine if session count is greater than determined threshold (194 min for 3210's)
if($lcount -ige $thread_thresh)
{
#Start timer
$sw.start();
#Send initial message and track current filer
Send-MailMessage -To $recipients -From $sendMailAs -Subject $subjectLine -Body "The NDMP Thread count on $current_filer reached $lcount, this may require investigation - Time: $dateCurrent" -Priority $priority -SmtpServer $smtpServer
$current_filer = $filer
#Recheck loop
while($lcount -ige $thread_thresh)
{
#Kill script after 30 minutes
if($sw.elapsed.minutes -gt 30)
{
Send-MailMessage -To $recipients -From $sendMailAs -Subject $subjectLine -Body "The script has been running for 30 minutes or more, killing script. Please investigate NDMP issues." -Priority $priority -SmtpServer $smtpServer
exit
}
#Initiate recheck
$recheck = (Invoke-NaSsh -Name $filer "ndmpd status" | Select-String -AllMatches "Session: " | foreach {$_.matches}|select value | Measure-Object).Count
$dateCurrent = Get-Date
if($recheck -ige $lcount)
{
#Retry after 5 minutes
sleep -Seconds 300
Send-MailMessage -To $recipients -From $sendMailAs -Subject $subjectLine -Body "The NDMP Thread count on $current_filer is currently $lcount, please investigate. - Time: $dateCurrent" -Priority $priority -SmtpServer $smtpServer
}
else
{
#Send message if below threshold
Send-MailMessage -To $recipients -From $sendMailAs -Subject $subjectLine -Body "The NDMP Thread count on $current_filer has fallen to $recheck, which is below the threshold of $thread_thresh. Time: $dateCurrent" -Priority $priority -SmtpServer $smtpServer
}
}
}
elseif($lcount -lt $thread_thresh)
{
Send-MailMessage -To $recipients -From $sendMailAs -Subject $subjectLine -Body "$filer is currently below the NDMP session threshold." -Priority $priority -SmtpServer $smtpServer
}
}