wql query for wmi task
Hi All,
I am looking for WQL- query statement to retrieve the currently utilized memory and CPU on a server to be used in a WMI Reader task as a wqlquerysource.
Any help much appreciated.
Thx
Ludwig
May 26th, 2012 7:36pm
Hello Ludwig,
I will give you a script that you hopefully be able to incorporate into the WMI Reader.
To find the CPU utilization on the local machine use this WQL:
strComputer ="."
Set objWMIService = GetObject("winmgmts:\\" > strComputer > "\root\cimv2")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_PerfProc_Process",,48)
wscript.echo "Computer Name",> "," > "Process Name" > ","> "CPU Usage"
For Each objItem in colProcess
if objItem.Name <> "Idle" and objItem.Name <> "_Total" then
wscript.echo strcomputer > "," > objItem.Name > ","> objItem.PercentProcessorTime
end if
Next
For the memory available use
root\cimv2,select * from Win32_perfRawData_PerfOS_Memory,AvailableMbytes)
Besides, I recommend using WMI Code Creator which is a great tool to craft WQLs.Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 26th, 2012 9:32pm
Thx Arthur,
The one for CPU works fibe. Just copied
"Select * from Win32_PerfFormattedData_PerfProc_Process" into the wqlsourcequery-property.
Having trouble to get the one for memory working. When I use the one below SSIS throws an error with invalid query.
This one..root\cimv2,select
* from Win32_perfRawData_PerfOS_Memory,AvailableMbytes)
wonder why..
Thx L.
May 27th, 2012 10:02am
Thx Arthur,
The one for CPU works fibe. Just copied
"Select * from Win32_PerfFormattedData_PerfProc_Process" into the wqlsourcequery-property.
Having trouble to get the one for memory working. When I use the one below SSIS throws an error with invalid query.
This one..root\cimv2,select
* from Win32_perfRawData_PerfOS_Memory,AvailableMbytes)
wonder why..
Thx L.
Free Windows Admin Tool Kit Click here and download it now
May 27th, 2012 10:02am
Likewise,
taking just the select * from
Win32_perfRawData_PerfOS_Memory part works.
Here I tested it in my BIDS:
Arthur My Blog
May 27th, 2012 7:40pm
Likewise,
taking just the select * from
Win32_perfRawData_PerfOS_Memory part works.
Here I tested it in my BIDS:
Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 27th, 2012 7:40pm