Remote WMI Slowness - Get processes running on Remote Machine


hi all,

good afternoon ! have been trying  processes running on remote server in same domain. wmi calls slow.

the painful thing in wmi there no option query process using "username" or "owner". couldn't believe microsoft has columns in wmi win32_process class not "username" field.

i want find processes being run specific user. since there no direct option that, m getting running processes in machine , each 1 of them using getowner method, loading them data table , binding data table grid view.

this method takes forever , takes more 10 15 mins produce result. wmi dead slow. there choice of using system.diagnostics namespace , use "processes" class , getprocesses("machinename"). again, here there no option processes specific user.

i have running processes , again , again deal wmi takes infinite amount of time.
can experts here please me find if doing wrong or have live wmi slowness.?

private datatable loadinggrid()         {  		// connection options             connectionoptions options = new connectionoptions();             options.username = remotedomaintext.text + "\\" + adminusertext.text;             string fqdn = hostnametext.text + "." + remotedomaintext.text;             string fqdn_trimmed = fqdn.trim();              managementscope scope = new managementscope("\\\\" + fqdn_trimmed + "\\root\\cimv2", options);             options.impersonation = system.management.impersonationlevel.impersonate;             options.enableprivileges = true;              scope.connect();  			 			/new data table load process info 			             datatable processtable = new datatable();             processtable.columns.add("processname");             processtable.columns.add("pid");             processtable.columns.add("owner"); 			 			 			// running on remote machine               objectquery query1 = new objectquery( "select * win32_process");              managementobjectsearcher searcher = new managementobjectsearcher(scope, query1);  // each of process in list,i getting pid             foreach (managementobject queryobj in searcher.get())             { 			// each of process in list,i getting pid                 string name = queryobj["name"] string;                 int processid = convert.toint32(queryobj["processid"]); 				 			objectquery query2 = new objectquery("select * win32_process processid = " + processid);                 managementobjectsearcher mosearcher = new managementobjectsearcher(scope, query2);                 managementobjectcollection mocollection = mosearcher.get();  // owner of process                  foreach (managementobject mo in mocollection)                 {                     string[] args = new string[] { string.empty };                     int returnval = convert.toint32(mo.invokemethod("getowner", args));                     if (returnval == 0)                     {                         string process_owner = args[0]; 						//add results data table                         processtable.rows.add(name, processid, process_owner);                     }                     else                     {                         processtable.rows.add(name, processid, "n/a");                     }                  }              }               return processtable;          }


- neuronring


hi neuronring,

since can't test scenario. hard locate why wmi slowness. , code looks me.

after search,  there are some threads. might helpful you.

why wmi queries slow sometimes?

wmi being slow

<copied>

there returnimmediately property belonging enumerationoptions class might results faster if them in 1 batch instead of enumerating them on network.

enumerationoptions options = new enumerationoptions(); options.returnimmediately = false;

</copied>

good day!

kristin


we trying better understand customer views on social support experience, participation in interview project appreciated if have time. helping make community forums great place.
click here participate survey.




Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'