端口连接数:

public static int PortTcpConnection(int port)
{
IPGlobalProperties properti = IPGlobalProperties.GetIPGlobalProperties();
var tcps = properti.GetActiveTcpConnections().ToList(); var list = tcps.Where(f => f.LocalEndPoint.Port == port); var iplist = list.GroupBy(f => f.RemoteEndPoint.Address);
return iplist.Count();
}

网站连接数:

public List<WebSite> ListSite()
{
List<WebSite> list = new List<WebSite>();
using (ServerManager sm = new ServerManager())
{
foreach (var s in sm.Sites)
{
WebSite site = new WebSite();
site.ID = s.Id;
site.SiteName = s.Name;
site.ApplicationPoolName = s.Applications["/"].ApplicationPoolName;
site.PhysicalPath = s.Applications["/"].VirtualDirectories["/"].PhysicalPath;
site.State = s.State.ToString(); //System.Management.ManagementObject o = new ManagementObject("Win32_PerfFormattedData_W3SVC_WebService.Name='" + s.Name + "'");
//site.CurrentConnections = int.Parse(o.Properties["CurrentConnections"].Value.ToString());这个太慢 int tcps = ;
foreach (var tmp in s.Bindings)
{
WebSite.Bind bind = new WebSite.Bind();
bind.IP = tmp.EndPoint.Address.ToString();
bind.Port = tmp.EndPoint.Port;
bind.Host = tmp.Host;
tcps += Util.SystemInfo.PortTcpConnection(bind.Port);
site.BindList.Add(bind);
}
site.CurrentConnections = tcps;//当前连接数
list.Add(site);
}
}
return list;
}

---------------------

原文:https://blog.csdn.net/wyljz/article/details/79207507
版权声明:本文为博主原创文章,转载请附上博文链接!

最新文章

  1. java开发环境的主题色的变化
  2. AngularJS的学习--TodoMVC的分析
  3. Sublime Text 2 一些常用的快捷键
  4. SPOJ 10628 求树上的某条路径上第k小的点
  5. ZOJ 1078 Palindrom Numbers
  6. 使用VS2013调试FluorineFx程序
  7. Android Activity的切换动画
  8. Go与GUI——GO语言的图形界面Walk
  9. apache的一些基本配置
  10. Bone Collector(01背包+记忆化搜索)
  11. 简要解析XMPP框架及iOS-Objective-C的使用
  12. CentOS 6.4 安装setuptools 和 pip
  13. 记 suds 模块循环依赖的坑-RuntimeError: maximum recursion depth exceeded
  14. HI3531的DDR3配置流程
  15. 【数据结构】赫夫曼树的实现和模拟压缩(C++)
  16. Java学习从菜鸟变大鸟之二 输入输出流(IO)
  17. 文本离散表示(二):新闻语料的one-hot编码
  18. Chrome - JavaScript调试技巧总结(浏览器调试JS)
  19. PHP 3 函数
  20. [ 原创 ] centos安装tomcat,启动成功 无法访问

热门文章

  1. C++ 11 创建和使用共享 weak_ptr
  2. Git - git clone - 将远端仓库克隆拷贝到本地
  3. jsp用el表达式获取后台传来的值,或者获取session中的值
  4. Windows系统XAMPP安装Moodle教程
  5. AES 加密与解密
  6. AngularJS学习之旅—AngularJS Scope作用域(五)
  7. 能ping通虚拟机,但snmp报文 Destination unreachable(Host administratively prohibited
  8. 5.3Python数据处理篇之Sympy系列(三)---简化操作
  9. 虚拟机硬盘vmdk压缩瘦身并挂载到VirtualBox
  10. Java list 转字符串并加入分隔符的方法