From: Florian Forster Date: Wed, 1 Jul 2009 14:56:33 +0000 (+0200) Subject: java plugin: Improve handling of DERIVE and ABSOLUTE data source types. X-Git-Tag: collectd-4.8.0~90 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1d883b12cf82b88972cacb72e083b8ffbb28d140;p=collectd.git java plugin: Improve handling of DERIVE and ABSOLUTE data source types. --- diff --git a/src/java.c b/src/java.c index 64e51d31..80c17c3b 100644 --- a/src/java.c +++ b/src/java.c @@ -1046,33 +1046,39 @@ static int jtoc_value (JNIEnv *jvm_env, /* {{{ */ class_ptr = (*jvm_env)->GetObjectClass (jvm_env, object_ptr); - if (ds_type == DS_TYPE_COUNTER) + if (ds_type == DS_TYPE_GAUGE) { - jlong tmp_long; + jdouble tmp_double; - status = jtoc_long (jvm_env, &tmp_long, - class_ptr, object_ptr, "longValue"); + status = jtoc_double (jvm_env, &tmp_double, + class_ptr, object_ptr, "doubleValue"); if (status != 0) { ERROR ("java plugin: jtoc_value: " - "jtoc_long failed."); + "jtoc_double failed."); return (-1); } - (*ret_value).counter = (counter_t) tmp_long; + (*ret_value).gauge = (gauge_t) tmp_double; } else { - jdouble tmp_double; + jlong tmp_long; - status = jtoc_double (jvm_env, &tmp_double, - class_ptr, object_ptr, "doubleValue"); + status = jtoc_long (jvm_env, &tmp_long, + class_ptr, object_ptr, "longValue"); if (status != 0) { ERROR ("java plugin: jtoc_value: " - "jtoc_double failed."); + "jtoc_long failed."); return (-1); } - (*ret_value).gauge = (gauge_t) tmp_double; + + if (ds_type == DS_TYPE_DERIVE) + (*ret_value).derive = (derive_t) tmp_long; + else if (ds_type == DS_TYPE_ABSOLUTE) + (*ret_value).absolute = (absolute_t) tmp_long; + else + (*ret_value).counter = (counter_t) tmp_long; } return (0);