hi,
I have to search several sub folders and alert if files do have wrong text string in.
c:\data\???\abc.xml
c:\data\???\bcd.xml
c:\data\???\efg.xml
c:\data\???\hji.xml
c:\data\???\mno.xml
Sub folder name ??? does change randomly.
How set this up ?
using Advanced Host Monitor v 8.50
br
esko
Text log test to sub folders ?
We have 800...
hi, I must define more ( and I got more info from application people):
We have software which have 800 sub folders.
sub folder names do not change.
To those subfolders software creates log file every morning.
Files come between 6-8 AM.
If we can find bad text like >RJCT< from any of these 800 sub folder file(s) , make hostmonitor alert.
We can use the %newest% , because name of text file changes, not folder like I said earlier.
Q1: several new subfolders come every week , so how to automatically generate tests ? (I can script these and load tests with hml import, but any other ideas ?)
Q2: can we add to alert line from log file, which has certain string ?
ie. log file structure is
....
<InfoId>Customer_12345</InfoId>
<Result>RJCT</Result>
...
So if this is found Result>RJCT</Result then alert with text InfoId>Customer_12345</InfoId ?
br,
esko
We have software which have 800 sub folders.
sub folder names do not change.
To those subfolders software creates log file every morning.
Files come between 6-8 AM.
If we can find bad text like >RJCT< from any of these 800 sub folder file(s) , make hostmonitor alert.
We can use the %newest% , because name of text file changes, not folder like I said earlier.
Q1: several new subfolders come every week , so how to automatically generate tests ? (I can script these and load tests with hml import, but any other ideas ?)
Q2: can we add to alert line from log file, which has certain string ?
ie. log file structure is
....
<InfoId>Customer_12345</InfoId>
<Result>RJCT</Result>
...
So if this is found Result>RJCT</Result then alert with text InfoId>Customer_12345</InfoId ?
br,
esko
Then you need to write your own script and use Shell Script test method to perform this check.
Something like this
Script requires 2 parameters: <Path to Folder> <Text to search>
Script returns Ok status if none of the files contains specified text. Otherwise it returns Bad status and text (1 line above specified string) from each file that contains the string.
If you need to check new files only and you need to keep old files as well, then you may add some code to check file age...
Regards
Alex
Something like this
Code: Select all
Option Explicit
const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"
dim objFSO, objShell, objTextFile, FileName, cnt, strtext, strpos, objArgs, fo, x, BadText, fline, nline, flist, ff
Set objArgs = WScript.Arguments
if objArgs.count <> 2 then
WScript.StdOut.Write statusUnknown & "expected params: <Path to Folder> <Search Text>"
WScript.Quit
end if
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
Set objShell = Wscript.CreateObject("Wscript.Shell")
BadText = ""
cnt = 0
Set fo = objFSO.GetFolder(objArgs(0))
For Each x In fo.SubFolders
Set flist = objFSO.GetFolder(objArgs(0) & x.Name & "\")
For Each ff In flist.files
FileName = objArgs(0) & x.Name & "\" & ff.Name
if objFSO.FileExists(FileName) then
Set objTextFile = objFSO.OpenTextFile(FileName, 1)
strpos = -1
fline = ""
nline = ""
Do While (objTextFile.AtEndOfStream <> True) AND (strpos<1)
strtext = objTextFile.ReadLine
strpos = InStr(1, strtext, objArgs(1),0)
fline = nline
nline = strtext
Loop
if strpos>0 then
if BadText <> "" then
BadText = BadText & " | "
end if
BadText=BadText & fline
cnt = cnt + 1
End If
Set objTextFile = Nothing
end if
Next
Next
if cnt > 0 then
WScript.StdOut.Write statusBad & BadText
else
WScript.StdOut.Write statusOk & BadText
End if
Script returns Ok status if none of the files contains specified text. Otherwise it returns Bad status and text (1 line above specified string) from each file that contains the string.
If you need to check new files only and you need to keep old files as well, then you may add some code to check file age...
Regards
Alex
Thanks, we test this
hi,
I knew You have something ready to use.
We test this during coming weeks and let You know how this goes.
br,
esko
I knew You have something ready to use.
We test this during coming weeks and let You know how this goes.
br,
esko