chewiebug / GCViewer

Fork of tagtraum industries' GCViewer. Tagtraum stopped development in 2008, I aim to improve support for Sun's / Oracle's java 1.6+ garbage collector logs (including G1 collector)
https://github.com/chewiebug/GCViewer/wiki
Other
4.47k stars 978 forks source link

command line only mode #4

Open chewiebug opened 12 years ago

chewiebug commented 12 years ago

GCViewer should be have a command line only mode so that no interaction is required to process a gc log file. This mode would allow the use of gcviewer in automated scripts. Add option to support export of graph as image.

nsureshn commented 12 years ago

This mode should include the feature of exporting the graph (as image - GIF/PNG) in addition to CSV data.

thierry-feltin commented 12 years ago

Command line mode should not not depend on any GUI component to run : That is should be able to run in a non interative session/shell. This would allow to use it in automated builds/test suites.

chewiebug commented 12 years ago

I agree.

dleborgne commented 12 years ago

I have a java class that takes a gc.log filename and prints some information (throughput, max used mem after gc, total gc'ed mem) on System.out using GCViewer classes. Here is my source code :


import com.tagtraum.perf.gcviewer.*;
import java.io.FileInputStream; 
import java.io.File;
import java.util.logging.Logger;
import java.util.logging.Level; 
import java.util.Locale;

public class GCLogStatistics {

    private final GCLogStatistics i = null; 
    private static final DataReaderFactory factory = new DataReaderFactory();

    public static void main (String args[]) {

        if (args == null || args.length != 1) { 
            System.out.println("Usage: GCLogStatistics gc.log");
            return; 
        }

        GCLogStatistics i = new GCLogStatistics(args[0]);
    }

    GCLogStatistics(String filename) {

        try {
            final File f = new File(filename);
            final FileInputStream in = new FileInputStream(f);
            final DataReader reader = factory.getDataReader(in);
            final GCModel model = reader.read();

            System.out.printf(Locale.US,"THROUGHPUT:%2.2f\n",model.getThroughput());
            System.out.println("MAXUSEDMEM:"+model.getPostFullGCUsedMemory().getMax()); 
            System.out.println("TOTALGCEDMEM:"+model.getFreedMemory()); 

        } catch (Exception e ) {
            System.err.println (e.toString ()); 
        }
    }

}

chewiebug commented 12 years ago

Hi David,

Thank you for this sample. There is another user working on this issue (pbilstein). His approach extracts more information. When he releases his code I'll have to see how I can combine the two different approaches.

Regards, Jörg