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

Posted on 2005-05-16
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
    LVL 23

    Expert Comment

    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

    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

    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

    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

    Author Comment

    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

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    This is an explanation of a simple data model to help parse a JSON feed
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now