Subject: | check_jmx4perl does not fully support aliases |
I wrote a simple alias to check cpu usage, e.g.:
===============================8<======================================
package JMX::Jmx4Perl::Product::Custom;
....
sub name {
return "custom";
}
....
sub init_aliases {
my $self = shift;
return {
attributes => {
OS_CPU_TIME => sub {
my $self = shift;
my $jmx = $self->{jmx4perl};
my $request = new JMX::Jmx4Perl::Request
(READ,"java.lang:type=OperatingSystem","ProcessCpuTime");
my $begin = $jmx->request($request);
sleep 10;
my $end = $jmx->request($request);
return new JMX::Jmx4Perl::Response(
value => sprintf("%.2f",($end->value - $begin->value) /
($end->timestamp - $begin->timestamp) / 10000000),
status => 200,
timestamp => time
)
},
},
operations => {
}
}
}
===============================>8======================================
jmx4perl works like expected, but check_jmx4perl returns an error:
UNKNOWN - Error: encountered CODE(0x9aed2dc), but JSON can only
represent references to arrays or hashes
at /usr/local/nagios/perl/lib/JSON.pm line 143.
seems it tries serialize request to JSON without checkin alias
information like jmx4perl does