Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Fri Mar 29, 2024 4:17 am

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Domain Audits
PostPosted: Wed Aug 30, 2006 3:47 am 
Offline
Moderator

Joined: Sat Mar 04, 2006 2:44 am
Posts: 193
Currently failed audits etc are not dealt with very well.

I propose we change the
[code]''''''''''''''''''''''''''''''''''''''''
' Audit the local domain, if requested '
'''''''''''''''''''''''''''''''''''''''' [/code]

section code to something similar to below. This would mean each audit.vbs exitcode can be recorded (and infact the stdout, stderror if required). This can be then used to create the failed audit list.

Then audit.vbs can be updated so that different error codes are raised (i.e. WScript.quit(errorcode)) depending on the error. These can then be included in the failed audit file.

Any comments on the code/idea

[code]
Const maxThreads = 2
Const noOfProcessors = 7

Dim WshShell
Dim theThreads(), processResults(), threadNum
Dim i

Set WshShell = CreateObject("WScript.Shell")
redim theThreads(maxThreads,1)
redim processResults(noOfProcessors)

i = 0
Do While i < noOfProcessors
While getNextThread = -1
WScript.Sleep 1000
Wend

threadNum = getNextThread
if (not isempty(theThreads(threadNum,0))) then
'record exit code
WScript.echo "Process Number:" & theThreads(threadNum,1)
processResults(theThreads(threadNum,1)) = theThreads(threadNum,0).ExitCode
end if
set theThreads(threadNum,0) = WshShell.Exec("cscript audit.vbs computer" & i)
theThreads(threadNum,1) = i
i = i + 1
Loop
waitForThreads()

for i = 0 to UBound(processResults)
WScript.echo processResults(i)
next


sub waitForThreads()
Dim i
for i = 0 to UBound(theThreads,1)
while theThreads(i,0).status = 0
WScript.Sleep 1000
wend
WScript.echo "Process Number:" & theThreads(i,1)
processResults(theThreads(i,1)) = theThreads(i,0).ExitCode
next
end sub

function getNextThread()
Dim i

getNextThread = -1

for i = 0 to UBound(theThreads,1)
if (isempty(theThreads(i,0))) then
getNextThread = i
elseif (theThreads(i,0).status <> 0) then
getNextThread = i
end if
next
end function
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 30, 2006 6:11 pm 
Offline
Moderator
User avatar

Joined: Tue Jan 25, 2005 3:09 am
Posts: 2140
Location: Scotland
Certainly an improvement. This is a necessity.

Only trouble is, how does the new audit.vbs handle inablilty to connect to WMI. so far as I am aware this is one of the major problems we have. If you attempt a connection to WMI and it fails for a known reason, thats fine, but if you attempt a connection and it times out.... it doesn't, ever actually time out.

This is the reason that when I look on the machine doing my audits, I invariably have two command windows open, one for a server with WMI screwed up on it (this is a production terminal server, so scheduling time to fix this is also a problem), and one for a workstation with an unknown WMI problem which we are going to bin soon anyway..

We need to be able to spawn a WMI connection test first, if this fails to talk to us within say 2 mins, we kill it, post the failure and then move on to the next box.

I like the idea, and think this should be priority number one, however I also think we need to release something stable soon. I suspect that if we start some a major re-write of audit.vbs, we need to do so in another branch, or after we finish the current cleanup and relaease cycle.

If you want to make a start on this idea, I am always willing to assist with the testing.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 30, 2006 9:45 pm 
Offline
Moderator

Joined: Sat Mar 04, 2006 2:44 am
Posts: 193
Hmm, maybe this isn't the best way to go.

The child process freezes if it writes out more than 4k on the stderr or stdout. This means that the above program has to be updated to keep clearing the stderr and stdout on the WshScriptExec object. Or we need some guarantee that the audit script will never write out more than 4k (hmm, not a great idea)

I updated the code to keep reading the streams but came accross another problem. I created a loop to read the stderr and stdout on each WshScriptExec object in turn. The problem is the AtEndOfStream property hangs if nothing has been written to the stream. So if nothing is ever written to stderr stream then the program will hang forever.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group