站办理员通常在维护好多i is站点的时间成百上千 每每会遇到i is 占用带宽或体系资源较多的环境而导致整个i is相应迟钝。
这种环境我们非常想知道是i is中哪些站点占用资源这么大从而找出问题的源头。许多站长一样平常都市在这时间打开i is 日志记录成果来分析iis日志记录在汪洋大海中征采我们必要的信息而在这个进程中有80%的人
徒劳无获。
为了解决这个问题在这里把最近写的一个i is网站全面信息实时监控程序和大家分享希望给需要者帮助。
图
程序是用net开发的下面讲讲具体的实现。
步调实现
想必各人都有听说过wmi这个东西你猜对了我们步调便是读取wm i性能技能器参数实现的i is站点监控的。
WMI 阐明参见http://baike baidu com/view/442461 htm 网上一大堆本身看看就明确了。其实我们议决WMI可以干许多事情比方像得到本地和远程谋略机硬件信息当前进程信息远程重启等成果。
是不是听起来挺故意思吧呵呵其实好多体系办理软件都是议决WMI来实现的---优化各人等等。
新打仗WMI以为它是很难一样其实不尽然。WMI其实便是一个数据库存放着谋略机全部的信息它还提供了
一种类似于sql的数据查问语言 叫WQL我们可以议决这个语言查找数据。
附个WQL查问器各人可用来查问一下信息试试其实要害是参数的熟习。
言反正传我们连续实现我们的步调其实有了刚才的根本我们就很简略了我们便是议决WQ L去查问性能计数器的属性值了。
看代码
//页面绑定方法privatevoid bind()
{int i=0;try
{
//下面就是net操作WMI 的代码了
//Win32_PerfForm atted Data_W3SVC_WebService就是我们说的性能计数器实体我们用WQL执行查询就行
Managem entObjectSearcher q uery=new Managem entObjectSearcher(
@"ootcimv2","SELECT
Nam e,Total Bytes Received,Total BytesSent,Total BytesTransfered,"+
"Total Fi lesSent,Total Fi les Received,Total Fi lesTransferred,TotalGetRequests,Total PostReq uests,Total MethodRequests,TotalNotFou nd Errors,"+
"CurrentConnections FROM Win32_PerfForm attedData_W3SVC_WebService");
Managem entObjectCollection queryCollection=query Get(); //Get获取集合并赋给Col lention foreach(ManagementObject mo in queryCol lection) //偏历集合
{i++;
DataRow webInfo=dataTable NewRow();webInfo["ID"]=i ;webInfo["Name"]=mo Properties["Name"]Value ToString();double receivedBytes=
Convert ToDouble(m o Properties["TotalBytes Received"]Value);rece ived B ytes=rece ived Bytes/ 1024;webInfo["Total Bytes Received"]=
Convert ToDouble(receivedBytes ToString("00"));
double sendBytes =Convert ToDouble(mo Properties["TotalBytesSent"]Value);sendBytes=sendBytes/ 1024;webInfo["TotalBytesSent"]=Convert ToDouble(sendBytes ToString("00"));double sendReciveSUM=
Convert ToDou ble(m o Properties["Total BytesTransfered"]Val ue);sendReciveSUM=sendReciveSUM/ 1024;webInfo["Total BytesTransfered"]=
ConvertToDouble(sendReciveSUM ToString("00"));webInfo["TotalFi lesSent"]=
Convert ToInt64(m o Properties["Total Fi lesSent"]Value);webInfo["TotalFi lesReceived"]=
Convert To Int64(m o Properties["Total Fi les Received"]Val ue);webInfo["TotalFi lesTransferred"]=
Convert To Int64(m o Properties["Total Fi lesTransferred"]Val ue);webInfo["TotalGetRequests"]=
Convert To Int64(m o Properties["Total GetReq uests"]Val ue);webInfo["TotalPostRequests"]=
Convert To Int64(m o Properties["Total PostReq uests"]Val ue);webInfo["Total MethodRequests"]=
Convert ToInt64(m o Properties["TotalMethodRequests"]Value);webInfo["TotalNotFoundErrors"]=
Convert To Int64(m o Properties["Total NotFou nd Errors"]Val ue);web Info["Cu rrentCon nections"]=
Convert To Int64(m o Properties["Cu rrentCon nections"]Val ue);dataTable Rows Add(webInfo);
}this dataGridView1 DataSource=dataTable;
Refres h();
}catch(System Exception ex)
{
MessageBoxShow(error);
}
}
MechanicWeb怎么样?MechanicWeb好不好?MechanicWeb成立于2008年,目前在美国洛杉矶、凤凰城、达拉斯、迈阿密、北卡、纽约、英国、卢森堡、德国、加拿大、新加坡有11个数据中心,主营全托管型虚拟主机、VPS主机、半专用服务器和独立服务器业务。MechanicWeb只做高端的托管vps,这次MechanicWeb上新Xeon W-1290P处理器套餐,基准3.7GHz最高...
DiyVM是一家比较低调的国人主机商,成立于2009年,提供VPS主机和独立服务器租用等产品,其中VPS基于XEN(HVM)架构,数据中心包括香港沙田、美国洛杉矶和日本大阪等,CN2或者直连线路,支持异地备份与自定义镜像,可提供内网IP。本月商家最高提供5折优惠码,优惠后香港沙田CN2线路VPS最低2GB内存套餐每月仅50元起。香港(CN2)VPSCPU:2cores内存:2GB硬盘:50GB/R...
厦门靠谱云股份有限公司 双十一到了,站长我就给介绍一家折扣力度名列前茅的云厂商——萤光云。1H2G2M的高防50G云服务器,依照他们的规则叠加优惠,可以做到12元/月。更大配置和带宽的价格,也在一般云厂商中脱颖而出,性价比超高。官网:www.lightnode.cn叠加优惠:全区季付55折+满100-50各个配置价格表:地域配置双十一优惠价说明福州(带50G防御)/上海/北京1H2G2M12元/月...