博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Asp.net获取系统信息
阅读量:6183 次
发布时间:2019-06-21

本文共 2541 字,大约阅读时间需要 8 分钟。

        [DllImport("kernel32")]

        public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);

        [StructLayout(LayoutKind.Sequential)]
        public struct MEMORY_INFO
        {
            public uint dwLength;
            public uint dwMemoryLoad;
            public uint dwTotalPhys;
            public uint dwAvailPhys;
            public uint dwTotalPageFile;
            public uint dwAvailPageFile;
            public uint dwTotalVirtual;
            public uint dwAvailVirtual;
        }

        protected string MemberName, AdminLevel, MemoryLoad, TotalPhys, AvailPhys, TotalPageFile, AvailPageFile, TotalVirtual;
        protected string ServerOS, CpuSum, CpuType, MachineName, ServerName, ServerPath, ServerNet, ServerArea, ServerTimeOut, ServerStart, UsersTxt;
        protected string PrStart, AspNetN, AspNetCpu, ServerSessions, ServerApp, ServerCache, ServerAppN, ServerFso, RunTime, SessionTime, VersionTxt;
        protected string SiteTitle, SiteUrl;
       
        protected void Page_Load(object sender, EventArgs e)
        {

            this.CheckPower();

            if (this.adminer != null)

            {
                DataLoad();
            }
        }

        private void DataLoad()
        {
            DateTime sTime = DateTime.Now;

            MemberName = "";

            ServerOS = Environment.OSVersion.ToString();

            CpuSum = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS");
            CpuType = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");
            MachineName = Server.MachineName;
            ServerName = Request.ServerVariables["SERVER_NAME"];
            ServerPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
            ServerNet = ".NET CLR " + Environment.Version.ToString();
            ServerArea = (DateTime.Now - DateTime.UtcNow).TotalHours > 0 ? "+" + (DateTime.Now - DateTime.UtcNow).TotalHours.ToString() : (DateTime.Now - DateTime.UtcNow).TotalHours.ToString();
            ServerTimeOut = Server.ScriptTimeout.ToString();
            ServerStart = ((Double)System.Environment.TickCount / 3600000).ToString("N2");
            PrStart = GetPrStart();
            AspNetN = GetAspNetN();
            AspNetCpu = GetAspNetCpu();
            ServerSessions = Session.Contents.Count.ToString();
            ServerApp = Application.Contents.Count.ToString();
            ServerCache = Cache.Count.ToString();
            ServerAppN = GetServerAppN();
            ServerFso = Check("Scripting.FileSystemObject");
            ServerTimeOut = Server.ScriptTimeout.ToString() + "毫秒";

            SessionTime = HttpContext.Current.Session.Timeout.ToString();

            MEMORY_INFO MemInfo;
            MemInfo = new MEMORY_INFO();
            GlobalMemoryStatus(ref MemInfo);
            MemoryLoad = MemInfo.dwMemoryLoad + " %";
            TotalPhys = dFileSize(MemInfo.dwTotalPhys);
            AvailPhys = dFileSize(MemInfo.dwAvailPhys);
            TotalPageFile = dFileSize(MemInfo.dwTotalPageFile);
            AvailPageFile = dFileSize(MemInfo.dwAvailPageFile);
            TotalVirtual = dFileSize(MemInfo.dwTotalVirtual);

        }

转载于:https://www.cnblogs.com/chengeng/p/3287009.html

你可能感兴趣的文章
MPQ技术内幕__
查看>>
文档生产工具 Doxygen
查看>>
PowerDesigner(一)-PowerDesigner概述(系统分析与建模)(转)
查看>>
Thrift RPC框架介绍
查看>>
球和正方形(矩形,长方形)碰撞 (二维) Flash Flex actionscript 3
查看>>
MVC框架 Struts
查看>>
【WebGoat 学习笔记】--2.安装
查看>>
js的parseInt函数结果为0很奇怪的问题
查看>>
滑雪_poj_1088(记忆化搜索).java
查看>>
ytu 1940:Palindromes _easy version(水题)
查看>>
asp.net“服务器应用程序不可用” 解决方法
查看>>
PHP中spl_autoload_register函数的用法
查看>>
response content-type json
查看>>
线程同步
查看>>
Android 从零开始打造异步处理框架
查看>>
调用Interop.zkemkeeper.dll无法使用解决方案
查看>>
贪心算法(Greedy Algorithm)
查看>>
DuBrute 3.1
查看>>
【PWA学习与实践】(9)生产环境中PWA实践的问题与解决方案
查看>>
RecyclerView的复用机制
查看>>