Вы находитесь на странице: 1из 2

On Error Resume Next 'Objective: To monitor the Process on a machine 'Created By :MAK 'Date Written: Nov 10, 2004

Set objArgs = WScript.Arguments ProcessName= objArgs(0) instance= objArgs(1) LogFile=objArgs(2) ServerName=objArgs(3) Set FSO = CreateObject("Scripting.FileSystemObject") if FSO.fileexist(LogFile) = True then Set FSOA = FSO.openTextFile(LogFile,8) end if if FSO.fileexist(LogFile) = False then Set FSOA = FSO.openTextFile(LogFile,2,True) end if count=0 strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & ServerName & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_Process",,48) For Each objItem in colItems if objItem.Name =ProcessName then count=count+1 'Wscript.Echo "Name: " & objItem.Name end if Next If cstr(count) < instance then string1 = ": ServerName =" & Servername & ": ProcessName =" & ProcessName & " : Number of given instances to monitor is =" & instance & " : Number of running in stance " & count & ": Date=" & now() FSOA.Writeline string1 end if If cstr(count) = instance then string1 = ": ServerName =" & Servername & ": ProcessName =" & ProcessName & " : Number of given instances to monitor is =" & instance & " : Number of running in stance " & count & ": Date=" & now() FSOA.Writeline string1 end if

>>Script Language and Platform: VBScript This script finds the number of process instances running on a server. Usage: cscript MonitorTask.vbs "distrib.exe" "2" "c:\taskmonitor.log" "MyServer" parameters Explained "distrib.exe" = ProcessName

"2" = Number of Instances that we are looking for "c:\taskmonitor.log"= Log File Location "MyServer"= Servername Result: Type "c:\taskmonitor.log" you will see the following results : ServerName =MyServer: ProcessName =distrib.exe : Number of given instances to monitor is =2 : Number of running instance 2: Date=11/16/2004 9:06:50 AM : ServerName =MyServer: ProcessName =notepad.exe : Number of given instances to monitor is =2 : Number of running instance 0: Date=11/16/2004 9:07:17 AM

Вам также может понравиться