diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2023-11-07 13:53:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 13:53:07 +0200 |
commit | 10238fc52aba2a200aade43ebfd1b4a9c29e6a3c (patch) | |
tree | 66a89606de7f82853eab41640585790967073a17 /database | |
parent | 7a73af1da1f775c2eb83d1856b687d68f30d6ee9 (diff) |
add rrddim_get_last_stored_value to simplify function code in internal collectors (#16348)
Diffstat (limited to 'database')
-rw-r--r-- | database/rrd.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/database/rrd.h b/database/rrd.h index 17ef5d544b..3687497ffd 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -1668,6 +1668,22 @@ void rrdset_pluginsd_receive_unslot_and_cleanup(RRDSET *st); void rrdset_pluginsd_receive_unslot(RRDSET *st); // ---------------------------------------------------------------------------- +static inline double rrddim_get_last_stored_value(RRDDIM *rd_dim, double *max_value, double div) { + if (!rd_dim) + return NAN; + + if (isnan(div) || div == 0.0) + div = 1.0; + + double value = rd_dim->collector.last_stored_value / div; + value = ABS(value); + + *max_value = MAX(*max_value, value); + + return value; +} + +// // RRD DB engine declarations #ifdef ENABLE_DBENGINE |