Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9158919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:21:57+00:00 2026-06-17T13:21:57+00:00

I am using the wmi client for linux. Through it you can execute WQL

  • 0

I am using the wmi client for linux. Through it you can execute WQL to query windows servers remotely.

For Example;

 Select * from Win32_ComputerSystem

What I am trying to do is calculate the CPU percentage used.

I’ve been getting the value of ‘PercentProcessorTime’ from ‘Win32_PerfFormattedData_Counters_ProcessorInformation’. I think this is working fine for computers with a single CPU, but I’m lost as to how to calculate the CPU usage for computers with multiple CPU’s.

any help is very much appreciated.

cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:21:58+00:00Added an answer on June 17, 2026 at 1:21 pm

    If you SELECT * FROM Win32_PerfFormattedData_Counters_ProcessorInformation then you will get a list of result sets. The first set is the overall values for all CPUs, and the rest are values for the individual CPUs.

    This code shows the idea. Note that you should replace SYSTEM with the name of the computer you want to query.

    use strict;
    use warnings;
    
    use Win32::OLE;
    use Win32::OLE::Variant;
    
    STDOUT->autoflush;
    
    my $wmi = Win32::OLE->GetObject('winmgmts:\\\\SYSTEM\root\cimv2') or die Win32::OLE->LastError;
    my $list = $wmi->ExecQuery('SELECT * FROM Win32_PerfFormattedData_Counters_ProcessorInformation');
    my $n = 0;
    for my $cpu (in $list) {
      printf "%s: %d%%\n", $n ? "CPU$n" : ' ALL', $cpu->PercentProcessorTime;
      $n++;
    }
    

    output

     ALL: 8%
    CPU1: 8%
    CPU2: 12%
    CPU3: 6%
    CPU4: 12%
    CPU5: 6%
    CPU6: 6%
    CPU7: 6%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experiencing a memory leak when using WMI from Delphi 7 to query a
Is there a way to get Windows audio mixer levels using WMI? For example,
Using Windows' WMI library, how can I eject CD rom mounted in a specific
First some background: I'm currently using j-interop to query WMI calls to a Windows
I need an example of an update query using WMI. I have searched but
I want to use Windows current credential when using WMI to query data on
I can not query log Security using WMI. Other logs works fine. Here is
Where can I find more information on and examples of using WMI with Qt?
Can anyone point me to a vbscript (using WMI) to find out the installed
I'm developing .net application using wmi and win32_* WQL queries. http://msdn.microsoft.com/en-us/library/aa394084(VS.85).aspx Will such application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.