#115853 - 2004-03-10 06:49 PM
Kixtart/WMI Performance Monitoring
|
Everyone
Getting the hang of it
Registered: 2003-10-19
Posts: 81
Loc: Beale Air Force Base, CA
|
Using Kixtart 4.22 on an XP test machine, going off of information from here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting11182003.asp Trying to create a Kixtart/WMI processor performance monitor, here's the Code:
$strComputer = "." $objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * From Win32_PerfRawData_PerfOS_Processor Where Name = '0'") For Each $objItem in $colItems $CounterValue1 = $objItem.PercentUserTime $TimeValue1 = $objItem.TimeStamp_Sys100NS Next For $i = 1 to 5 Sleep 1 $colItems = $objWMIService.ExecQuery("Select * From Win32_PerfRawData_PerfOS_Processor Where Name = '0'") For Each $objItem in $colItems $CounterValue2 = $objItem.PercentUserTime $TimeValue2 = $objItem.TimeStamp_Sys100NS If $TimeValue2 - $TimeValue1 = 0 ? "Percent User Time = 0%" Else $PercentProcessorTime = 100 * ($CounterValue2 - $CounterValue1) / ($TimeValue2 - $TimeValue1) ? "Percent User Time = " + $PercentProcessorTime + "%" Endif $CounterValue1 = $CounterValue2 $TimeValue1 = $TimeValue2 Next Next Keep getting an "ERROR : Error in experssion.!" on the line that has "If $TimeValue2 - $TimeValue1 = 0" on it. I put a "? $TimeValue1" and "? $TimeValue2" line in after each of those variables to see what they were returning. I got 4230585452000 for $TimeValue1 and 4230595588000 for $TimeValue2. Set up a seperate script to see if it just didn't like the math on those numbers... had no problem with it, it just doesn't want to work when it gets the numbers from a WMI query.
Any ideas?
|
|
Top
|
|
|
|
#115859 - 2004-03-11 12:05 AM
Re: Kixtart/WMI Performance Monitoring
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I've played around a little with monitoring processes with WMI. Check out KiXforms: ProcessMon for some ideas.
|
|
Top
|
|
|
|
#115861 - 2004-03-11 07:21 PM
Re: Kixtart/WMI Performance Monitoring
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
If you're monitoring the System Idle Process it will show close to 100% (depending on what you're doing, of course), as technically that is the CPU utilization of that process.
Monitor iexplore.exe instead and watch how even moving the mouse over the window uses CPU cycles.
|
|
Top
|
|
|
|
#115862 - 2004-03-11 09:27 PM
Re: Kixtart/WMI Performance Monitoring
|
Everyone
Getting the hang of it
Registered: 2003-10-19
Posts: 81
Loc: Beale Air Force Base, CA
|
Ahh, you know, I wasn't even selecting a process to monitor, I was just clicking monitor when it came up.
Too much math involved in this perfmance monitoring stuff.
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 874 anonymous users online.
|
|
|