c#监测电脑状态
public class DeviceMonitor
{ static readonly PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
static readonly PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");
static readonly PerformanceCounter uptime = new PerformanceCounter("System", "System Up Time"); public static bool GetInternetAvilable()
{
bool networkUp = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
return networkUp;
} public static TimeSpan GetSystemUpTime()
{
uptime.NextValue();
TimeSpan ts = TimeSpan.FromSeconds(uptime.NextValue());
return ts;
} public static string GetPhysicalMemory()
{
string str = null;
ManagementObjectSearcher objCS = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem");
foreach (ManagementObject objMgmt in objCS.Get())
{
str = objMgmt["totalphysicalmemory"].ToString();
}
return str;
} public static string getCurrentCpuUsage()
{
return cpuCounter.NextValue() + "%";
} public static string getAvailableRAM()
{
return ramCounter.NextValue() + "MB";
}
}
c# 监测电脑状态,CPU使用率,物理内存使用,开机时间,网络状态
c#监测电脑状态的更多相关文章
- Linux iostat监测IO状态
Linux iostat监测IO状态 http://www.orczhou.com/index.php/2010/03/iostat-detail/
- Linux iostat监测IO状态(转)
Linux iostat监测IO状态 2010-03-1 | 13:13分类:Linux,技术细节 | 标签:Linux | 53,945 views Linux系统出现了性能问题,一般我 ...
- grunt-contrib-watch 实时监测文件状态
grunt-contrib-watch:实时监测文件的增删改状态,状态改变时自动执行预定义任务使用watch时,被watch的文件可以分开写,这样可以提高watch的性能,不用每次把没修改的文件也执行 ...
- Centos6.5部署Rsyslog-日志的存储方式及监测服务状态
1.以IP地址命名 在/etc/rsyslog.conf中加入如下配置,并做好备注.添加这三行配置之后,远程日志会被单独输出到一个以IP命名的日志文件中. #IP format by zhz at x ...
- nginx负载均衡监测节点状态
1. 安装nginx_upstream_check_module模块 我的实验环境是在/root 和 /application目录下都编译安装了nginx-1.6.3,然后在/root目录下建立一个文 ...
- memcache 原理 & 监测 & 查看状态 & stats & 结构
Mencache内存存储方式:slab/LRU,采用预先申请固定大小的内存页(slab/page),然后再把内存分成多个块(chunk) 先放一张从网上找到的memcache内存结构图,觉得非常的赞:
- shell应用之监测电脑内存、负载和磁盘的使用情况
1 #!/bin/bash 2 for i in $(cat ip.txt);do 3 #内存 4 total_memo=$(ssh $i "free -m" |grep Mem ...
- IOS 特定于设备的开发:检查设备接近度和电池状态
UIDevice类提供了一些API,使你能够跟踪设备的特征,包括电池的状态和接近度传感器.他们二者都以通知的形式提供更新,可以订阅他们,以便在有重要的更新时通知你的应用程序. 1>启动和禁用接近 ...
- localstorage 更新监测 storage事件
1.存储更新监测 存储状态监测的原理是storage事件.storage事件说明: https://developer.mozilla.org/zh-CN/docs/Web/API/StorageEv ...
随机推荐
- Gym100814B Gym100814F Gym100814I(异或) ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest (2015) Arab Academy for Science and Technology
今日份的训练题解,今天写出来的题没有昨天多,可能是因为有些事吧... Gym100814B 这个题就是老师改卷子,忘带标准答案了,但是他改了一部分卷子,并且确定自己改的卷子没出错,他想从改过的卷子里把 ...
- UVALive3882-And Then There Was One-约瑟夫问题-递推
And Then There Was One Time limit: 3.000 seconds Let's play a stone removing game. Initially, n ston ...
- hdu_1025(LIS Nlog(N)算法)
题意:自己慢慢读吧.大概就是道路两边建路,给出建路需求,要求两条路不能有交叉,问最多可以建多少条路. 题解:一看数据范围500000,应该是dp,再画个图模拟一下,发现实质就是求最长上升子序列,很自然 ...
- ACM_素数筛选
/* *素数筛法,判断小于MAXN的数是不是素数. *notprime是一张表,为false表示是素数,true表示不是素数 */ const int MAXN = 1000010; bool not ...
- Android studio启动后卡在refreshing gradle project(包解决)
这个问题几乎每个刚使用Android studio的同学都会碰到过,网上有各式各样的方法,有的说使用本地gradle,我试过多次,每次启动android studio时还是会检查更新,所以根本上解决的 ...
- IntersectionObserver实现图片懒加载
API: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API 直接上源码: <!DOCTYPE ...
- mysql中的union和order by、limit
我有一个表 CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(20) N ...
- dedecms 图集标签{dede:productimagelist} {dede:field name='imgurls'}&nbs
1.{dede:productimagelist}{/dede:productimagelist} 2.{dede:field name='imgurls'}{/dede:field} 这两个图集标签 ...
- 跟版网 > 织梦教程 > 织梦安装使用 > 织梦DedeCMS附件上传大
织梦DedeCMS附件上传大小受限制,超过2M就不能上传了,针对此问题按如下方法修改: 1.进入后台→系统设置→系统基本参数→会员设置→会员上传文件大小(K),改成你需要限制的大小: 2.在dede ...
- jquery 循环获取checkBox的值,以及对复选框选中,取消,操作按钮
法一:jquery 循环获取选中checkBox框的值 function checkeds() { $("input:checkbox").each(function(index) ...