Hi,
Need to get the storage adaptert hardware details like firmware version, driver version etc using shell script. Anyone please help me ?
Regards,
Rajesh
On ESX host HBA firmware version can be checked via cat /proc/scsi/qla/ |less -S
---
iSCSI SAN software
http://www.starwindsoftware.com
The only way that I know of is through the files in the /proc/scsi folders.
You can list those with the plink.exe command from the PuTTY Suite.
This is an example when you have QLogic adapters.
$User = "<user-account>" $Pswd = "<user-password>" $Computer = "<esx-hostname>" $plink = "<PuTTY-directory>\plink.exe" $plinkoptions = " -v -batch -pw $Pswd" $cmd1 = 'cat /proc/scsi/qla*/*' $remoteCommand = '"' + $cmd1 + '"' $command = $plink + " " + $plinkoptions + " " + $User + "@" + $computer + " " + $remoteCommand $msg = Invoke-Expression -command $command # Extract the required info from the $msg variable ...
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD,
But I have more number of hosts. Need to get HBA details for all the hosts in the cluster. We are in the process of upgrading the HBA firmware.
Regards,
Rajesh
If you can use the same account/password on all the hosts, you can place the above in a loop through all the hosts.
Something like this
$User = "<user-account>" $Pswd = "<user-password>" $plink = "<PuTTY-directory>\plink.exe" $plinkoptions = " -v -batch -pw $Pswd" $cmd1 = 'cat /proc/scsi/qla*/*' $remoteCommand = '"' + $cmd1 + '"' $command = $plink + " " + $plinkoptions + " " + $User + "@" + $computer + " " + $remoteCommand Get-VmHost | %{ $Computer = $_.Name $msg = Invoke-Expression -command $command # Extract the required info from the $msg variable ... }
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thakns a ton. I ran the script, and it works fine without any error. Since I am new to scripting, i dont know how to extract details form the $msg variable. Could you please help me out ?
Sure, but could you perhaps attach a few sample lines of the output ?
Would make it easier for me, since not all HBAs produce exactly the same output.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
The sample output should be
ClusterName | Hostname | HBA | Model Name | Driver Version | Firmware Version
Thanks in Advance.
Regards,
Rajesh
We have only Emulex HBA card.
Poke around in /proc/lpfc then...
--Matt
VCP, vExpert, Unix Geek
I meant the output from the 'cat /proc/scsi/qla/' command.
I don't have any Emulex cards.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
No problem. You help me out for qlogic. We also have some qlogic HBA cards.
Regards,
Rajesh
Attached a script that extracts most of the data you want.
The script is attached because the forum sw has some issues with square brackets.
With the sample RegEx objects it shouldn't be too hard to extract other data or to extract the data from other types of HBA cards.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks once again Lucd. I am getting this error when execute the script
The term 'C:\Documents' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
At :line:15 char:32
+ $msg = Invoke-Expression <<<< -command $command
I have placed plink.exe in C:Documents and Settings\adm\Desktop\plink.exe
Regards,
Rajesh
That's due to blank in the path to plink.exe.
Can't you place plink.exe in a folder without blanks in the path ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Unable to read from standard input: The handle is invalid.
At :line:1 char:12
+ C:\plink.exe <<<< user@computername -pw xxxx "cat /proc/scsi/lpfc/*"
Hi Lucd,
I ma getting the above error when i ran the script after correcting the space problem.
Regards,
Rajesh
Is the stuff you're looking for available via HostKernelModuleSystem's QueryModules routine?
On one of my servers I get this:
[vSphere PowerCLI] C:\> $modules | where { $_.Name -like "ql*" } | set-variable m [vSphere PowerCLI] C:\> $m Id : 33 Name : qla2xxx Version : Version 831.k1.24vmw, Build: 207424, Interface: ddi_9_1 Built on: Nov 4 2009 Filename : qla2xxx.o OptionString : Loaded : True Enabled : True UseCount : 2 ReadOnlySection : VMware.Vim.KernelModuleSectionInfo WritableSection : VMware.Vim.KernelModuleSectionInfo TextSection : VMware.Vim.KernelModuleSectionInfo DataSection : VMware.Vim.KernelModuleSectionInfo BssSection : VMware.Vim.KernelModuleSectionInfo DynamicType : DynamicProperty : [vSphere PowerCLI] C:\> $m.Version Version 831.k1.24vmw, Build: 207424, Interface: ddi_9_1 Built on: Nov 4 2009
Or is there other data that you need here?
=====
Carter Shanklin
Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]
The Firmware version doesn't seem to be in the Version property.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Could be since it is the first plink connection or that there is something wrong with the sudo setup.
Have a look at
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
Atlast i got a script to get the hbafirmware details. The plink is not working on GUI. I tried it on cmd. Here is my script. It was a good experience working on script. Since I am newbie to scripting, i learned a lot..
Thanks a lot,
Rajesh
-
Connect-VIServer -Server $vcName -User $loginName -Password $vcPass
#Creating a text file to hold the output data
$filename = $vcName + "-hbaversion.txt"
"HBA Firware Version for the VC " + $vcName | Out-File -FilePath .\$filename
"----
" | Out-File -FilePath .\$filename -Append
$plink = "C:\plink.exe"
$plinkoptions = "-pw $esxPass"
#Getting HBA details from each ESX hosts in a VC
foreach($myhost in Get-VMhost){
$remotecommand = "'hostname; cat /proc/scsi/lpfc/* | egrep -i emulex\|firmware\|link'"
$command = $plink + " " + $esxUser + "@" + $myhost + " " + $plinkoptions + " " +$remoteCommand
(Invoke-Expression -command $command) | Out-File -FilePath .\$filename -Append
"----
" | Out-File -FilePath .\$filename -Append
}
#Disconnect from VC
Disconnect-VIServer -Confirm:$false