13 asp.net iis-6 performancecounter
我想使用.NET/Process性能计数器在网页上显示一些内存统计信息(工作集,GC等).不幸的是,如果该服务器上有多个应用程序池,则使用索引(#1,#2等)对它们进行区分,但我不知道如何将进程ID(我有)与该#xx索引进行匹配.是否有编程方式(来自ASP.NET网页)?
180*_*ION 11
谷歌的第一个热门话题:
当多个ASP.NET辅助进程正在运行时,公共语言运行时(CLR)性能计数器将具有类似于"W3wp#1"或"W3sp#2"的名称,依此类推.这在.NET Framework 2.0中得到了补救,在.NET CLR内存性能对象中包含一个名为Process ID的计数器.此计数器显示实例的进程ID.您可以使用此计数器来确定与进程关联的CLR性能计数器.
也是KB 281884:
默认情况下,性能监视器(Perfmon.msc)通过以下列方式枚举进程来显示具有相同名称的多个进程:
流程#1流程#2流程#3
性能监视器还可以通过以下列方式将进程ID(PID)附加到名称来显示这些进程:
Process_PID
小智 11
private static string GetProcessInstanceName(int pid)
{
PerformanceCounterCategory cat = new PerformanceCounterCategory("Process");
string[] instances = cat.GetInstanceNames();
foreach (string instance in instances)
{
using (PerformanceCounter cnt = new PerformanceCounter("Process",
"ID Process", instance, true))
{
int val = (int) cnt.RawValue;
if (val == pid)
{
return instance;
}
}
}
throw new Exception("Could not find performance counter " +
"instance name for current process. This is truly strange ...");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17465 次 |
| 最近记录: |