We had a few issues recently where SnapManager for Exchange and SnapDrive were failing to communicate properly which resulted in a weeks worth of missed snapshots before anyone realised what was going on.
I wrote this script to report on the status of snapshots. The filer name is passed as a variable and a list of volume names is stored as a variable at the top of the script. The output is nicely formatted email.
- The script uses SSH to connect to the filer (see my SSH guide for Netapp filers)
- For each vol listed in the array, the list of snapshots is returned
- Any line with “__daily” in is processed – all others are ignored (we only care about our nightly verified snapshots which are all named __daily)
- The snapshot name contains the date/time it was taken – this is read and if the date is within 24 hours of now a success is return (since reports are run the day after the verified job). If the date is over 24 hours a failure is returned.
- A nicely formated HTML email is sent out which looks a little something like this…
Please see below for today’s backup report.
| VOL Name | Status | Snapshot name |
| Vol_Exc02_DB | Success | 0% ( 0%) 0% ( 0%) Mar 02 01:44 exchsnap__exchange02_03-01-2010_23.00.14__daily (busy,backup[0],dump) |
| Vol_Exc02_LOG | Success | 0% ( 0%) 0% ( 0%) Mar 02 04:38 eloginfo__exchange02_03-01-2010_23.00.14__daily |
| Vol_Exc02_DB1 | Success | 0% ( 0%) 0% ( 0%) Mar 01 23:00 exchsnap__exchange02_03-01-2010_23.00.14__daily |
| Vol_Exc02_LOG1 | Success | 1% ( 0%) 0% ( 0%) Mar 02 01:27 eloginfo__exchange02_03-01-2010_23.00.14__daily |
| Vol_Exc03_DB | Success | 1% ( 1%) 0% ( 0%) Mar 02 00:50 exchsnap__exchange03_03-01-2010_23.00.13__daily |
| Vol_Exc03_LOG | Success | 0% ( 0%) 0% ( 0%) Mar 02 02:06 eloginfo__exchange03_03-01-2010_23.00.13__daily |
| Vol_Exc03_DB1 | FAILURE | 1% ( 1%) 0% ( 0%) Feb 26 23:00 exchsnap__exchange03_03-01-2010_23.00.13__daily |
| Vol_Exc03_LOG1 | FAILURE | 0% ( 0%) 0% ( 0%) Feb 26 00:32 eloginfo__exchange03_03-01-2010_23.00.13__daily |
See the script and HTML files after the jump…
Don’t forget to change the name of your mail server, your sending and recipient email addresses and, most importantly, the location of plink.exe and your DSA keys used to establish the SSH connection (although you could easily modify this script to use RSH instead).
snapReport.ps1 script
# ==============================================================================================
#
# NAME: Netapp filer snapshot reports
#
# AUTHOR: David Warburton
# DATE: 12/03/2009
#
# PARAMETERS: 1. $filer
# Specifies the name of the remote filer to connect to.
# example: snapReport.ps1 myfiler01
#
# ==============================================================================================
$debugPreference = "continue"
$errorActionPreference = "stop"
$filer = $Args[0]
$htmlFile = "D:\Logs\Exchange Snapshot Report\exchange_Snapshot.html"
$volumes = ("Vol_Exc02_DB", "Vol_Exc02_LOG", "Vol_Exc02_DB1", "Vol_Exc02_LOG1", "Vol_Exc03_DB", "Vol_Exc03_LOG", "Vol_Exc03_DB1", "Vol_Exc03_LOG1")
$header = get-content "header.html"
$header > $htmlFile
$today = get-date
function sendEmail() {
$eServer = new-object system.net.mail.smtpClient("mailserver.yourdomain.com")
$From = "youraddress@yourcompany.com"
$To = "backup_reports@yourcompany.com"
if ($checkType -eq "weekly") {
$title = "Weekly "
} else {
$title = "Daily "
}
$todayDate = [string] $today.day + "/" + [string] $today.month + "/" + [string] $today.year
$title += "Exchange snapshot Report for $todayDate"
$Body = get-content $htmlFile
$eMsg = new-object System.Net.Mail.MailMessage($from,$to,$Title,$body)
$eMsg.IsBodyHTML = $True
#$eMsg.cc.add($cc)
$eServer.send($eMsg)
}
function checkSnap($volName) {
$output = D:\Utils\PuTTY\plink.exe svc-ssh@$filer -i D:\Utils\PuTTY\id_dsa.ppk snap list $volName
$validsnap = $False
$snapname = ""
foreach ($line in $output){
if ($line.contains("__daily")) {
$sMonth = $line.substring(62, 2)
$sDay = $line.substring(65, 2)
$sYear = $line.substring(68, 4)
$sDate = [datetime] "$sMonth $sDay $sYear"
if (($sDate.date).addDays(1) -eq $today.date) {
$validsnap = $True
$snapname = $line
}
}
if ($validsnap) {
return $snapname
}
}
return $False
}
foreach ($vol in $volumes) {
$line = "<tr><td>$vol</td>"
$status = checkSnap $vol
if ($status -eq $false) {
$line += "<td><font color=red>FAILED</font></td>"
} else {
$line += "<td><font color=blue>Success</font></td>"
}
$line += "<td>$status</td></tr>"
$line >> $htmlFile
}
$footer = Get-Content "footer.html"
$footer >> $htmlFile
sendEmail
Here are the HTML bits for the header and footer of the email…
header.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Backup Report</title>
<style type="text/css">
body {
font-family: Calibri, Arial, Helvetica;
color: black;
font-size: xx-small;
background-color: #FFFFFF }
p {
font-size: x-small }
.big {
font-size: x-small;
font-weight: bold }
table {
padding: 0px ;
border-spacing: 2px ;
empty-cells: hide ;
border: 1px solid #AAAAAA }
td {
background-color: #EEEEEE;
vertical-align: top }
th {
background-color: #EEEEEE;
vertical-align: top ;
text-align: left}
</style>
</head>
<body>
<p>*** This email is now automatically generated ***<br><br><b>Please see below for today's backup report.</b></p>
<p>
<b>NOTE: </b><br/>
- Exchange and SQL snapshots are managed by SnapManager and are alerted independantly to this report.<br/>
- Not <u>all</u> snapshots are shown in these reports. Hourly snapshots are currently not reported upon.
</p>
<table>
<tr>
<th>VOL Name</th><th>Status</th><th>Number of Snapshots</th><th>Last snapshot taken</th>
</tr>
footer.html
</table> <br/> <p>Regards.</p> </body> </html>

This is a good looking script. Nice job.
Do you have any scripts to poll a netapp filer for free space and report the answer back to an html page?
Hi Brian,
Sadly not….and even more sadly, I’m not actively working with Netapp filers. Hopefully will be again soon but the best I have at the moment is a simulator running at home!
Keep an eye on the blgo though – as soon as I’m back on Netapps I’ll be sure to let everyone know
Dave