如何获取Windows负载值 [英] How to get Windows load values

查看:446
本文介绍了如何获取Windows负载值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java从Windows获取有关CPU,RAM,HDD,网络和进程(服务)列表的数据。如何在不使用第三方库或JNI的情况下获取这些系统值?

I would like using Java to get data from Windows about CPU, RAM, HDD, Network and list of processes(services). How I can get these system values values without using third-party libraries or JNI?

在Windows中是否存在与/ proc类似的内容,我可以获得所有必要的值并使用他们?

Is there something similar to /proc in Windows where I can get all necessary values and use them?

推荐答案

您可以使用 JNI 来使用本机API。

You can use native API's using JNI.

您还可以使用 SIGAR ,这是Apache许可的库,可以提供更多功能然后你要求它。它已经在Java API中包装了原生调用,因此你不必知道 JNI 的内部工作原理。

You can also use SIGAR which is Apache licensed library which does much more then what you are asking for.It has wrapped the native calls in Java API's so that you dont have to know the inner workings of JNI.

您还可以从代码内部生成进程以运行特定于操作系统的命令,以便您可以收集系统统计信息,例如systeminfo |在Windows或Linux cat / proc / meminfo上找到Available Physical Memory或wmic命令。这可以通过java.lang.ProcessBuilder来实现。

You can also spawn processes from inside the code to run OS specific commands so that you can collect the system stats e.g. systeminfo |find "Available Physical Memory" or wmic command on windows or Linux cat /proc/meminfo . This can be achieved via java.lang.ProcessBuilder.

这篇关于如何获取Windows负载值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆