Ticket #926: GCTime.patch

File GCTime.patch, 3.8 KB (added by jsa, 3 years ago)

simple patch

  • plugins/javalib/org/munin/plugin/jmx/GCTimeGet.java

     
    1313class GCTimeGet { 
    1414 
    1515        private ArrayList<GarbageCollectorMXBean> gcmbeans; 
    16         private String[] GCresult = new String[2]; 
     16        private long[] GCresult = new long[2]; 
    1717        private MBeanServerConnection connection; 
    1818 
    1919        public GCTimeGet(MBeanServerConnection connection) { 
    2020                this.connection = connection; 
    2121        } 
    2222 
    23         public String[] GC() throws IOException, MalformedObjectNameException { 
     23        public long[] GC() throws IOException, MalformedObjectNameException { 
    2424                ObjectName gcName = null; 
    2525 
    2626                gcName = new ObjectName( 
     
    4141                int i = 0; 
    4242 
    4343                for (GarbageCollectorMXBean gc : gcmbeans) { 
    44                         GCresult[i++] = formatMillis(gc.getCollectionTime()); 
     44                        GCresult[i++] = gc.getCollectionTime(); 
    4545                } 
    4646                 
    4747                return GCresult; 
    4848        } 
    49  
    50         private String formatMillis(long ms) { 
    51                 return String.format("%.4f", ms / (double) 1000); 
    52         } 
    5349} 
  • plugins/javalib/org/munin/plugin/jmx/GCTime.java

     
    33import org.munin.plugin.jmx.AbstractAnnotationGraphsProvider.Graph; 
    44 
    55 
    6 @Graph(title="GarbageCollectionTime", vlabel="seconds", info="The Sun JVM defines garbage collection in two modes: Minor copy collections and Major Mark-Sweep-Compact collections. A minor collection runs relatively quickly and involves moving live data around the heap in the presence of running threads. A major collection is a much more intrusive garbage collection that suspends all execution threads while it completes its task. In terms of performance tuning the heap, the primary goal is to reduce the frequency and duration of major garbage collections.") 
     6@Graph(title="GarbageCollectionTime", vlabel="ms", info="The Sun JVM defines garbage collection in two modes: Minor copy collections and Major Mark-Sweep-Compact collections. A minor collection runs relatively quickly and involves moving live data around the heap in the presence of running threads. A major collection is a much more intrusive garbage collection that suspends all execution threads while it completes its task. In terms of performance tuning the heap, the primary goal is to reduce the frequency and duration of major garbage collections.") 
    77public class GCTime extends AbstractAnnotationGraphsProvider { 
    88         
    9         private String[] times; 
     9        private long[] times; 
    1010 
    1111        @Override 
    1212        public void prepareValues() throws Exception { 
     
    1414                times = collector.GC(); 
    1515        } 
    1616         
    17         @Field(label="MinorTime", info="The approximate accumulated collection elapsed time in seconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE") 
    18         public String copyTime() { 
     17        @Field(label="MinorTime", info="The approximate accumulated collection elapsed time in milliseconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE", min=0) 
     18        public long copyTime() { 
    1919                return times[0]; 
    2020        } 
    2121         
    22         @Field(label="MajorTime", info="The approximate accumulated collection elapsed time in seconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE") 
    23         public String markSweepCompactTime() { 
     22        @Field(label="MajorTime", info="The approximate accumulated collection elapsed time in milliseconds. This method returns -1 if the collection elapsed time is undefined for this collector.", type="DERIVE", min=0) 
     23        public long markSweepCompactTime() { 
    2424                return times[1]; 
    2525        } 
    2626