16

I'm working on a program that queries three different servers in order to get CPU and LogicalDisk information.

Each server I query returns me values in 6 to 15 seconds (depending on the server). So it takes a total of 31 seconds to get all my values (15 sec for the first server, 6 for the second and 10 for the third).

I tried to multi thread each query, it reduced the execution time of 1 second for each server, so I don't think it's the solution.

I also tried to run queries directly with powershell in servers:

  • First server : it took 10 seconds (instead of 15) to retrieve informations

  • Second server : it took 10 seconds (like when I do it remotely) to retrieve informations

  • Third server ) it took ~1 second (instead of 6)

Here are my queries:

SELECT LoadPercentage From WIN32_Processor

SELECT Size, FreeSpace From WIN32_LogicalDisk

My Question is: is there something to do on my servers to make queries easier ? I already tried to desactivate the firewall and the antivirus.

PS: I'm querying Windows 2003 R2 server, Win XP pro and Win 7 server, each in the same domain as my local computer.

Thomas F.
  • 717
  • 3
  • 13
rafatic
  • 223
  • 1
  • 10

5 Answers5

1

Perhaps it might speed up the whole thing by using CIM instead of WMI.

Here you can find a performance comparison: http://community.spiceworks.com/topic/332657-powershell-cmdlet-performance-get-wmiobject-vs-get-ciminstance

Of course you can get a specific CimInstance in C#, too: https://msdn.microsoft.com/en-us/library/dn313201(v=vs.85).aspx

Peter Schneider
  • 2,879
  • 1
  • 14
  • 17
0

Try querying locally to investigate the performance issue. if it is still slow, investigate your query.

I don;t know what your project specs are but i would approach it this way: 1) create a console app that queries 2) schedule it on the servers at start up every 10-15 minutes 3) push through MSMQ or log to a database or web service. 4) the console app should be deployed as clickonce so that you have a single point to update should you need additional performance counters.

  • I tried to run queries locally, as i said in my question, thé results were pretty much the same. I will try to deploy it as clickonce – rafatic Jun 30 '14 at 15:03
0

Since you listed two different queries, it would be interesting to know if both of them are slow or just one of them.

In the past I have experienced that queries to WIN32_Processor can be slow on some Windows versions. If that is the case, maybe you can get the required information from other (hopefully more responsive) objects such as Win32_PerfFormattedData_Counters_ProcessorInformation:

SELECT PercentProcessorTime FROM Win32_PerfFormattedData_Counters_ProcessorInformation
Thomas F.
  • 717
  • 3
  • 13
0

Look into the WBEM_FLAG_RETURN_IMMEDIATE flag for your language. When using Scriptomatic (great little VBScript GUI from MS for making WMI calls) this option is automatically added as part of the options. The 48 means WBEM_FLAG_RETURN_IMMEDIATE | WBEM_FLAG_FORWARD_ONLY. VBScript example:

objWMIService.ExecQuery ("Select * from Win32_NetworkConnection",,48)

https://msdn.microsoft.com/en-us/library/aa390880(v=vs.85).aspx

Dane W
  • 181
  • 2
  • 6
0

You can try two things just to check if it works fine for your.

  1. Try to go with PowerShell script. http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/

  2. or you can use tool available in Windows - named wbemtest. If you are not querying above WQL from any programming language then you should try out above two options.

atp9
  • 890
  • 1
  • 11
  • 23