Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Requires the Netapp Powershell toolkit installed
- # 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
- # Generate the credential file(Better than plain txt passwords in scripts) GET-CREDENTIAL –Credential “user-account” | EXPORT-CLIXML C:\SecureLocation\NetappSecureCredentials.xml
- Import-Module DataONTAP
- $ReportOutput ="<h1><center>NetApp Cluster Replication Report</center></h1>"
- $targetdate = (get-date)
- $credential= Import-Clixml C:\SecureLocation\NetappSecureCredentials.xml
- Connect-NcController -Name BackupFilerName -Credential $credential
- $ReportOutput += "<h2>Report run on: $targetdate</h2>"
- $ReportOutput += "<hr size=.5 width=100% align=left color='green'>"
- $ReportOutput += "<h2>SnapVault Relationship Health</h2>"
- $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
- $ReportOutput += $Results | sort lag -Descending | ConvertTo-HTML -Fragment
- $head= "<style>
- body {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;}
- table {border-collapse:collapse; border:#b1babf 1px solid; font:10pt Verdana, Geneva, Arial, Helvetica, sans-serif;color: black;}
- th {font-size: 12px; font-weight: bold; padding:5px 10px; text-align: left;border:#b1babf 1px solid;background-color:#A7C942;color:#fff;}
- td{font-size: 12px; padding:5px 5px; text-align: left;border:#b1babf 1px solid;}
- h1{ clear: both; font-size: 24pt; margin-left: 20px; margin-top: 30px;}
- h2{ clear: both;font-size: 115%; margin-left: 20px; margin-top: 30px;}
- h3{ clear: both;color:red; font-size: 115%; margin-left: 20px; margin-top: 30px;}
- h4{clear: both; color:green; font-size: 10pt;margin-left: 20px; margin-top: 30px;}
- h5{ clear: both; font-size: 16pt; margin-left: 20px; margin-top: 30px;}
- 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}
- table tr:nth-child(even) { background-color: #DBE5F1; }
- table tr:nth-child(odd) { background-color: #EAF1DD; }
- </style>"
- if($ReportOutput -ne $null)
- {
- $emailFrom = "SnapVaultReport@companyname"
- $emailTo = "BackupAlerts@companyname"
- $subject = "SnapVault Report"
- $body = "" | ConvertTo-HTML -head:$head -body:$ReportOutput | foreach {$PSItem -replace "<td>False</td>", "<td style='background-color:#FF8080'>False</td>"} | Out-string
- $smtpServer = "mail.server.com"
- Send-MailMessage -SmtpServer:$smtpServer -To:$emailTo -From:$emailFrom -Subject:$subject -Body:$body -BodyAsHtml
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement