I am new to hostmon so if I am a lil off on some basics please accept my apologies....
I am trying to setup a test (currently using VBScript) to get the memory usage of a specific process from a remote Windows computer. Following is the script
Code: Select all
Option Explicit
const statusAlive = "Host is alive:"
const statusDead = "No answer:"
const statusUnknown = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk = "Ok:"
const statusBad = "Bad:"
const statusBadContents = "Bad contents:"
Dim objWMIService, objProcess, colProcess, WorkingSetSize
Dim strComputer, strProcess
strComputer = "192.168.2.2"
strProcess = "'ThisServer.exe'"
FUNCTION performtest()
WorkingSetSize = "0"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select WorkingSetSize from Win32_Process Where Caption = " & strProcess )
For Each objProcess in colProcess
WorkingSetSize = objProcess.WorkingSetSize
Next
IF (WorkingSetSize > 0) THEN
performtest = statusOk & WorkingSetSize
ELSE
performtest = statusBad & WorkingSetSize
END IF
END FUNCTION
a. To get the memory usage in MB by a particular process on a remote machine every 30 secs.
b. Get an alert if this value is above x for say 10 polling intervals.
c. Have the response log to a file with timestamp.
So far I am only able to get the memory used by a process on a local machine.
So my first question is: "How can I pass the credentials to connect to the remote machine"
and then how can I log all the responsess to a file with time stamp. I want to do this so that I can have a graphical output from this data.
Thanks for all your help.
Alam