开发者

How to get CPU utilization using Javascript or Java

开发者 https://www.devze.com 2022-12-18 14:45 出处:网络
How can I get the CPU utilization of client\'s machine. I have created a Java web application and where I need to get the CPU utilization of client\'s machine.

How can I get the CPU utilization of client's machine.

I have created a Java web application and where I need to get the CPU utilization of client's machine.

Can it be done using either Javascrip开发者_JAVA百科t or Java?


Whatever you use, Java or Javascript, you can't get CPU utilization of the client's machine. That will be a huge security risk. The only way to do it will be to install a plug-in. This wouldn't help too much however, as reading the CPU utilization is platform specific.


@Daniel provides a link to a method that (on a good day) would give an approximate measure of CPU usage.

@kgiannakakis says that this would be a serious security risk.

But I wonder. How could an attacker exploit CPU usage levels to compromise the user machine's security, or steal sensitive information about the user? Off the top of my head, I cannot think of anything realistic.

The only possible risk I can think of would be if the attacker had already installed/launched some spy software somewhere else on the user's machine. The ability to measure CPU usage could be used to implement a "covert channel" to get information from the spy s/w to the outside world. But this is only of theoretical interest (unless you are trying to implement A1 / A2 level security).


It may look like a security risk, but there is a technique to get an estimate of the CPU usage with JavaScript inside the browser. You may want to check this article:

  • Ajaxian - JPU: JavaScript CPU Monitor (Demo here)

As kgiannakakis noted in a comment below, this calculation is based on the delay of setInterval() calls.

I remember seeing a similar implementation on Mindmeister.com (showing the CPU usage while editing a mind map.)


There is simple example of a CPU usage monitor demonstrates how to use XML DOM capabilities of client JavaScript in a BSP application to dynamically request data from server and adjust corresponding elements of the screen without reloading the whole page.

This article might be helpful.


jni concept for cpu utilization

http://www.javaworld.com/javaworld/javaqa/2002-11/01-qa-1108-cpu.html?page=1

try this link


If its java look at OperatingSystemMXBean using the please be aware this is Java 1.6 only.

OperatingSystemMXBean operatingSystemInfo = 
    (com.sun.management.OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();

I am not sure how well this works in an applet.


I once looked into creating a Web Start application that could be launched by a user to "scan" their system hardware. Luckily, the targeted systems were Windows boxes, so I used the Jacob package (Google or search this site for info) to do a WMI query for things like serial numbers, etc.

I created a proof of concept Swing client app, but never got around to the Web Start portion.

0

精彩评论

暂无评论...
验证码 换一张
取 消