一个Asp.net探针的源码

现在针对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所占CPU

4

当前Session数量

0

当前SessionID

gp3n1u55f2qcse55xo3q2x45

当前系统用户名

NETWORK SERVICE


由于还不是很成熟,所以暂时开源供大家讨论,希望能得到高手的补充!暂定版本0.90 

以下是源码部分

/// <summary>

/// Asp.net服务器探针,Power by 51aspx.com

/// 作者liudao,51aspx.com版权所有 转载请保留版权信息

/// </summary>

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            /// <summary>

            /// 取应用程序路径

            /// </summary>

 

            lbServerName.Text = "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;

            lbIp.Text = Request.ServerVariables["LOCAl_ADDR"];

            lbDomain.Text = Request.ServerVariables["SERVER_NAME"].ToString(), ;

            lbPort.Text = Request.ServerVariables["Server_Port"].ToString();

            lbIISVer.Text = Request.ServerVariables["Server_SoftWare"].ToString();

            lbPhPath.Text = Request.PhysicalApplicationPath;

            lbOperat.Text = Environment.OSVersion.ToString();

            lbSystemPath.Text = Environment.SystemDirectory.ToString();

            lbTimeOut.Text = (Server.ScriptTimeout / 1000).ToString() + "秒";

            lbLan.Text = CultureInfo.InstalledUICulture.EnglishName;

            lbAspnetVer.Text = string.Concat(new object[] { Environment.Version.Major, ".", Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision });

            lbCurrentTime.Text = DateTime.Now.ToString();

 

            RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Internet Explorer/Version Vector");

            lbIEVer.Text = key.GetValue("IE", "未检测到").ToString();

            lbServerLastStartToNow.Text = ((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟";

 

            string[] achDrives = Directory.GetLogicalDrives();

            for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)

            {

                lbLogicDriver.Text = lbLogicDriver.Text + achDrives[i].ToString();

            }

 

            //ManagementClass diskClass = new ManagementClass("NUMBER_OF_PROCESSORS");

            lbCpuNum.Text = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString();

            lbCpuType.Text = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString();

            lbMemory.Text = (Environment.WorkingSet / 1024).ToString() + "M";

            lbMemoryPro.Text = ((Double) GC.GetTotalMemory(false) / 1048576).ToString("N2") + "M";

            lbMemoryNet.Text = ((Double) Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M";

            lbCpuNet.Text = ((TimeSpan) Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0");

            lbSessionNum.Text = Session.Contents.Count.ToString();

            lbSession.Text = Session.Contents.SessionID;

            lbUser.Text = Environment.UserName;

        }

    }

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值