'=================================================================== ' ' C7000 / C3000 Quick Inventory ' Converts a SHOW SERVER INFO ALL file to a CSV ' of the same name ' David Heinrich dheinrich@hp.com Feb. 19, 2013 ' Syntax: ENC_SRV_CON.VBS File ' Suggested usage with plink or telnet ' Hint: telnet hostname -f logfile.txt ' will capture the output to the logfile.txt ' This will record Blade model, serial , CPU's, mem size, ' Mezinne slots, iLo address, and rom version ' More can be added follow the code ' Written by: David Heinrich dheinrich@hp.com 20130222 Rev. 1 ' ' Yes I could of made this more complex but I want to encourage ' people in taking it apart and changing it ' '=================================================================== Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") ' check if a file is entered to convert if Wscript.Arguments.Count = 0 then ' tell user what's wrong wscript.echo "Please enter file Name to Convert" ' exit wscript.quit end if ' Inputfile is now StrFileIn StrFileIn = Wscript.Arguments.item(0) ' test for file if objFSO.FileExists(StrFileIn) then ' Everything is OK! else ' tell user what's wrong wscript.echo "File does not exist" ' exit wscript.quit end if ' Change extension if present to CSV set objTextFile = objFSO.OpenTextFile (StrFileIn, 1, ForReading) OutFilecvs = ucase(objFSO.GetBaseName(StrFileIn) & ".CSV") ' Output file is now StrFileIn.CSV ' setup file for writing to Set ObjTSOut = ObjFSO.CreateTextFile(OutFilecvs ,2, True) ' creat dictionary of input file Set ObjDictionary = CreateObject("Scripting.Dictionary") ' write first line in csv file (header) StrBladeData = "Enclosure,Slot #,Model,Serial number,Server Name,Mem," StrBladeData = StrBladeData & "iLo Address,CPU1,CPU2,CPU3,CPU4,MEZ1," StrBladeData = StrBladeData & "MEZ2,MEZ3,MEZ4,MEZ5,MEZ6,MEZ7,ROM" StrBladeData = StrBladeData & vbcrlf ObjTSOut.Write(StrBladeData) ' start reading each line and evaluate ' start Blade Count a 1 BC = 1 Do Until objTextFile.AtEndOfStream strNextLine = objTextFile.Readline ' line from dic to testing string StrTest = strNextLine ' is this the oa? If InStr(1,StrTest,"-OA1") = 13 then StrEnc = left(StrTest,12) ' keep oa name as first column ' if this is a new blade line write data and reset If Left(StrTest, 14) = "Server Blade #" then StrSvr = lTrim(rTrim(right(left(StrTest,16),2))) CC = Cint(StrSvr) ' if a new blade shows up by number increment ' and write the current data and clear data for next blade If CC > BC then if StrPn = "" then StrPN = "Blank" if StrSN = "" then StrSN = " - " END IF if StrSNN = "" then StrSNN = " - " END IF if StrCPa = "" then StrCPa = " - " END IF if StrCPb = "" then StrCPb = " - " End if if StrCPc = "" then StrCPc = " - " End if if StrCPd = "" then StrCPd = " - " End if if StrMn = "" then StrMn = " - " End if if StrMza = "" then StrMza = " - " End if if StrMzb = "" then StrMzb = " - " End if if StrMzc = "" then StrMzc = " - " End if if StrMze = "" then StrMze = " - " End if if StrMzd = "" then StrMzd = " - " End if if StrMzf = "" then StrMzf = " - " End if if StrMzg = "" then StrMzg = " - " End if if StrIlo = "" then StrIlo = " - " End if if StrROM = "" then StrROM = " - " End if ' write data out to file StrBladeData = StrEnc & "," & CC - 1 & "," & StrPn & "," StrBladeData = StrBladeData & StrSN & "," & StrSNN & "," StrBladeData = StrBladeData & StrMn & "," & StrIlo & "," StrBladeData = StrBladeData & StrCPa & "," & StrCPb & "," StrBladeData = StrBladeData & StrCPc & "," & StrCPd & "," StrBladeData = StrBladeData & StrMza & "," & StrMzb & "," StrBladeData = StrBladeData & StrMzc & "," & StrMzd & "," StrBladeData = StrBladeData & StrMze & "," & StrMzf & "," StrBladeData = StrBladeData & StrMzg & "," & StrROM & vbcrlf ObjTSOut.Write(StrBladeData) BC = CC StrPn = "" StrSN = "" StrMn = "" StrSNn = "" StrCPa = "" StrCPb = "" StrCPc = "" StrCPd = "" StrMza = "" StrMzb = "" StrMzc = "" StrMze = "" StrMzd = "" StrMzf = "" StrMzg = "" StrIlo = "" StrROM = "" end if end if ' The evaulations If InStr(1,StrTest,"Serial Number:") > 0 then StrSN = lTrim(rTrim(mid(StrTest,16))) If InStr(1,StrTest,"Product Name:") > 0 then StrPN = lTrim(rTrim(mid(StrTest,15))) If InStr(1,StrTest,"Mezzanine 1:") > 0 then StrMza = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"Mezzanine 2:") > 0 then StrMzb = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"Mezzanine 3:") > 0 then StrMzc = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"Mezzanine 4:") > 0 then StrMzd = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"Mezzanine 5:") > 0 then StrMze = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"Mezzanine 6:") > 0 then StrMzf = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"Mezzanine 7:") > 0 then StrMzg = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"Server Name:") > 0 then StrSNN = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"ROM Version:") > 0 then StrROM = lTrim(rTrim(mid(StrTest,14))) If InStr(1,StrTest,"IP Address:") > 0 then StrIlo = lTrim(rTrim(mid(StrTest,13))) If InStr(1,StrTest,"Memory:") > 0 then StrMn = lTrim(rTrim(mid(StrTest,9 ))) If InStr(1,StrTest,"CPU 1:") > 0 then StrCPa = lTrim(rTrim(mid(StrTest,8 ))) If InStr(1,StrTest,"CPU 2:") > 0 then StrCPb = lTrim(rTrim(mid(StrTest,8 ))) If InStr(1,StrTest,"CPU 3:") > 0 then StrCPc = lTrim(rTrim(mid(StrTest,8 ))) If InStr(1,StrTest,"CPU 4:") > 0 then StrCPd = lTrim(rTrim(mid(StrTest,8 ))) Loop ' final data flush and write if StrPn = "" then StrPN = "Blank" if StrSN = "" then StrSN = " - " if StrMn = "" then StrMn = " - " if StrSNN = "" then StrSNN = " - " if StrCPa = "" then StrCPa = " - " if StrCPb = "" then StrCPb = " - " if StrCPc = "" then StrCPc = " - " if StrCPd = "" then StrCPd = " - " if StrMza = "" then StrMza = " - " if StrMzb = "" then StrMzb = " - " if StrMzc = "" then StrMzc = " - " if StrMzd = "" then StrMzd = " - " if StrMze = "" then StrMze = " - " if StrMzf = "" then StrMzf = " - " if StrMzg = "" then StrMzg = " - " if StrIlo = "" then StrIlo = " - " if StrROM = "" then StrROM = " - " StrBladeData = StrEnc & "," & StrSvr & "," & StrPn & "," & StrSN & "," StrBladeData = StrBladeData & StrSNN & "," & StrMn & "," & StrIlo & "," StrBladeData = StrBladeData & StrCPa & "," & StrCPb & "," & StrCPc & "," StrBladeData = StrBladeData & StrCPd & "," & StrMza & "," & StrMzb & "," StrBladeData = StrBladeData & StrMzc & "," & StrMzd & "," & StrMze & "," StrBladeData = StrBladeData & StrMzf & "," & StrMzg & "," & StrROM & vbcrlf ObjTSOut.Write(StrBladeData) ' uncomment next line if you need to know when it's done ' it is VERY fast ' wscript.echo "Done"