Netapp Replication Report

a guest Feb 21st, 2018 24 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Requires the Netapp Powershell toolkit installed
  2. # Export credential to file. Restricted to user that created the file. If running this on a schedule make sure the .xml is generated with the account that will run the task  
  3. # Generate the credential file(Better than plain txt passwords in scripts) GET-CREDENTIAL –Credential “user-account” | EXPORT-CLIXML C:\SecureLocation\NetappSecureCredentials.xml
  5. Import-Module DataONTAP
  7. $ReportOutput ="<h1><center>NetApp Cluster Replication Report</center></h1>"
  8. $targetdate = (get-date)
  9. $credential= Import-Clixml C:\SecureLocation\NetappSecureCredentials.xml
  10. Connect-NcController -Name BackupFilerName -Credential $credential
  11. $ReportOutput += "<h2>Report run on: $targetdate</h2>"
  12. $ReportOutput += "<hr size=.5 width=100% align=left color='green'>"
  13. $ReportOutput += "<h2>SnapVault Relationship Health</h2>"
  14. $Results = Get-NcSnapmirror | Select-Object @{Name="RPO Meet";Expression={$_.Lagtime -lt 14400}}, SourceVolume, DestinationVolume, @{Name="Transfer Size MB"; Expression={"{0:N2}" -f ($_.LastTransferSize /1Mb)}} ,NewestSnapshotTimestampDT, NewestSnapshot,@{Name="Lag";Expression={[timespan]::fromseconds($_.LagTime).tostring()}}, IsHealthy
  15. $ReportOutput += $Results | sort lag -Descending | ConvertTo-HTML -Fragment
  18. $head= "<style>
  19. body {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;}
  20. table {border-collapse:collapse; border:#b1babf 1px solid; font:10pt Verdana, Geneva, Arial, Helvetica, sans-serif;color: black;}
  21. th {font-size: 12px; font-weight: bold; padding:5px 10px; text-align: left;border:#b1babf 1px solid;background-color:#A7C942;color:#fff;}
  22. td{font-size: 12px; padding:5px 5px; text-align: left;border:#b1babf 1px solid;}
  23. h1{ clear: both; font-size: 24pt; margin-left: 20px; margin-top: 30px;}
  24. h2{ clear: both;font-size: 115%; margin-left: 20px; margin-top: 30px;}
  25. h3{ clear: both;color:red; font-size: 115%; margin-left: 20px; margin-top: 30px;}
  26. h4{clear: both; color:green; font-size: 10pt;margin-left: 20px; margin-top: 30px;}
  27. h5{ clear: both; font-size: 16pt; margin-left: 20px; margin-top: 30px;}
  28. h6{BORDER-BOTTOM: #b1babf 1px solid; POSITION: relative; BORDER-LEFT: #b1babf 1px solid; BACKGROUND-COLOR: #0061bd; PADDING-LEFT: 5px; DISPLAY: block; FONT-FAMILY: Tahoma; HEIGHT: 2em; COLOR: #ffffff; MARGIN-LEFT: 0px; FONT-SIZE: 12pt; BORDER-TOP: #b1babf 1px solid; FONT-WEIGHT: bold; MARGIN-RIGHT: 0px; BORDER-RIGHT: #b1babf 1px solid; PADDING-TOP: 8px}
  29. table tr:nth-child(even) { background-color: #DBE5F1; }
  30. table tr:nth-child(odd) { background-color: #EAF1DD; }
  31. </style>"
  33. if($ReportOutput -ne $null)
  34. {
  35.     $emailFrom = "SnapVaultReport@companyname"
  36.     $emailTo = "BackupAlerts@companyname"
  37.     $subject = "SnapVault Report"
  38.     $body = "" | ConvertTo-HTML -head:$head -body:$ReportOutput | foreach {$PSItem -replace "<td>False</td>", "<td style='background-color:#FF8080'>False</td>"} | Out-string
  39.     $smtpServer = ""
  40.     Send-MailMessage -SmtpServer:$smtpServer -To:$emailTo -From:$emailFrom -Subject:$subject -Body:$body -BodyAsHtml
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!