开发者

Getting statistics of the activity of my engine

开发者 https://www.devze.com 2023-01-19 04:43 出处:网络
One of my application is an engine that executes some complex calculations. These calculations may take several hours. I want to know the activity of this engine among time.

One of my application is an engine that executes some complex calculations. These calculations may take several hours. I want to know the activity of this engine among time.

If you are using Hudson CI server, there is such a feature in Administration > Usages statistics option. Here is an example:

Getting statistics of the activity of my engine

In my application, I already have a function that returns the number of calculations. So my idea is to periodically call this method, for example every 10 minutes (using Quartz) in order to retrieve the number of running calculations and store it in a int[]. Every day开发者_运维知识库, this int[] is stored in an external file, and cleaned. So after some days, the content of this file will look like:

data.20101008=1;2;1;0;1;1;0;0;0;0;....;0
data.20101009=1;0;1;1;0;0;0;0;3;2;....;0
data.20101010=1;2;1;0;1;1;2;3;4;4;....;2
...

(I simplified a little this processing, as I want to update this file more frequently, in case of engine shutdown, or something like that)

To summarize, my idea is to store in a properties file the number of running calculations for a specific day. Eventually, I can provide a function that returns this data as a Map<Date, int[]>.

Finally, I will use JFreeChart to display these data in a graphical

What do you think of this idea? Any advice to enhance this process?

Note that this functionality is one a nice to have feature, so I don't want to build too complex systems.

I am using Java 6.


For simple ad-hoc monitoring by a human operator, you can simply use JMX. With JConsole (ships with the JDK) you can connect to a running java process and it will do nice graphs of CPU and memory usage, number of live threads, any many more. Using MBeans, you can expose current values over JMX, and use JConsole to chart them (while it is connected, of course).


Instead of a properties file and JFreeChart, maybe consider using a RRDTool Java implementation like RRD4J. From the RRDTool website:

RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data.

0

精彩评论

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