{"id":554,"date":"2010-03-21T21:30:44","date_gmt":"2010-03-22T02:30:44","guid":{"rendered":"http:\/\/www.jasemccarty.com\/blog\/?p=554"},"modified":"2010-03-21T21:30:44","modified_gmt":"2010-03-22T02:30:44","slug":"netapp-snapmirror-monitor-script-part-2-using-poshontap","status":"publish","type":"post","link":"https:\/\/www.jasemccarty.com\/blog\/netapp-snapmirror-monitor-script-part-2-using-poshontap\/","title":{"rendered":"NetApp SnapMirror Monitor Script \u2013 Part 2 using PoshOnTap"},"content":{"rendered":"<p>My <strong><a title=\"NetApp SnapMirror Monitor Script \u2013 Part 1\" href=\"http:\/\/www.jasemccarty.com\/blog\/?p=500\" target=\"_self\">first attempt<\/a><\/strong> at this worked out pretty well, but I&#8217;ve been looking into <strong><a title=\"PoshOnTap\" href=\"http:\/\/poshontap.codeplex.com\/\" target=\"_blank\">PoshOnTap<\/a><\/strong>, and come up with a more efficient script.\u00a0 PoshOnTap is really something to look at if you have a NetApp, and are getting deeper into using Powershell.<\/p>\n<p>To get started, download PoshOnTap from <strong><a title=\"PoshOnTap\" href=\"http:\/\/poshontap.codeplex.com\/\" target=\"_blank\">http:\/\/poshontap.codeplex.com\/<\/a><\/strong>, and install it.<\/p>\n<p>Once PoshOnTap is installed, to use the cmdlets, it must be imported into your Powershell session using <strong>Import-Module PoshOnTap<\/strong><\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH01.png\"><img loading=\"lazy\" decoding=\"async\" title=\"Import-Module\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH01-150x150.png\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p>Now to connect to my second filer, the one that is performing the SnapMirror role, I need to connect to it.\u00a0 This is done with <strong>Connect-NaServer -Filer filername -UserName user -Password password<\/strong>. I&#8217;ve omitted the username and password, as my Filer is joined to my Active Directory Domain.\u00a0 My Powershell session is being run from an account which is part of the domain.<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH02.png\"><img loading=\"lazy\" decoding=\"async\" title=\"Connect To Filer\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH02-150x150.png\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p>In my previous post, I had to remotely execute a <strong>&#8220;snapmirror status&#8221;<\/strong> command using ssh through plink.\u00a0 Not very elegant.\u00a0 From the command line, &#8220;snapmirror status&#8221;, <em>will only show<\/em> Source, Destination, State, Lag, and Status.<\/p>\n<p>Using Powershell I can execute the same type command, and actually get  more  information. Information like:<\/p>\n<ul>\n<li> BaseTimeStamp (time of the last update)<\/li>\n<li>BaseSnaphot (name of the Snapshot on the destination filer)<\/li>\n<li>ContentState<\/li>\n<li>CurrentTransferSize (showing the size of a current transfer)<\/li>\n<li>CurrentTransferType<\/li>\n<li>LastTransferSize (how many bytes were transferred)<\/li>\n<li>LastTransferDuration (how long the last SnapMirror took)<\/li>\n<li>LastTransferType (Did an initialization occur? Did an update take place?)<\/li>\n<\/ul>\n<p>So how would I get the same information through Powershell?<\/p>\n<p>Get-NaSnapMirror by itself will show the same information as snapmirror status does, albeit in a different order.<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH03.png\"><img loading=\"lazy\" decoding=\"async\" title=\"Get-NaSnapMirror\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH03-150x150.png\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p>Now, if we change the output format from Format-Table (default) to Format-List (or FL) we will see some very different output.<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH04.png\"><img loading=\"lazy\" decoding=\"async\" title=\"Get-NaSnapMirror | FL\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH04-150x150.png\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p>Now to use some of that output for our monitoring.\u00a0 I created the following script to pull more information than my last script<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n#Load the PoshOnTap Module\nImport-Module PoshOnTap\n\n#Connect to the Filer\nConnect-NaServer -Filer netapp2\n\n#Pull Our Data\nget-NaSnapMirror|select Source,Destination,Status,State,Lag,LastTransferSize,LastTransferDurration|ft\n<\/pre>\n<p>Which returns<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH05.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-673\" title=\"List SnapMirror Information\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH05-150x150.png\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p>Now, to get the output into e-mail, I&#8217;m going to have to massage the output a little bit.\u00a0 Here&#8217;s the resulting script:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n#Load the PoshOnTap Module\nImport-Module PoshOnTap\n\n#Connect to the Filer\nConnect-NaServer -Filer netapp2\n\n#Pull The Data\n$body = Get-NaSnapMirror|Select Source,Destination,Status,State,Lag,LastTransferSize,LastTransferDurration|Out-String\n\n#Send e-mail\nSend-MailMessage -From &quot;user@yourdomain.com&quot; -To &quot;user@yourdomain&quot; -Subject &quot;NetApp Replication Script&quot; -SmtpServer mail.domain.com -Body $body\n<\/pre>\n<p>Which will give an output something like this:<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH061.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-676\" title=\"Sample Output\" src=\"http:\/\/www.jasemccarty.com\/blog\/wp-content\/uploads\/2010\/03\/POSH061-150x150.png\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p>Pretty cool how Powershell will let us use less code, and get more done.<\/p>\n<p>I can add <strong>&#8220;Where-Object { $_.Lag -gt &#8220;01:0:00&#8243;} |&#8221;<\/strong> between <strong>&#8220;Get-NaSnapMirror |&#8221; <\/strong>and <strong>&#8220;Select Source,&#8221;<\/strong> to only show the volumes that have a lag greater than 1 hour.\u00a0 Again, pretty flexible.<\/p>\n<p>Now I&#8217;m off to work on Part 3, where I post this information to a SQL database for historical purposes.<\/p>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 456px; width: 1px; height: 1px; overflow: hidden;\">Using Powershell I can execute the same command, and actually get more  information.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>My first attempt at this worked out pretty well, but I&#8217;ve been looking into PoshOnTap, and come up with a more efficient script.\u00a0 PoshOnTap is &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[56,64,72,81],"class_list":["post-554","post","type-post","status-publish","format-standard","hentry","category-virtualization","tag-netapp","tag-poshontap","tag-replication","tag-smvi"],"_links":{"self":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/comments?post=554"}],"version-history":[{"count":0,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/554\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/media?parent=554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/categories?post=554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/tags?post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}