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.
If you
SELECT * FROM Win32_PerfFormattedData_Counters_ProcessorInformationthen 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
SYSTEMwith the name of the computer you want to query.output