root / plugins / jvm / jvm_sun_tenuredgcs @ 17f78427
Historique | Voir | Annoter | Télécharger (2,75 ko)
| 1 |
#!/usr/bin/perl -w |
|---|---|
| 2 |
|
| 3 |
# Sun JVM tenured GC statistics. Parses a verbose log of tenured GC |
| 4 |
# stats. Reads the entire log file and sums time in seconds spent on |
| 5 |
# GC and number of times it is performed. Thus we obtain counters. |
| 6 |
# The counters are reset when the log is rotated. (note: the minorgcs |
| 7 |
# plugin uses a state file, we did not make it a priority to use a |
| 8 |
# state file in this plugin...) |
| 9 |
|
| 10 |
# The two numbers are graphed in _one_ graph. Where it has been used |
| 11 |
# until now these two numbers have been in the same order of |
| 12 |
# magnitude. |
| 13 |
|
| 14 |
# Configuration (common with the other sun_jvm_* plugins in this family): |
| 15 |
# [jvm_sun_*] |
| 16 |
# env.logfile /var/foo/java.log (default: /var/log/munin/java.log) |
| 17 |
# env.graphtitle (default: "Sun Java") |
| 18 |
|
| 19 |
# You need to configure your Sun JVM with these options: |
| 20 |
# -verbose:gc |
| 21 |
# -Xloggc:/var/log/app/jvm/gc.log |
| 22 |
# -XX:+PrintGCTimeStamps |
| 23 |
# -XX:+PrintGCDetails |
| 24 |
|
| 25 |
# History: |
| 26 |
|
| 27 |
# This plugin was developed by various people over some time - no logs |
| 28 |
# of this has been found. - In 2006 significant contributions was |
| 29 |
# financed by NRK (Norwegian Broadcasting Coproration) and performed |
| 30 |
# by Nicolai Langfeldt of Linpro AS in Oslo, Norway. |
| 31 |
|
| 32 |
# $Id: $ |
| 33 |
|
| 34 |
use strict; |
| 35 |
use warnings; |
| 36 |
|
| 37 |
# Full path to jvm log file |
| 38 |
my $logfile = $ENV{logfile} || "/var/log/app/jvm/gc.log";
|
| 39 |
my $grtitle = $ENV{graphtitle} || 'Sun Java';
|
| 40 |
|
| 41 |
# Title that appears on munin graph |
| 42 |
my $title = "$grtitle tenured GCs pr second"; |
| 43 |
|
| 44 |
# Extended information that appears below munin graph |
| 45 |
my $info = "Amount is the number of Tenured GC pr. second.\nSeconds spent is the total time spent on those Tenured GCs."; |
| 46 |
|
| 47 |
my $record = ""; |
| 48 |
my %elements; |
| 49 |
|
| 50 |
# Print config information to munin server |
| 51 |
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
| 52 |
print "graph_title $grtitle tenured GCs pr minute\n"; |
| 53 |
print "graph_period minute\n"; |
| 54 |
print "graph_category virtualization\n"; |
| 55 |
print "graph_args --lower-limit 0\n"; |
| 56 |
print "graph_info $info\n"; |
| 57 |
print "activity.label Number of GCs\n"; |
| 58 |
print "activity.type DERIVE\n"; |
| 59 |
print "activity.min 0\n"; |
| 60 |
print "time.label Seconds spent on GCs\n"; |
| 61 |
print "time.type DERIVE\n"; |
| 62 |
print "time.min 0\n"; |
| 63 |
exit 0; |
| 64 |
} |
| 65 |
|
| 66 |
# Scan through the log file and keep the last instance of a |
| 67 |
# Tenured record in $record. |
| 68 |
open( FILE, "< $logfile" ) or die "Can't open $logfile : $!"; |
| 69 |
my $counter = 0; |
| 70 |
my $record_time_spent; |
| 71 |
my $time_spent; |
| 72 |
while (<FILE>) {
|
| 73 |
chomp; |
| 74 |
if (m/.+Tenured.+/) {
|
| 75 |
$record = $_; |
| 76 |
} elsif (m/^:.+/) {
|
| 77 |
$record .= $_; |
| 78 |
} |
| 79 |
if ( $record =~ m/(\d+)\..+Tenured.+(\d+\.\d+) secs\]/ ) {
|
| 80 |
# print "Record: $record\n"; |
| 81 |
$record_time_spent = $2; |
| 82 |
# print "Time spent: ",$record_time_spent,"\n"; |
| 83 |
|
| 84 |
$counter++; |
| 85 |
$time_spent += $record_time_spent; |
| 86 |
} |
| 87 |
$record = ""; |
| 88 |
} |
| 89 |
close FILE; |
| 90 |
|
| 91 |
print "activity.value $counter\n"; |
| 92 |
print "time.value ",int($time_spent),"\n"; |
