diff options
Diffstat (limited to 'collectors/utils.h')
-rw-r--r-- | collectors/utils.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/collectors/utils.h b/collectors/utils.h new file mode 100644 index 0000000000..5f6d3fd8ae --- /dev/null +++ b/collectors/utils.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef COLLECTORS_UTILS_H +#define COLLECTORS_UTILS_H + +#include "database/rrd.h" + +static inline RRDSET *rrdset_find_active_localhost(const char *id) +{ + RRDSET *st = rrdset_find_by_id(rrdb.localhost, id); + if (unlikely(st && rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED))) + return NULL; + return st; +} + +static inline RRDSET *rrdset_find_active_bytype_localhost(const char *type, const char *id) +{ + RRDSET *st = rrdset_find_by_type(rrdb.localhost, type, id); + if (unlikely(st && rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED))) + return NULL; + return st; +} + + +static inline RRDSET *rrdset_find_active_byname_localhost(const char *name) +{ + RRDSET *st = rrdset_find_by_name(rrdb.localhost, name); + if (unlikely(st && rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED))) + return NULL; + return st; +} + +static inline RRDDIM *rrddim_find_active(RRDSET *st, const char *id) { + RRDDIM *rd = rrddim_find_by_id(st, id); + + if (unlikely(rd && rrddim_flag_check(rd, RRDDIM_FLAG_ARCHIVED))) + return NULL; + + return rd; +} + +#endif /* COLLECTORS_UTILS_H */ |