How can i monitor system statistics in kubuntu using Java? - 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?

Related

Getting hardware information in MATLAB in a platform-independent way

I would like to find hardware information such as the hardware ID, manufacturer and type of graphics card, CPU type etc. from within MATLAB. Preferably without installing any additional toolbox or third-party scripts.
I assume this could be done by directly accessing the Java interface.
It's not very easy to do this in a platform-independent way.
I would start by taking a look at cpuinfo from the MATLABCentral File Exchange. This does quite a bit of what you're asking for (although not everything). It does it by including separate code paths for Windows, Unix and Mac, and running the appropriate commands on each.
It's a third-party script, which I know you specified that you didn't want, but it is freely available and authored by a MathWorks developer - and even if you can't use it directly, you could perhaps at least read through it to see how you might proceed to implement things yourself.

"Analyse" the Python language to dissect a Scons build script?

I'm thinking about trying to convert a Scons (Python) script to another build system but was wondering if there was a Python-analysis library available in order to 'interrogate' the Scons/Python script?
What I'm [possibly] after is something along the lines of Java's reflection mechanism, in fact, if this is possible via say Jython/Java, coding in Java, that would be best for me as a Java dev (I have no real background in Python).
What I need to be able to do is extract the variable assigment values etc. for certain named class types and methods within the script, so that I can transfer them to my new output format.
Any ideas?
Thanks
Rich
If your current scons files are very regular and consistent it may be easier to do something "dumb" with standard text-editing tools. If you want to get smarter, you should notice that scons is itself a Python program, and it loads your build files which are also Python. So you could make your own "special" version of scons which implements the functions your build scripts use (to add programs, libraries, whatever). Then you could run your build scripts in your "fake" scons program and have your functions dump their arguments in a format suitable for your new build system.
In other words, don't think of the problem in terms of analyzing the Python grammar completely--realize that you can actually run your build scripts as Python code and hijack their behavior.
Easier said than done, I'm sure.
I doubt it's the best tool for migrating scons, but python's inspect module offers some reflection facilities. For the rest, you can simply poke inside live classes and objects: Python has some data hiding but does not enforce access restrictions.

Access SPSS data from a Python, Java (groovy/grails)' or C++ app without license for SPSS?

I am finding mixed results googling. I have a need to parse a SPSS .sav file to discover the data layout and extract the survey results. Step one is to read the "schema" of the data. For example I need to know the question and its type of allowed responses. I plan to model this data in my own SQL table so I can slice and dice it per my apps requirements. Step two is populate my data model with the respondents answers. Looking at the SPSS sav file I believe it has both types of data I am looking for.
I don't need or want the expensive SPSS software if I don't strictly require it. We will not be doing statistics on this data, just selecting subsets of respondents based on answer filters. The SPSS file will be provided by a partner company that licenses SPSS. I do not need to out any data back into SPSS; my use case is read-only.
I can use Python, Java with or without Groovy, C/C++ for my parser program. This program will be run once at the end of data collection so performance is not particularly important. Ideally I'd like my code to be cross platform so I can develop on my Mac and deploy to Linux, but I can use windows if I must,
A lot of what am finding is either java classes from 2004 or modern Python code that requires a DLL from IBM and is windows specific. Based on my quick explanation of requirements, I would appreciate recommendations from the SO community. I think my needs are simple, but haven't found exactly what I had hoped. An open source lib would be ideal, but I'd even pay for a simple commercial solution at a reasonable price.
You can get the SPSS i/o modules with detailed documentation for free in order to build your own app to read (or write) sav files. The modules are available for all platforms supported by SPSS Statistics.
Go to the SPSS Community site at http://www.ibm.com/developerworks/spssdevcentral and follow the links for SPSS Downloads. You have to register, but that is free.
The SAV file is a binary format with a number of complex structures, so it is better to use the i/o modules. And if new features are added to the SAV file, which has often happened, the i/o modules are updated at the same time, so your code won't go out of date.
HTH,
Jon Peck
GNU PSPP can apparently read SPSS data files. I also found a link to a description of the format in the PSPP source, although it comes with a warning "don't try to read/write this format directly."
There is a java library here:
http://sourceforge.net/projects/spss-writer/

Generate imports list for Java File

I'm writing some Java code in vim and really miss the feature afforded by the IDEs such that I can type up a block of code, and after a few keystrokes have the IDE infer which imports it should place at the top of my file based on the classes I've used in my code.
Anyone know of a way to achieve this functionality in vim? I'm thinking a command-line tool I can shell to for the file being edited. The tool would ideally dump the imports to the screen after it's analysed my Java file.
You can try these links
http://vim.wikia.com/wiki/Add_Java_import_statements_automatically
Vim & Java: add java import statements automatically
Haven't tried it myself but its a good start.
It seems to boil down to two different approaches, ones like Amir suggested where some process generates a mapping file from classes on the file system, or the approach I ended up taking where the plugin communicates real-time to a process that does the heavy lifting (Eclipse).
So I chose Eclim, seems antithetical to vim's light weight mantra, but in the end was the best featured approach.

Is there an instruction-oriented profiling tool for Android?

I need to profile several functions in my java code for Android.
I do know about traceview. And I actually found which functions to investigate using this tool. But it gives no information that can help in investigations inside specific functions.
So, is there any way I can get per-instruction profiling information for Java code on Android?
I would suggest you can try 'hprof' within your Java code to dump the profiled data to a file and you can analyse that file for more details.
API to use:
dumpHprofData(String fileName)
If you are interested in more granular level profiling then you can try 'readprofile' which works at Kernel level. You would need 'busybox' to use it though. However, I guess you need to map the instructions with your Java statements.

Categories

Resources