Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find LUN that a File or Logical Drive is on

Status
Not open for further replies.

djtech2k

MIS
Jul 24, 2003
1,097
US
I have a SAN attached cluster. I need some vbs that can "map" out a path and tell me what LUN it sits on. For example, if I specify a file or a path, I need to know which LUN that data sits on.

I already have some HBA info, including LUN's, targets, ports, etc. I also have some file/directory info. Now I just need to link the 2 sets of data so that I can "map" a file to the SAN or at least to the LUN.

I saw some stuff in an old DOC, but its very complex. I am not sure if I could use any of it with my existing code.


Any ideas?
 
the last 4 digits of the disk ID tend to be the LUN number, if i remember correctly.
please ignore the gay way of writing an xml file ;-), something might be of use?


objTS.WriteLine vbTab & vbTab & "<possibleluns>"
Dim strDiskNames, arrDiskNames, dic2Check, colDiskDrives, aDiskDrive, aDiskName
Set dic2Check = CreateObject("Scripting.Dictionary")
'might need to change this string, yuk, in a hurry
strDiskNames = "EMC;Qlogic"
arrDiskNames = Split(strDiskNames, ";")
For Each strTemp In arrDiskNames
If Not dic2Check.Exists(strTemp) Then
dic2Check.Add strTemp, "1"
End If
Next
' Get physical disk drive
Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
For Each aDiskDrive In colDiskDrives
For Each aDiskName In dic2Check
If InStr(LCase(aDiskDrive.Caption), LCase(aDiskName)) Then
strTemp = ""
If Len(aDiskDrive.PNPDeviceID) > 3 Then
'this bit is well dodgy, get the LUN number from the last 3 digits!
strTemp = Right(aDiskDrive.PNPDeviceID, 4)
'If IsNumeric(strTemp) Then
If strTemp <> "0000" Then 'this one is the funny blank one which i dont really know what it is for SAN magic
objTS.WriteLine vbTab & vbTab & vbTab & "<possiblelun>"
objTS.WriteLine vbTab & vbTab & vbTab & vbTab & "<lunnumber>" & strTemp & "</lunnumber>"
On Error Resume Next
objTS.WriteLine vbTab & vbTab & vbTab & vbTab & "<size>" & (aDiskDrive.Size)/(1024*1024) & "</size>"
On Error Goto 0
objTS.WriteLine vbTab & vbTab & vbTab & vbTab & "<caption>" & aDiskDrive.Caption & "</caption>"
objTS.WriteLine vbTab & vbTab & vbTab & vbTab & "<pnpdeviceid>" & Replace(aDiskDrive.PNPDeviceID, "&", "*") & "</pnpdeviceid>"
'WScript.Echo CStr(strTemp & "=" & aDiskDrive.Index & "=" & aDiskDrive.Caption & "=" & aDiskDrive.PNPDeviceID)
objTS.WriteLine vbTab & vbTab & vbTab & "</possiblelun>"
End If
'End If
End If
End If
Next
Next
Set colDiskDrives = Nothing
objTS.WriteLine vbTab & vbTab & "</possibleluns>"

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
Thanks. I grabbed that and tried to run it, but it did not seem to get me the info I needed. I have been fooling with a few different code snippets, but do not have 1 working completely right yet. This one did not match something correctly because I compared the output to some others and some of the others were correct matches, while I am not sure if this one was. The bottom line is that I need to map/link the pieces from a server to a SAN as closely as I can. This is for the purpose of automated monitoring with System Center Operations Manager.

I need to be able to "link" pieces together so I know what things are impacted...eg:

Server > HBA > Port > Target > Logical Disk > Physical Disk > LUN > SAN ...or something like that
 
there used to be a tool from microsoft, fcinfo. it came in the form of an msi file to install on a machine. once installed it exposed LUN and fabric information via a COM object, scriptable. i used it in the past, briefly.

failing that i dont know what toolset you have on the server, some command line CLI GUI tools from vendors might expose the information you are after.

certainly off the top of my head i dont think there are any native windows WMI classes of COM interfaces to get all the information you require.

you may need to rely on client side SAN toolset or something like FCInfo.

good luck. i will be happy to see your solution as it is something i would like to have myself.


I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top