We used to monitor an application through vbscript in ipMonitor. The vbscript basically carry out following tasks:
- Run a command with series of parameters e.g. "myappl.exe -r -s ServerName Port 4040 AppComponentName > myapp.log"
- Check the text in the log file, if it is numeric, then return 0, otherwise return 2.
Here is the code:
Const CONNECTION_OK = 0, CONNNECTION_FAILED = 2, NOT_CONFIGURED = -2, ForReading = 1, ForWriting = 2, ForAppend = 8
Dim fso, LogFile, LogLine, Diff, f1
On error resume next
IP = "192.168.5.10"
Port = "4040"
Factory = "Network V3"
LogPath = IP+"_myApp.log"
cmdfile = IP+"_myhApp.cmd"
myAppcmd = "C:\\OrionScripts\\myApp\\myApp.exe -s -r "& IP &":"& port &" execute " & chr(34) & Factory & chr(34) & " FACTORY Internal.Info.GetNumOpenTransactions > " & LogPath
Set fso = CreateObject("Scripting.FileSystemObject")
Set LogFile = fso.OpenTextFile(cmdfile, ForWriting, True)
Set fso = nothing
LogFile.WriteLine myAppcmd
LogFile.Close
Set Logfile=nothing
Set objShl=CreateObject("WScript.Shell")
objShl.Run cmdfile,1,true
Set fso = CreateObject("Scripting.FileSystemObject")
Set LogFile = fso.OpenTextFile(LogPath, ForReading)
LogLine = LogFile.ReadLine()
LogFile.Close
Set Logfile=nothing
Set fso = nothing
MyCheck = IsNumeric(trim(logline))
If MyCheck = true Then
WScript.Echo( "CONNECTION_OK" )
WScript.Quit( CONNECTION_OK )
Else
WScript.Echo( "CONNNECTION_FAILED" )
WScript.Quit( CONNNECTION_FAILED )
End If
Recently we purchased Orion SAM. I tried to use the default Script Monitor to do the same. But when testing the script output in Script Monitor configuration, I keep getting error "Some or all identity references could not be translated". I have spent sometime testing the script locally on the Orion server itself. It works with Run As Admin, otherwise give me permission denied error on line 20 "Set LogFile = fso.OpenTextFile(cmdfile, ForWriting, True)".
I just wondering, instead of spending more time on figuring out how to re-use the vbscript, is there a better/more efficient way in SAM to monitor an output from a particular application? Process Monitor seems more towards performance. Is Powershell the way to go?