English 中文(简体)
How can i monitor system statistics in kubuntu using Java?
原标题:

i am doing a project related to configuration and memory analyzer for kubuntu. i want to display the system statistics information like CPU usage, RAM usage and proceses etc. graphically using an odometer. i wanted to know if there is any great open source library for graphical component like odometers and other graphing utilities. also another problem is that i have to get information of cpu from somewhere and parse it and feed it into the odometer for display. one method may be that i use command line utilities and parse the results and feed to the graphical component. another option is that there is a library called libstatgrab which is written in complete C and i need to use JNI.

i dont like both these approaches because i am a little short on time and need a library that can do these things for me. there is a binding library present for Python to libstatgrab but not to java. and if any one has any other approach, please write up.

问题回答

For collecting the statistics, I would read directly from /proc or /sys, since they re just text files which are readily parseable (slightly moreso than exec()ing a command line tool and reading its output). Look at /proc/meminfo, /proc/loadavg, /proc/stat and others.

You can look at the C source of the procps package to see how these files are worked with by running

apt-get source procps

In there, you can look at how top.c reads the /proc/stat file.

As for charting, the "bog standard" plotting library is JFreeChart.

there is a binding library present for Python to libstatgrab but not to java

Use jython?





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签