views:

55

answers:

2

Is there a way can I access machine diagnostic information within the Linux OS in realtime? Such diagnostic info as CPU utilization, memory utilization, etc using JavaScript to display on a web page?

If there is no direct access from JavaScript, is there any other method where JS code can call functions in shared libraries (dll, etc.)? Since I am sure there is a native library that can exists in the OS.

+3  A: 

You'll need to write a web interface to the native tools.

Javascript is sand-boxed to the browser, so the only way to get that information is to ask a web server. Javascript cannot access the disk, much less invoke DLLs or other executable. If Javascript was able to do this, the Internet would be chaos.

The easiest way to set this up would likely be to use CGI scripts.

Ben S
Im indeed very glad javascript cannot do that, otherwise the internet would have even less security :p
Henri
Not that i have a need for rep, but why is this answer upvoted when the question is about client-side information, not server-side?
Georg Fritzsche
+1  A: 

JavaScript is in general not allowed to access system information - among other things this results from portability and security considerations.

If you really need that for some reason you either find some browser-specific solutions (don't know if there are any) or you require the user to install a custom plugin you deliver (probably native with the NPAPI for cross-browser-support) that provides the information to JavaScript.

Another alternative would be browser extensions, but with them you lose the cross-browser-portability - if you don't want to lock users onto a specific browser you would have to at least develop seperate extensions for Gecko- and Webkit-based browsers.

Georg Fritzsche