CPU Utilization Script
Hi,
I need assistance to write a script for CPU Utilization which will records events in every 5 mins and transfer data in some text file.
Is there any kix or dos batch script which i can use.
Thanks and Regards.
Anurag.
Windows Forum
Hi,
I need assistance to write a script for CPU Utilization which will records events in every 5 mins and transfer data in some text file.
Is there any kix or dos batch script which i can use.
Thanks and Regards.
Anurag.
by 3xp3rt
For this kind of job you need some knowledge about Windows API.
For this see the following link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_hardware_information.asp
by ask_anurag
Hi,
Thanks for your help.
I use this smeggy little vbscript. Copy to a file called, say, CPU_Use.vbs or whatever and kick it off with the scheduler. It's set to Run Forever but doesn't load the CPU when sleeping so you can leave it running for days. The output file format is Date [Tab] Time [Tab] Total CPU use averaged over the period. The first iteration is always null.
------------------------------------
Const ForAppending = 8 'Contents not overwritten.
strComputer = "."
strLogFile = "c:\Processor.log" ' Your log file
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.Swbemrefresher")
Set objProcessor = objRefresher.AddEnum _
(objWMIService, "Win32_PerfFormattedData_PerfOS_Processor").objectSet
objRefresher.Refresh
Do
For Each intProcessorUse in objProcessor
If intProcessorUse.Name = "_Total" Then
Set objLogfile = objFSO.OpenTextFile(strLogFile,ForAppending, true)
objLogFile.WriteLine FormatDateTime(Now,vbShortDate) & vbTab & _
FormatDateTime(Now,vbShortTime) & vbTab & _
intProcessorUse.PercentProcessorTime
objLogFile.Close
Set objLogFile = Nothing
End If
Next
Wscript.Sleep 300000 ' Sleep in mSec.
objRefresher.Refresh
Loop
by ask_anurag
This discussion is closed to new replies.
Sort by Trending