From 60c387cb3adda350ac8607afd87a282857109a57 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 10 Apr 2010 12:25:24 +0200 Subject: [PATCH] pinba plugin: Multiply the derive data sources by a factor. Otherwise the change is too slow to be really useful. --- src/pinba.c | 21 ++++++++++++--------- src/types.db | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/pinba.c b/src/pinba.c index 9697cf27..8ddd9966 100644 --- a/src/pinba.c +++ b/src/pinba.c @@ -135,12 +135,15 @@ static void float_counter_add (float_counter_t *fc, float val) /* {{{ */ } } /* }}} void float_counter_add */ -static derive_t float_counter_get (const float_counter_t *fc) /* {{{ */ +static derive_t float_counter_get (const float_counter_t *fc, /* {{{ */ + uint64_t factor) { - if (fc->n >= 500000000) - return ((derive_t) (fc->i + 1)); - else - return ((derive_t) fc->i); + derive_t ret; + + ret = (derive_t) (fc->i * factor); + ret += (derive_t) (fc->n / (1000000000 / factor)); + + return (ret); } /* }}} derive_t float_counter_get */ static void strset (char **str, const char *new) /* {{{ */ @@ -697,16 +700,16 @@ static int plugin_submit (const pinba_statnode_t *res) /* {{{ */ sstrncpy (vl.type, "requests", sizeof (vl.type)); plugin_dispatch_values (&vl); - value.derive = float_counter_get (&res->req_time); - sstrncpy (vl.type, "total_time", sizeof (vl.type)); + value.derive = float_counter_get (&res->req_time, /* factor = */ 1000); + sstrncpy (vl.type, "total_time_in_ms", sizeof (vl.type)); plugin_dispatch_values (&vl); - value.derive = float_counter_get (&res->ru_utime); + value.derive = float_counter_get (&res->ru_utime, /* factor = */ 100); sstrncpy (vl.type, "cpu", sizeof (vl.type)); sstrncpy (vl.type_instance, "user", sizeof (vl.type_instance)); plugin_dispatch_values (&vl); - value.derive = float_counter_get (&res->ru_stime); + value.derive = float_counter_get (&res->ru_stime, /* factor = */ 100); sstrncpy (vl.type, "cpu", sizeof (vl.type)); sstrncpy (vl.type_instance, "system", sizeof (vl.type_instance)); plugin_dispatch_values (&vl); diff --git a/src/types.db b/src/types.db index 29916027..a1bcc28d 100644 --- a/src/types.db +++ b/src/types.db @@ -156,7 +156,6 @@ timeleft timeleft:GAUGE:0:3600 time_offset seconds:GAUGE:-1000000:1000000 total_requests value:DERIVE:0:U total_time_in_ms value:DERIVE:0:U -total_time value:DERIVE:0:U total_values value:DERIVE:0:U uptime value:GAUGE:0:4294967295 users users:GAUGE:0:65535 -- 2.30.2