General discussion


CPU Utilization Script

By ask_anurag ·

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.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by 3xp3rt In reply to CPU Utilization Script

For this kind of job you need some knowledge about Windows API.
For this see the following link

Collapse -

by ask_anurag In reply to


Thanks for your help.

Collapse -

by neilb@uk In reply to CPU Utilization Script

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

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 & _
Set objLogFile = Nothing
End If
Wscript.Sleep 300000 ' Sleep in mSec.

Collapse -

by ask_anurag In reply to CPU Utilization Script

This question was closed by the author

Related Discussions

Related Forums