*如何使用来自多个 WINDOWS 服务的信息 *
我有一台中央管理员机器和 40 台其他类似客户端的行为,我需要做的是:
1-在每个客户端的机器上安装 Windows 服务以获取他们的信息*- : IP地址
- : MAC地址
- : 主机名
- :上传速率(用于互联网连接)
- : 下载速率(互联网连接)
2-能力:
- :切断连接
- :限制带宽
PS:这是我去年的项目,所以解决它非常重要,我想
我做了什么 :
public string addip ()
{
var hostEntry = Dns.GetHostEntry(Dns.GetHostName());
string x =(from addr in hostEntry.AddressList where addr.AddressFamily.ToString() == "InterNetwork" select addr.ToString()).FirstOrDefault() ;
return x;
}
public string hostname ()
{
string x = System.Net.Dns.GetHostName() ;
return x;
}
public string downlo ()
{
List<NetworkInterface> nics = NetworkInterface.GetAllNetworkInterfaces().Where(network => network.NetworkInterfaceType == NetworkInterfaceType.Ethernet).ToList();
NetworkInterface nic = nics[0];
IPv4InterfaceStatistics interfaceStats = nic.GetIPv4Statistics();
int bytesReceivedSpeed = (int)(interfaceStats.BytesReceived - double.Parse(BytesReceived)) / 1024;
BytesReceived = interfaceStats.BytesReceived.ToString();
string x = (bytesReceivedSpeed.ToString() + " KB/s") ;
return x;
}
public string uplo ()
{
List<NetworkInterface> nics = NetworkInterface.GetAllNetworkInterfaces().Where(network => network.NetworkInterfaceType == NetworkInterfaceType.Ethernet).ToList();
NetworkInterface nic = nics[0];
IPv4InterfaceStatistics interfaceStats = nic.GetIPv4Statistics();
int bytesSentSpeed = (int)(interfaceStats.BytesSent - double.Parse(BytesSent)) / 1024;
BytesSent = interfaceStats.BytesSent.ToString();
string x = (bytesSentSpeed.ToString()+ " KB/s") ;
return x;
}