鉴于大家对ASP.net十分关注,我们编辑小组在此为大家搜集整理了“服务器性能监测WMI学习”一文,供大家参考学习!
1.WMI简介
WMI是英文Windows Management Instrumentation的简写,通过使用WMI,我们可以获取本地或远程服务器的性能参数和进程运行情况,以及大部分硬件信息,但前提是运行的用户要有足够的权限,如administrator组用户等。这也是做负载均衡所需要且比较方便快捷的途径。
2.使用时首先添加System.Management.dll,然后引用
using System.Management;3.定义远程访问 public class ManagementConnectPool
...{
private static System.Management.ConnectionOptions Conn = new ConnectionOptions() ;
private static ManagementObjectSearcher mos = new ManagementObjectSearcher();
private string username = "";
private string pwd = "";
private string space="";
private string server = "";
public ManagementConnectPool(string mpusername,string mppwd , string mpspace ,string mpserver)
...{
this.username = mpusername;
this.pwd = mppwd;
this.space = mpspace;
this.server = mpserver;
Conn.Username = mpusername;
Conn.Password = mppwd;
string scopestring ="\\" + mpserver + mpspace;
System.Management.ManagementScope Ms = new ManagementScope(scopestring);
Ms.Connect();
mos.Scope = Ms;
}
本新闻共18页,当前在第1页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18