mo0206
mo0206

Reputation: 801

collecting JVM GC samples within a specific time range

I am trying to fetch the JVM GC stats using 'jstat' gcutil command.

jstat -gcutil -t 32351

This is returning me a single sample from current time.

I also understand using $ jstat -gcutil -t 32351 1s 5 will return me 5 samples with 1s interval from current time.

I want to be able to get the GC stats for last 5 minutes. or within a specific time range. I tried browsing online and could not figure it out. Can anyone please guide me on this ?

Upvotes: 0

Views: 649

Answers (1)

Nicolas Filotto
Nicolas Filotto

Reputation: 44965

The command jstat only provides live stats, if you want to have access to past stats, you should redirect the output stream into a file and query the file.

So for example let's say that you want the stats of your java process every seconds, you could launch

jstat -gcutil <process-id> 1s > mystats

Then to get the last 5 minutes you could simply display the last 300 lines

tail -300 mystats 

Upvotes: 1

Related Questions