For my EMC SAN I have a script that exports the performance data (NAR files) to a folder every hour. This allows me to easily review the files at a later time and even import them into Excel or other tools.
The problem comes when attempting to merge a large number of files for reviewing a long time period (several weeks or months). The EMC Navisphere UI has a function to merge two NAR files, but with hundreds or thousands of files, this is impossible.
I did some research and found that the Navisphere CLI can combine NAR files from command line. The basic syntax is as follows:
NaviSECCli.exe analyzer -archivemerge -data file1.nar file2.nar -out file3.nar
Using this command, I created a script that used the following logic:
- Rename the first file as Temp.Nar
- Begin loop though all the files
- Merge the current file with Temp.Nar, creating Output.Nar
- Rename Output.Nar to Temp.Nar
- Continue with loop
The only problem I found with this merge process is that it becomes slower as the files increase in size. So if you continually add to a single file (like I did), it will start out fast and gradually come to a crawl. This is fine for merging a few dozen files, but not the thousands that I was running into.
I reworked my script and came up with the following logic:
- Create an empty variable named tempFile
- Begin loop though all the files
- If tempFile is empty
- Assign it the current file
- Continue with loop
- If tempFile isn’t empty
- Merge the current file and tempFile, creating a file with a random name
- Continue with loop
- Repeat loop until only 1 file remains
While this may seem slower at first glance, its faster because it works with small files more frequently. Only after multiple passes does the merge process begin working with larger files that can take several minutes to complete.
naviPath="C:Program Files (x86)EMCNavisphere CLI"
SET oShell = WScript.CreateObject("Wscript.Shell")
SET objArgs = Wscript.Arguments
folderspec = objArgs(0)
Set fso = CreateObject("Scripting.FileSystemObject")
DO WHILE fso.GetFolder(folderspec).Files.Count >1
MergeNAR(folderspec)
Loop
SUB MergeNAR(folderspec)
dim tempFile
tempFile=NULL
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
IF IsNull(tempFile) THEN
SET tempFile = f1
ELSE
strCmd = "'" & naviPath & "NaviSECCli.exe' analyzer -archivemerge -data '" & folderspec & "" & f1.name & "' '" & folderspec & "" & tempFile.Name & "' -out '" & folderspec & "" & getTimeStamp & ".nar'"
strCmd = Replace(strCmd,"'","""")
wscript.echo strCmd
oShell.Run strCmd, 1, true
f1.Delete
tempFile.Delete
tempFile = NULL
END IF
Next
END SUB
Function getTimeStamp()
Dim intSeconds, intMilliseconds, strMilliseconds, intDatePart, intTimePart
intSeconds = (Hour(Now) * 3600) + (Minute(Now) * 60) + Second(Now)
intMilliseconds = Timer() - intSeconds
intMilliseconds = Fix(intMilliseconds * 100)
intDatePart = (Year(Now) * 10000) + (Month(Now) * 100) + Day(Now)
intTimePart = (Hour(Now) * 1000000) + (Minute(Now) * 10000) + (Second(Now) * 100) & "." & intMilliseconds
getTimeStamp = intDatePart & intTimePart
End Function
Comments
Post a Comment