Msdn: win32_processor, cim_operatingsystem, and win32_logicalmemoryconfiguration are mainly the attributes that can be viewed in the first two msdn
Protected string [] getservercpuandmem (string IP, string username, string password)
{
Connectionoptions conoptions = new connectionoptions ();
Conoptions. Username = username;
Conoptions. Password = password;
String Path = "\\\\" + IP + "\\ Root \ cimv2 ";
Managementscope MS = new managementscope (PATH );
Ms. Options = conoptions;
Ms. Connect ();
String cpupercent = ""; // CPU serial number \ 192.0.0.184 \ Root \ cimv2: win32_processor
Managementclass cimobject = new managementclass (MS, new managementpath (path + ": win32_processor"), null );
Managementobjectcollection MOC = cimobject. getinstances ();
Foreach (managementobject Mo in MoC)
{
Cpupercent = Mo. properties ["loadpercentage"]. value. tostring ();
}
Cpupercent = cpupercent + "% ";
Objectquery OQ = new objectquery ("select * From cim_operatingsystem ");
Managementobjectsearcher searcher = new managementobjectsearcher (MS, OQ );
Uint64 totalvisiblememorysize = 0;
Uint64 freephysicalmemory = 0;
Foreach (managementobject queryobj in searcher. Get ())
{
Totalvisiblememorysize = (uint64) queryobj ["totalvisiblememorysize"];
Freephysicalmemory = (uint64) queryobj ["freephysicalmemory"];
}
Decimal di = convert. todecimal (totalvisiblememorysize-freephysicalmemory)/totalvisiblememorysize;
String mempercent = "";
Try
{
Mempercent = convert. tostring (di * 100). Split ('.') [0];
}
Catch
{
Mempercent = convert. tostring (di * 100 );
}
Mempercent = mempercent + "% ";
String [] result = new string [2];
Result [0] = cpupercent;
Result [1] = mempercent;
Return result;
}