.net 获取CPU频率 内存 磁盘大小,域名 端口 虚拟目录等
CPU个数: @Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS")
CPU类型: @Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER")
CPU频率: @ViewBag.CPUGHZ
服务器内存大小: @ViewBag.TotalMemory
服务器磁盘大小: @ViewBag.TotalDisk
虚拟目录绝对路径: @Request.ServerVariables["APPL_PHYSICAL_PATH"]
执行文件绝对路径: @Request.ServerVariables["PATH_TRANSLATED"]
虚拟目录Session总数: @Session.Contents.Count
/// <summary>
/// 获取CPU频率
/// </summary>
/// <returns></returns>
public string GetCpuGHZ()
{
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection cpus = mc.GetInstances(); string str = "";
string[] mHz = new string[cpus.Count];
int c = ;
ManagementObjectSearcher mySearch = new ManagementObjectSearcher("select * from Win32_Processor");
foreach (ManagementObject mo in mySearch.Get())
{
double temp = Convert.ToInt64(mo.Properties["CurrentClockSpeed"].Value);
mHz[c] = temp.ToString();
str += (temp/).ToString("0.00") + "GHz,";
c++;
}
mc.Dispose();
mySearch.Dispose();
// return mHz;
return str.TrimEnd(',');
} /// <summary>
/// 获取内存大小
/// </summary>
/// <returns></returns>
public string GetTotalPhysicalMemory()
{
try
{
string st = " ";
ManagementClass mc = new ManagementClass("Win32_ComputerSystem");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
st = mo["TotalPhysicalMemory"].ToString();
}
moc = null;
mc = null;
return st;
}
catch
{
return "";
}
finally
{
}
} /// <summary>
/// 硬盘大小
/// </summary>
/// <returns></returns>
public string GetSizeOfDisk()
{
ManagementClass mc = new ManagementClass("Win32_DiskDrive");
ManagementObjectCollection moj = mc.GetInstances();
foreach (ManagementObject m in moj)
{
return m.Properties["Size"].Value.ToString();
}
return "";
}
比较全的获取服务器信息:
https://www.cnblogs.com/tylerdonet/archive/2013/04/07/3006278.html
比较全的Request 用法:
https://www.cnblogs.com/mazhenyu/p/9468441.html
.net 获取CPU频率 内存 磁盘大小,域名 端口 虚拟目录等的更多相关文章
- asp.net 获得域名,端口,虚拟目录[转]
asp.net 获得域名,端口,虚拟目录 记性不好,好多次都被路径问题给拦住了.我现在想得到一个资源的全URL路径,因此首先想得到网站当前的域名,端口和虚拟目录.看下表 底下這張表就是各種跟 Brow ...
- 方法:Linux 下用JAVA获取CPU、内存、磁盘的系统资源信息
CPU使用率: InputStream is = null; InputStreamReader isr = null; BufferedReader brStat = null; StringTok ...
- Android获取cpu和内存信息、网址的代码
android获取手机cpu并判断是单核还是多核 /** * Gets the number of cores available in this device, across all proce ...
- Python获取CPU、内存使用率以及网络使用状态代码
Python获取CPU.内存使用率以及网络使用状态代码_python_脚本之家 http://www.jb51.net/article/134714.htm
- Linux下使用java获取cpu、内存使用率
原文地址:http://www.voidcn.com/article/p-yehrvmep-uo.html 思路如下:Linux系统中可以用top命令查看进程使用CPU和内存情况,通过Runtime类 ...
- Golang获取CPU、内存、硬盘使用率
Golang获取CPU.内存.硬盘使用率 工具包 go get github.com/shirou/gopsutil 实现 func GetCpuPercent() float64 { percent ...
- Linux下java获取CPU、内存、磁盘IO、网络带宽使用率
一.CPU 使用proc文件系统,"proc文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间.它以文件系统的方式为访问系统内核数据的操作提供接口.用户和应用程序可以通过proc得 ...
- python3监控系统资源最终版(获取CPU,内存,磁盘,网卡等信息),返回json格式。
#!/usr/bin/env python3 #-*- coding:utf-8 -*- #create at 2018-12-07 'this is a system monitor scripts ...
- Java 获取CPU、内存、外网IP等硬件信息
import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.Input ...
随机推荐
- pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
使用pytesseract识别验证码中遇到异常如下: pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installe ...
- jQuery 标单验证
jQuery Validate jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求.该插件捆绑了一套有用的验证方 ...
- "What's your problem?"记住!聊天千万不能用这句话!
"What's your problem?"记住!聊天千万不能用这句话! 2018-01-05 19:21 这个世界套路太多 学英语也不例外 一不留神就陷入套路里 有一种痛叫做“ ...
- Entity Framework Core for Console
包 Microsoft.EntityFrameworkCore Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCor ...
- cocoapods安装 Unable to download data from http://ruby.taobao.org/ & don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
安装cocoapods,记录两个问题! 1.镜像已经替换成了 http://ruby.taobao.org/, 还是不能不能安装cocoapods, 报错:Unable to download dat ...
- Git 克隆
工作中大家分工协作,共同开发维护一个项目,git仓库放在公共的服务器上,如github.Gitee等. 在这种情况使用git,需要先克隆仓库到本地. 克隆非常简单,使用命令git clone 将远程仓 ...
- Juju solutions for OpenStack
Juju solutions for OpenStack Juju makes it easy to deploy OpenStack at scale. Quickly and reliably b ...
- Endpoint is unreachable and there is no snapshot available for offline browsing
docker Portainer配置的时候出现这个错误:Endpoint is unreachable and there is no snapshot available for offline b ...
- docker安装指定版本nexus3
安装maven私服 1 下载指定版本的镜像 docker pull sonatype/nexus3:3.18.1 2 宿主机创建一个映射目录 ,并设置所有者 mkdir -p /app/ne ...
- java知识精要(二)
java知识精要(一) 集合 Iterable v.s. Iterator 两者都是接口,在Collection继承的是Iterable. Iterable表达了集合具备迭代访问的能力,而Iterat ...