I am trying to get the vbscript log parser to work, but I keep running into the same problem no matter what I try. If I intentionally search for a value that I know is in the log file; the script returns with a down status which is expected. However, whenever I try to search for a value that I know is not in the log it always returns with an unknown status. I have verified that the section of the script of functioning by mispelling the message that it returns. I have WScript.Quit(0) at the end of the section and the debug log sees that the script exited with the exit code of 0 but it will not translate that to an UP status.
This is from the condition that should have returned an UP status:
2013-08-27 14:30:46,415 [STP SmartThreadPool Thread #3] [C3013] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Trying to get exit code
2013-08-27 14:30:46,415 [STP SmartThreadPool Thread #3] [C3013] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Script returned exit code: 0
2013-08-27 14:30:46,415 [STP SmartThreadPool Thread #3] [C3013] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Checking if script exited
2013-08-27 14:30:46,415 [STP SmartThreadPool Thread #3] [C3013] DEBUG SolarWinds.APM.Probes.WindowsScriptProbe - Adding results to the result writer.
2013-08-27 14:30:46,431 [STP SmartThreadPool Thread #3] [C3013] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Data transform for script result started.
2013-08-27 14:30:46,447 [STP SmartThreadPool Thread #3] [C3013] ERROR SolarWinds.APM.Probes.WindowsScriptProbe - SolarWinds.APM.Probes.Script.ScriptConfigurationException: Script output values are not defined or improperly defined.
at SolarWinds.APM.Probes.Script.ScriptResult.ValidateDefinitions(List`1 definitions)
at SolarWinds.APM.Probes.Script.ScriptResult.get_Columns()
at SolarWinds.APM.Probes.Script.ScriptResult.ApplyDataTransform()
at SolarWinds.APM.Probes.WindowsScriptProbe.ProbeInternal(ProbeInformation configuration, DynamicMonitorResult result, IWindowsScriptHelper scriptHelper)
This is from the one that does return the DOWN status:
2013-08-27 14:37:15,822 [STP SmartThreadPool Thread #4] [C3013] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Trying to get exit code
2013-08-27 14:37:15,822 [STP SmartThreadPool Thread #4] [C3013] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Script returned exit code: 1
2013-08-27 14:37:15,822 [STP SmartThreadPool Thread #4] [C3013] DEBUG SolarWinds.APM.Probes.Script.WindowsScriptHelper - Checking if script exited
2013-08-27 14:37:15,822 [STP SmartThreadPool Thread #4] [C3013] DEBUG SolarWinds.APM.Probes.WindowsScriptProbe - Adding results to the result writer.
2013-08-27 14:37:16,212 [STP SmartThreadPool Thread #4] [C3013] DEBUG SolarWinds.APM.Probes.WindowsScriptProbe - Outcome - Fail.
2013-08-27 14:37:16,212 [STP SmartThreadPool Thread #4] [C3013] DEBUG SolarWinds.APM.Probes.WindowsScriptProbe -
Anyone got any Ideas?
Here is the whole script:
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const ERROR_WMI = 1
Const ERROR_WQL_DIR = 2
Const ERROR_DISK_ACCESS = 3
Const ERROR_NO_DRIVE = 4
Dim objFSOL
Dim objFSOO
Dim objFSO
Dim objFile
Dim objFileLog
Dim objRegEx
Dim colMatches
Dim arrFileLines()
Dim sStart
Dim sStop
Dim sLogfilepath
Dim sSearch
Dim sUsage
Dim sPosition
Dim sLine
Dim sPattern
Dim sMatchFound
Dim sDateLog
Dim sDirectory
Dim i
Dim iCount
On Error Resume Next
Set objFSOO = CreateObject("Scripting.FileSystemObject")
If Wscript.Arguments.Count < 4 Then
'Wscript.Echo "Critical Error Check Arg Usage: logfilepath, searchstring, usage, start"
WScript.Echo "Message: Critical Error Check Arg Usage"
WScript.Echo "Statistic: 0"
WScript.Quit(1)
End If
sLogfilepath=""
sSearch=""
sUsage=""
sPosition=""
sMatchFound=""
iCount=0
sLogfilepath=Trim(Wscript.Arguments(0))
sSearch=Trim(Wscript.Arguments(1))
sUsage=Trim(Wscript.Arguments(2))
sPosition=Trim(Wscript.Arguments(3))
'Wscript.Echo sLogfilepath & Chr(9) & sSearch & Chr(9) & sUsage & Chr(9) & sPosition
If (sLogfilepath="""" ) Then
Wscript.Echo "Message: Can't find ""logfile_path"" argument. Check documentation."
'WScript.Quit(1)
End If
If (sSearch="""" ) Then
Wscript.Echo "Message: Can't find ""regex search string"" argument. Check documentation."
'WScript.Quit(1)
End If
If (sUsage="""" ) Then
Wscript.Echo "Message: Can't find ""usage"" argument. Check documentation."
'WScript.Quit(1)
End If
If (sPosition="""" ) Then
Wscript.Echo "Message: Can't find ""position"" argument. Check documentation."
'WScript.Quit(1)
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(sLogfilepath) Then
'Wscript.Echo "Found log file: " & sLogfilepath
'Set objFile = objFSO.OpenTextFile(sLogfilepath)
Else
'WScript.Echo("Critical Error: The specified file was not found.")
WScript.Echo "Message: Critical Error The specified file was not found."
WScript.Echo "Statistic: 0"
WScript.Quit(1)
End If
'USAGE ==============================================================
Select Case sUsage
Case "total"
Set objFile = objFSO.OpenTextFile(sLogfilepath,1)
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.IgnoreCase = True
objRegEx.Pattern = sSearch
i = 0
Do Until objFile.AtEndOfStream
sLine = objFile.ReadLine
Set colMatches = objRegEx.Execute(sLine)
If colMatches.Count > 0 Then
'Wscript.Echo "Line Match" & Chr(9) & sLine
If (iCount=0) Then
sMatchFound = Trim(sLine)
Else
sMatchFound = sMatchFound & ";" & Trim(sLine)
End If
iCount=iCount+1
End If
Loop
Case "new"
'Wscript.Echo sUsage
'WScript.Quit(1)
Case "match"
'Wscript.Echo sUsage
'WScript.Quit(1)
Case Else
'Wscript.Echo sUsage
'WScript.Echo("Critical Error: Incorrect usage argument: It should be: total, new or match.")
WScript.Echo "Message: Critical Error: Incorrect usage argument"
WScript.Echo "Statistic: 0"
WScript.Quit(1)
End Select
'SET RETURN AS REQUIRED ==============================================================
If (Len(sMatchFound) > 0) Then
WScript.Echo "Message: " & sMatchFound
WScript.Echo "Statistic: " & iCount
WScript.Quit( 1 )
Else
WScript.Echo "Message: No Matches"
WScript.Echo "Statistic: 0"
WScript.Quit( 0 )
End If
If Err Then
'WScript.Echo "Error:" & Err.Number & Chr(9) & Err.Description
'WScript.Quit(1)
End If
'CLOSE ===============================================================================
objFile.Close
Set objFSO = Nothing
Set objFSOL = Nothing
Set objFSOO = Nothing
Set objRegEx = Nothing
'Wscript.Echo "Processing Complete"
'DONE ===============================================================================
WScript.Echo "Message: Scan Failure"
WScript.Echo "Statistic: 0"
WScript.Quit(1)