Record/Compair Autosupport Settings for many controllers

by New Contributor on ‎2012-02-23 10:40 AM

This is a followup to a post listed here https://communities.netapp.com/docs/DOC-8907 which shows how to check two controllers against eachother to make sure the Autosupport settings match, and offers how to fix them, or can automatically fix them. This script is designed for those of us who have to manage a large farm of controllers, and have a known good controller that is perfect. This also helps site that want to enforce change control to make sure that settings dont change. Since many controllers are hard to compair on a PowerShell output screen, this tool exports the data to Excel. This also can be used/saved for future reference.

Script is as follows.

# This script will connect to a Storage Controller and retreive all
# of the AutoSupport Setttings. It will then connect to a second
# controller and compair those settings. The recommended changes will be shown.
# script now assumes an working controller that is set up correctly.
# it then points to a list of other controllers and lets you know if any of them differ

$workingController = "10.58.1.10"
$targetControllers= @("10.58.2.11","10.58.3.29","10.58.4.61")
$User = "root"
$Pass = "Password1"

$WCPass  = ConvertTo-SecureString $Pass -AsPlainText –Force
$Wcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$WCPass
$TCPass  = ConvertTo-SecureString $Pass -AsPlainText –Force
$Tcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$WCPass
$workops=new-object system.collections.arraylist
Connect-NaController $TargetController -Credential $Tcred

$suppress = $Targops = get-naoption autosupport.*
Write-host "------------------------------------------------"

$excel=new-object -comobject excel.application
$excel.Visible=$true
$workbooks=$excel.workbooks.add()
$worksheet=$workbooks.worksheets.item(1)

$worksheet.cells.item(1,1)="Option Name"
$worksheet.cells.item(1,1).font.bold=$true
$worksheet.cells.item(1,1).font.size=22
$worksheet.cells.item(2,1)="Controller Name"
$worksheet.cells.item(2,1).font.bold=$true
$worksheet.cells.item(2,1).font.size=22
$worksheet.cells.item(1,2)="Master FAS"
$worksheet.cells.item(1,2).font.bold=$true
$worksheet.cells.item(1,2).font.size=22
$worksheet.cells.item(2,2)=$WorkingController
$cellR=3
foreach($Controller in $TargetControllers)

{          Connect-NaController $Controller -Credential $Wcred
          $Workops.add( (get-naoption autosupport.* ) )
           $worksheet.cells.item(1,$cellr)="Target FAS"
           $worksheet.cells.item(1,$cellr).font.bold=$true
           $worksheet.cells.item(1,$cellr).font.size=22
           $worksheet.cells.item(2,$cellr++)=$controller
}
$worksheet.cells.item(1,$cellr)="Command to fix"


Write-host "------------------------------------------------"
$coun=2
foreach ($workop in $workops)
{     $coun=$coun+1
      $line=2
      $founditem=$false
      foreach ($item in $workop)
      {      $workname=$item.name
            $workval =$item.value
            foreach($titem in $targops)
            {     if ($titem.name -eq $item.name)
                  {      $line=$line+1
                        $foundvalue=$true
                        $worksheet.cells.item($line,1)=$titem.name
                        $worksheet.cells.item($line,2)=$titem.value
                        $worksheet.cells.item($line,$coun)=$item.value
                        write-host "   "$item.name"="$item.value    
                        if ($titem.value -ne $item.value)
                        {      write-host "   "$item.name"="$item.value" -Values Mismatch ="$titem.value
                              $worksheet.cells.item($line,$cellr)=("set-naoption"+$titem.name+" "+$item.value)
                              write-host "        To fix this issue, command is as follows;"
                              write-host "           set-naoption"$titem.name""$item.value
                        }
                  }
            }
      }
}
$workdoc=$worksheet.UsedRange
$workdoc.EntireColumn.Autofit() | out-null

The output from this script looks as follows.

Comments

Hi Chris,

This is a real good for us to compare options on our filers, I changed the older script in part 5 to show all filer options and created a server array instead of just the autosupport* like this:

$Workops = get-naoption (so it would display all options)

I tried to changed this new script to do the same thing so we could have it output to excel but it doesnt work like the script in Part 5, do you have any ideas on this? Also have the excel file saved to a disk so we can run it as a script and email it out would be nice.

Ok I figured it our powershell needed a reset, Thanks for this

Hi chris

Ive managed to get all the options but I would like it to save to file rather than pop up on screen any ideas?

as its will run a as a scheduled task

Thanks

Ok Managed to get it to save the file too so it emails the admins:

$worksheet.saveas("c:\123.xlsx")

Hopefully will be useful

Ive just realised the output for the master controller settings is not correct and cannot see connection to the master controller in the script, is anyone else using this script or know how to fix it?

The settings of the master controller seem to be the same as the target controllers

Any ideas or fixes please?

Hi,

thanks for nice script,

I am trying to create a script for Filer initial perametrs configuration such as IP,Hostname,etc..

I have a DHCP server enabled in my enviornment,So when I power on a new Controller ,The dhcp will assign a IP to the filer.

Is there any possibility for that?

Reagrds

why dont you bung the config into an rc file so it will load on boot use vi through unix or cifs to edit the rc file

hostname

ifconfig

route

savecore

etc etc

Is it possible to create it for multiple filers?My intention is to fully automate the Provision of a new filer

yep what your trying to do is achievable with this ssh wrapper you'll have to script it with ssh, obviously secureadmin will have to be run with keys etc before you execute your setup script with this wrapper

http://search.cpan.org/~bnegrao/Net-SSH-Expect-1.09/lib/Net/SSH/Expect.pod

im sure you can do it in powershell too which might be easier as its keyless

This is very nice and helpful.. How hard to modify or make it to work with clustermode ?

Saluting Chris,

Love your wonder script:>)

Thanks & Happy Thursday

Henry

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.