[Xymon] about trends and multigraph

Olivier AUDRY olivier at audry.fr
Tue Sep 11 23:17:20 CEST 2012


For the records the scripts that you can use :

#!/usr/bin/perl

use Data::Dumper;

my @jps = split /\n/, `sudo  /usr/java/jdk1.6/bin/jps  -v | grep Bootstrap`;
my %res;
foreach my $jvm (@jps) {

        my @t = split /\s+/, $jvm;
        my $pid = shift @t;
        if ( my @tt = grep /-Dcatalina.base/, @t) {
                my $tid = shift @tt;
                my @ttid = split /\//, $tid;
                my $id = pop @ttid;
                if ( `sudo /usr/java/jdk1.6/bin/jinfo $pid 2>&1 ` =~ /java.specification.version/ ) {
                        $res{"$id"}{"version"}  = "jdk1.6";
                        $res{"$id"}{"pid"}      = $pid;
                } elsif ( `sudo /usr/java/jdk1.5/bin/jinfo $pid 2>&1 ` =~ /java.specification.version/ ) {
                        $res{"$id"}{"version"} = "jdk1.5";
                        $res{"$id"}{"pid"}    = $pid;
                } else { print "Cannot identify jvm version for $pid\n"; }


        }
}

foreach my $id (keys %res) {

        my $pid = $res{"$id"}{"pid"};
        my $bin = $res{"$id"}{"version"};

        $str = `sudo /usr/java/$bin/bin/jstat -gccapacity -t $pid 1 1 | tail -n 1`;
        ($t,$timestamp,$NGCMN,$NGCMX,$NGC,$S0C,$S1C,$EC,$OGCMN,$OGCMX,$OGC,$OC,$PGCMN,$PGCMX,$PGC,$PC,$YGC,$FGC) = split /\s+/, $str;
        $str = `sudo /usr/java/$bin/bin/jstat -gc -t $pid 1 1 | tail -n 1`;
        ($t,$timestamp,$s0c,$s1c,$s0u,$s1u,$ec,$eu,$oc,$ou,$pc,$pused,$ygc,$ygct,$fgc,$fgct,$gct) = split /\s+/, $str;

        my $perused = sprintf ("%.2f",( $pused * 100 ) / $PGCMX );
        if ($perused > 99) {
                $color = "red";
        } elsif ( $perused > 98 ) {
                $color = "yellow";
        } else { $color = "green"; }


        $res{"$id"}{"gccap"}{"label"} = "Gc Capacity";
        $res{"$id"}{"gccap"}{"value"} = $perused;
        $res{"$id"}{"gccap"}{"alert"} = 0;

        $str = `sudo /usr/java/$bin/bin/jstat -gc -t $pid 1 1 | tail -n 1`;
        ($t,$timestamp,$s0c,$s1c,$s0u,$s1u,$ec,$eu,$oc,$ou,$pc,$pu,$ygc,$ygct,$fgc,$fgct,$gct) = split /\s+/, $str;

        $s0c *= 1024; $s1c *= 1024; $s0u *= 1024; $s1u *= 1024; $ec  *= 1024; $eu  *= 1024; $oc  *= 1024; $ou  *= 1024;
        $pc  *= 1024; $pu  *= 1024;
        $res{"$id"}{"gccap"}{"trends"} = "[jvm.$id.rrd]
DS:SOC:GAUGE:600:0:U $s0c
DS:S1C:GAUGE:600:0:U $s1c
DS:S0U:GAUGE:600:0:U $s0u
DS:S1U:GAUGE:600:0:U $s1u
DS:EC:GAUGE:600:0:U $ec
DS:EU:GAUGE:600:0:U $eu
DS:OC:GAUGE:600:0:U $oc
DS:OU:GAUGE:600:0:U $ou
DS:PC:GAUGE:600:0:U $pc
DS:PU:GAUGE:600:0:U $pu
DS:GCAP:GAUGE:600:0:U $perused";

}

$line = "Gc Capacity and VM memory reporting\n";
#$line = "$ENV{'BB'} $ENV{'BBDISP'} \"status $ENV{'MACHINE'}.jvm";
$mcolor = 0;
@colors = ("green","yellow","red");
$trends = "";
foreach my $id (sort keys %res) {

        $line .= "&". at colors[$res{"$id"}{"gccap"}{"alert"}]." $id : ".$res{"$id"}{"gccap"}{"value"}."%\n";
        if ( $res{"$id"}{"gccap"}{"alert"} > $mcolor ) {
                $mcolor = $res{"$id"}{"gccap"}{"alert"} ;
        }
        $trends .= $res{"$id"}{"gccap"}{"trends"}."\n";
}
$date = `/bin/date`;
$color = $colors[$mcolor];
$line .= "\n<!-- linecount=6 -->";
system qq/ $ENV{'BB'} $ENV{'BBDISP'} "status $ENV{'MACHINE'}.jvm $color $line $date"/;
system qq/ $ENV{'BB'} $ENV{'BBDISP'} "data $ENV{'MACHINE'}.trends\n$trends"/;


----- Mail original -----
De: "Olivier AUDRY" <olivier at audry.fr>
À: "Xymon mailinglist" <xymon at xymon.com>
Envoyé: Mardi 11 Septembre 2012 22:45:02
Objet: [Xymon] about trends and multigraph

hello

I have one rrd by jvm to trend memory usage off the jvm 

-rw-rw-r-- 1 xymon xymon 209480 11 sept. 22:35 jvm.tomcat5-1.rrd
-rw-rw-r-- 1 xymon xymon 209480 11 sept. 22:35 jvm.tomcat5-2.rrd
-rw-rw-r-- 1 xymon xymon 209480 11 sept. 22:35 jvm.tomcat5-3.rrd
-rw-rw-r-- 1 xymon xymon 209480 11 sept. 22:35 jvm.tomcat5-4.rrd
-rw-rw-r-- 1 xymon xymon 209480 11 sept. 22:35 jvm.tomcat6-1.rrd
-rw-rw-r-- 1 xymon xymon 209480 11 sept. 22:35 jvm.tomcat6-2.rrd

the graphs def :

[jvm]
        FNPATTERN jvm.(.*).rrd
        TITLE Garbage Collection
        YAXIS Bytes
        DEF:EC at RRDIDX@=@RRDFN@:EC:AVERAGE
        DEF:EU at RRDIDX@=@RRDFN@:EU:AVERAGE
        DEF:OC at RRDIDX@=@RRDFN@:OC:AVERAGE
        DEF:OU at RRDIDX@=@RRDFN@:OU:AVERAGE
        DEF:PC at RRDIDX@=@RRDFN@:PC:AVERAGE
        DEF:PU at RRDIDX@=@RRDFN@:PU:AVERAGE
        DEF:GCAP at RRDIDX@=@RRDFN@:GCAP:AVERAGE
        LINE1:EC at RRDIDX@#@COLOR@:@RRDPARAM@ Current eden space capacity.\n
        GPRINT:EC at RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:EC at RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:EC at RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:EC at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n
        LINE1:EU at RRDIDX@#@COLOR@:@RRDPARAM@ Eden space utilization.\n
        GPRINT:EU at RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:EU at RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:EU at RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:EU at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n
        LINE1:OC at RRDIDX@#@COLOR@:@RRDPARAM@ Current old space capacity.\n
        GPRINT:OC at RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:OC at RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:OC at RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:OC at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n
        LINE1:OU at RRDIDX@#@COLOR@:@RRDPARAM@ Old space utilization.\n
        GPRINT:OU at RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:OU at RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:OU at RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:OU at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n
        LINE1:PC at RRDIDX@#@COLOR@:@RRDPARAM@ Current permanent space capacity.\n
        GPRINT:PC at RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:PC at RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:PC at RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:PC at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n
        LINE1:PU at RRDIDX@#@COLOR@:@RRDPARAM@ Permanent space utilization.\n
        GPRINT:PU at RRDIDX@:LAST: \: %5.1lf (cur)
        GPRINT:PU at RRDIDX@:MAX: \: %5.1lf (max)
        GPRINT:PU at RRDIDX@:MIN: \: %5.1lf (min)
        GPRINT:PU at RRDIDX@:AVERAGE: \: %5.1lf (avg)\n

I got the trends in the jvm column and in the trends column but the I have all the information in the same graph => unreadable.
So I had the jvm value to the CGI_SVC_OPTS.

CGI_SVC_OPTS="--env=$XYMONENV --no-svcid --history=top --multigraphs=jvm,disk,inode,qtree,if_load,if_err,if_col,vip-bandwith,diskstats"

On the column jvm I got the graph for the first rrd but not for the others. If I tweak the url with the right value for first and count
I can find the graph for the other rrd.

I suspect the value in the html <!-- linecount=1 --> should not be at 1 but I don't understand how this is set.

Any help would be much appreciated :)

oau

_______________________________________________
Xymon mailing list
Xymon at xymon.com
http://lists.xymon.com/mailman/listinfo/xymon



More information about the Xymon mailing list