Home Directory

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Directory

nagmon7

Reviews(1)
bynagmon7, June 25, 2023
When running the VB script, dcdiag /test:fsmocheck on long domain name, the vbscript get the result "passed test FsmoCheck" on multiple lines, and the script is getting a false error. For example:

Running enterprise tests on : verylong.sub.topdomaine.com
------------------------------------
Starting test: FsmoCheck
......................... verylong.sub.topdomaine.com passed test
FsmoCheck
------------------------------------
The FsmoCheck appears on the line after "passed test".
The fix when a line end with "passed test", then add the next line at the end if this line.
The code fix is available at:
https://github.com/mst-amour/nagios/blob/main/check_ad.vbs

Here is the updated function to update:
--------------------------------
'call dcdiag and parse the output
sub exec(strCmd)
'Declare variables
dim objShell : Set objShell = WScript.CreateObject("WScript.Shell")
dim objExecObject, lineout, tmpline, tmpline_no_cr_lf, end_passed_str, tmpline_next
lineout = ""
'Command line options we're using
' pt strCmd

Set objExecObject = objShell.Exec(strCmd)

'Loop until end of output from dcdiag
do While not objExecObject.StdOut.AtEndOfStream
tmpline = lcase(objExecObject.StdOut.ReadLine())

tmpline_no_cr_lf = Replace(tmpline,chr(10),"") ' Newline
tmpline_no_cr_lf = Replace(tmpline,chr(13),"") ' CR

call parselang(tmpline_no_cr_lf)
lineout = lineout + tmpline
if (instr(tmpline_no_cr_lf, ".....")) then
'testresults start with a couple of dots, so lets reset the lineout buffer
lineout= tmpline

if (len(tmpline_no_cr_lf) > 13) then
end_passed_str = Mid(tmpline_no_cr_lf, Len(tmpline_no_cr_lf) - 10, 11)

if(StrComp(end_passed_str, "passed test") = 0) then
tmpline_next = lcase(objExecObject.StdOut.ReadLine())
tmpline_next = Replace(tmpline_next,chr(10),"") ' Newline
tmpline_next = Replace(tmpline_next,chr(13),"") ' CR

tmpline_no_cr_lf = tmpline_no_cr_lf + tmpline_next
end if

end if
end if

if instr(tmpline_no_cr_lf, lcase(strOK)) then
'we have a strOK String which means we have reached the end of a result output (maybe on newline)
call parse(tmpline_no_cr_lf)
lineout = ""
end if
loop
' Catch the very last test (may be in the lineout buffer but not yet processed)
if instr(lineout, lcase(strOK) & " test") OR instr(lineout, lcase(strNotOK) & " test") then
'we have a strOK String which means we have reached the end of a result output (maybe on newline)
call parse(lineout)
end if
end sub