[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


WMI CPU Script - Load % Not Correct - please help.

Posted on 2005-05-16
Medium Priority
Last Modified: 2013-11-13
Hi, I have a CPU script in WMI/Vbscript and works on most machines, WINNT, 2000 and 2003.

But on one machine, it constantly reports the load at 98%, and this is simply NOT correct.  Any ideas why this would happen?  I runs it local and remotely, and get the same value.  On the box's task manager and perfmon, the load is COMPLETLEY NORMAL, ie 1-10%?


1) If I am querying multiple servers, is there any way to speed performance?
2) Does executing this WMI script anyway affect/impact the targe server? Performance wise,etc.
3) Currently, the WMI script I have posted will iterate for ALL processors on a server, is there a WMI script that will just get the total average CPU?  I know I can iterate through all cpus and then do the math, but I thought if there was a way to get the total cpu load %, it would enhance performance.

Any ideas on how to accomplish the above?  Or API alternatives?  Many thanks!

Computer = "mybox"
Set WshNtwk = WScript.CreateObject("WScript.Network")
Set ProcSet = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").InstancesOf ("Win32_Processor")
checkedCPU = WshNtwk.ComputerName

Wscript.echo "Computer Name =" & Computer
for each System in ProcSet
Wscript.echo "Load % =" & system.LoadPercentage
Wscript.echo "CPUdevice=" & system.deviceid
Question by:rsp05
  • 2
  • 2
LVL 23

Expert Comment

ID: 14011503
Go here :


If you scroll down a bit on that page , it has an example for detecting high cpu load and you can obviously alter it to your needs :)
LVL 41

Expert Comment

ID: 14012554
Hummm... I'd consider another point of view....

If that's the only PC that's got a problem, then I'd be asking questions about that PC.

How many CPUs (to include whether hyperthreading is turned on)
Running Processes

It could be that the "affect" of running the script alone could be enough to push up the %load

Author Comment

ID: 14012675
thx for replies.  graye: I think it has 4cpus, and all processors return 98%.  Can this one script really cause a spike on all 4 processors?  It doesn't seem to affect ANY other server in this way.  Again, the taskmgr shows low cpu, at the same time I run script.

Any other ideas?  Thx, much!
LVL 41

Accepted Solution

graye earned 300 total points
ID: 14013723
Humm... you're right... it's not likely that a simple WMI script would cause that much of a spike.

Here is another suggestion (althought it might be kinda wild).   You could dump the WMI repository on that server, and have it recreate the repository from scratch on the next reboot.   Sometimes that helps...    We've had problems with corrupted WMI repository before when we renamed a bunch of servers... rebuilding the repository fixed it.

instructions are at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/reinstalling_wmi.asp

Author Comment

ID: 14014037
dear graye:  BINGO!  But not exactly the way you suggested.  Maybe even a DOH!  I was going to reinstall, when I just thought, maybe if I restart the services, I would refresh it.  And walla!  It worked!
I will now AWARD you the points for putting the thought of the services in my head  ;-)

MAny THanks!


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Introduction to Processes
Screencast - Getting to Know the Pipeline

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question