您的位置:首页 > 编程语言 > ASP

自己写了一个Asp.net探针的源码,希望大家讨论一下

2007-05-25 09:38 821 查看
现在针对Asp.net的探针很少,所以闲来无事就简单的写了一个,读取的信息如下

服务器基本信息
服务器计算机名http://localhost/
服务器IP地址127.0.0.1
服务器域名localhost
服务器端口80
服务器IIS版本Microsoft-IIS/6.0
本文件所在文件夹E:\downCode\ServerInfo\
服务器操作系统Microsoft Windows NT 5.2.3790 Service Pack 1
系统所在文件夹C:\WINDOWS\system32
服务器脚本超时时间30000秒
服务器的语言种类Chinese (People's Republic of China)
.NET Framework 版本2.050727.42
服务器当前时间2007-5-25 9:32:55
服务器IE版本7.0000
服务器上次启动到现在已运行66分钟
逻辑驱动器A:\C:\D:\E:\F:\G:\H:\I:\
CPU 总数2
CPU 类型x86 Family 15 Model 3 Stepping 4, GenuineIntel
虚拟内存61784M
当前程序占用内存6.44M
Asp.net所占内存60.46M
Asp.net所占CPU4
当前Session数量0
当前SessionIDgp3n1u55f2qcse55xo3q2x45
当前系统用户名NETWORK SERVICE
由于还不是很成熟,所以暂时开源供大家讨论,希望能得到高手的补充!暂定版本0.90

以下是源码部分

1
2 public partial class _Default : System.Web.UI.Page
7 {
8 protected void Page_Load(object sender, EventArgs e)
9 {
10 if (!IsPostBack)
11 {
12 /**//// <summary>
13 /// 取应用程序路径
14 /// </summary>
15
16 lbServerName.Text= "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
17 lbIp.Text = Request.ServerVariables["LOCAl_ADDR"];
18 lbDomain.Text = Request.ServerVariables["SERVER_NAME"].ToString();
19 lbPort.Text = Request.ServerVariables["Server_Port"].ToString();
20 lbIISVer.Text = Request.ServerVariables["Server_SoftWare"].ToString();
21 lbPhPath.Text = Request.PhysicalApplicationPath;
22 lbOperat.Text = Environment.OSVersion.ToString();
23 lbSystemPath.Text = Environment.SystemDirectory.ToString();
24 lbTimeOut.Text = (Server.ScriptTimeout/1000).ToString() + "秒";
25 lbLan.Text = CultureInfo.InstalledUICulture.EnglishName;
26 lbAspnetVer.Text = string.Concat(new object[] { Environment.Version.Major, ".", Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision });
27 lbCurrentTime.Text = DateTime.Now.ToString();
28
29 RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Version Vector");
30 lbIEVer.Text = key.GetValue("IE", "未检测到").ToString();
31 lbServerLastStartToNow.Text = ((Environment.TickCount / 0x3e8)/60).ToString() + "分钟";
32
33 string[] achDrives = Directory.GetLogicalDrives();
34 for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)
35 {
36 lbLogicDriver.Text = lbLogicDriver.Text + achDrives[i].ToString();
37 }
38
39 //ManagementClass diskClass = new ManagementClass("NUMBER_OF_PROCESSORS");
40 lbCpuNum.Text = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString();
41 lbCpuType.Text = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString();
42 lbMemory.Text = (Environment.WorkingSet / 1024).ToString()+ "M";
43 lbMemoryPro.Text = ((Double)GC.GetTotalMemory(false) / 1048576).ToString("N2") + "M";
44 lbMemoryNet.Text = ((Double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M";
45 lbCpuNet.Text = ((TimeSpan)Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0");
46 lbSessionNum.Text = Session.Contents.Count.ToString();
47 lbSession.Text = Session.Contents.SessionID;
48 lbUser.Text = Environment.UserName;
49
50 }
51 }
52 }
注意:当前版本只支持Asp.net2.0环境

另外根据大家的补充版本不断升级中,敬请关注!
作者liudao
51aspx.com版权所有 转载请保留版权信息

另外提供完整项目源码供大家下载,见笑了!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐