Like the
7-Mode version of the data collector tool from this post - Collect7:
7-Mode vFiler0 and vFilers Data Collector - here it’s just rewritten for
Clustered Data ONTAP (probably not as useful for C-Mode, since there’s no
config files to collect).
You
point it at your Cluster, and it will collect the outputs of all the specified
ClusterShell commands, for the Cluster and any and all Vservers, and store the
outputs in a folder for the Cluster, and a folder each for the Vservers. A
couple of examples of using it are below:
Example 1: Running as .\CollectCC.ps1
Example 2: Running as .\CollectCC.ps1 -Cluster
10.0.1.100 -UserName admin -Password $PW
The Script
Copy
into a text editior and save as CollectCC.ps1. Edit the sections -
CLUSTER
CLI OUTPUTS TO COLLECT
VSERVER
CLI OUTPUTS TO COLLECT
- as per
requirements.
#############################################################################
## COLLECTCC: C-MODE CLUSTER
AND VSERVERS DATA COLLECTOR (CSHELL COMMANDS) ##
#############################################################################
Param(
[Parameter(Mandatory=$True)][String]$Cluster,
[Parameter(Mandatory=$True)][String]$UserName,
[Parameter(Mandatory=$True)][SecureString]$Password
) # Tip: You can use> $PW
= Read-Host -AsSecureString, as input for -Password
FUNCTION Wr{
Param([String]$P="",[String]$C="WHITE"); Write-Host $P
-ForegroundColor $C}; Wr
FUNCTION Get-CmCliOutput{
Wr "Getting the output of::> $COMMAND
" CYAN
If(!$V){ [String]$StrOut = Invoke-NcSsh
-Command $COMMAND }
else{ [String]$StrOut = Invoke-NcSsh -Command
"vserver context $VSERVER; $COMMAND" }
If(!$StrOut){ RETURN }
[System.Array]($StrOut.Split("`n"))
| Set-Content ($SaveDir + "/CLI_OUT_" + $COMMAND)
}
FUNCTION CollectC{
Param([System.Array]$COMMANDS,[Switch]$V)
If(!$V){ [String]$SaveDir = $Cluster }
Else{ [String]$SaveDir = ($Cluster +
"." + $VSERVER) }
[Void](New-Item -Path $SaveDir -ItemType
Directory -Force)
Foreach($COMMAND in $COMMANDS){
[Void](Get-CmCliOutput) };Wr
}
<# CLUSTER CLI OUTPUTS TO
COLLECT: #>; [System.Array]$CCommands = `
"cluster show",`
"node show",`
"vserver show"
<# VSERVER CLI OUTPUTS TO
COLLECT: #>; [System.Array]$VCommands = `
"cifs show",`
"nfs show",`
"cifs share
show",`
"export-policy rule
show"
## MAIN PROGRAM ##
If(!(Get-Module DataONTAP)){
[Void](Import-Module DataONTAP -ErrorAction SilentlyContinue) }
If(!(Get-Module DataONTAP)){
Wr "Failed to load DataONTAP PSTK!" RED; EXIT }
Wr "Loaded DataONTAP
PSTK" GREEN; Wr
Wr
"<<<<< COLLECTCC: C-MODE CLUSTER AND VSERVERS DATA
COLLECTOR (CSHELL COMMANDS) >>>>>" MAGENTA; Wr
$Cred = New-Object
System.Management.Automation.PsCredential($UserName,$Password)
[Void](Connect-NcController
$Cluster -Credential $Cred -ErrorAction SilentlyContinue)
If(!$Global:CurrentNcController){
Wr "Failed to connnect to $Cluster!" RED; EXIT }
Wr "Connected to
$Cluster" GREEN
$query = Get-NcVserver
-template
$query.State =
"running"
[System.Array]$Vservers =
(Get-NcVserver -Query $query).Vserver
Wr "Collecting data for
cluster $Cluster" GREEN
[Void](CollectC $CCommands)
Foreach($VSERVER in
$Vservers){
Wr "Collecting data for cluster $Cluster
and Vserver $VSERVER" GREEN
[Void](CollectC $VCommands -V)
}
Comments
Post a Comment