rrdvar.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_RRDVAR_H
  3. #define NETDATA_RRDVAR_H 1
  4. #include "libnetdata/libnetdata.h"
  5. typedef enum rrdvar_type {
  6. RRDVAR_TYPE_CALCULATED = 1,
  7. RRDVAR_TYPE_TIME_T = 2,
  8. RRDVAR_TYPE_COLLECTED = 3,
  9. RRDVAR_TYPE_TOTAL = 4,
  10. RRDVAR_TYPE_INT = 5
  11. // this is 8 bit
  12. // to increase it you have to set change the bitfield in
  13. // rrdvar, rrdsetvar, rrddimvar
  14. } RRDVAR_TYPE;
  15. typedef enum rrdvar_options {
  16. RRDVAR_FLAG_NONE = 0,
  17. RRDVAR_FLAG_ALLOCATED = (1 << 0), // the value ptr is allocated (not a reference)
  18. RRDVAR_FLAG_CUSTOM_HOST_VAR = (1 << 1), // this is a custom host variable, not associated with a dimension
  19. RRDVAR_FLAG_CUSTOM_CHART_VAR = (1 << 2), // this is a custom chart variable, not associated with a dimension
  20. RRDVAR_FLAG_RRDCALC_LOCAL_VAR = (1 << 3), // this is a an alarm variable, attached to a chart
  21. RRDVAR_FLAG_RRDCALC_FAMILY_VAR = (1 << 4), // this is a an alarm variable, attached to a family
  22. RRDVAR_FLAG_RRDCALC_HOST_CHARTID_VAR = (1 << 5), // this is a an alarm variable, attached to the host, using the chart id
  23. RRDVAR_FLAG_RRDCALC_HOST_CHARTNAME_VAR = (1 << 6), // this is a an alarm variable, attached to the host, using the chart name
  24. // this is 24 bit
  25. // to increase it you have to set change the bitfield in
  26. // rrdvar, rrdsetvar, rrddimvar
  27. } RRDVAR_FLAGS;
  28. #define RRDVAR_OPTIONS_REMOVED_ON_NEW_OBJECTS \
  29. (RRDVAR_FLAG_ALLOCATED)
  30. #define RRDVAR_OPTIONS_REMOVED_WHEN_PROPAGATING_TO_RRDVAR \
  31. (RRDVAR_FLAG_ALLOCATED)
  32. #define RRDVAR_MAX_LENGTH 1024
  33. int rrdvar_fix_name(char *variable);
  34. #include "rrd.h"
  35. STRING *rrdvar_name_to_string(const char *name);
  36. const RRDVAR_ACQUIRED *rrdvar_custom_host_variable_add_and_acquire(RRDHOST *host, const char *name);
  37. void rrdvar_custom_host_variable_set(RRDHOST *host, const RRDVAR_ACQUIRED *rva, NETDATA_DOUBLE value);
  38. int rrdvar_walkthrough_read(DICTIONARY *dict, int (*callback)(const DICTIONARY_ITEM *item, void *rrdvar, void *data), void *data);
  39. #define rrdvar_custom_host_variable_release(host, rva) rrdvar_release((host)->rrdvars, rva)
  40. void rrdvar_release(DICTIONARY *dict, const RRDVAR_ACQUIRED *rva);
  41. NETDATA_DOUBLE rrdvar2number(const RRDVAR_ACQUIRED *rva);
  42. const RRDVAR_ACQUIRED *rrdvar_add_and_acquire(const char *scope, DICTIONARY *dict, STRING *name, RRDVAR_TYPE type, RRDVAR_FLAGS options, void *value);
  43. void rrdvar_release_and_del(DICTIONARY *dict, const RRDVAR_ACQUIRED *rva);
  44. DICTIONARY *rrdvariables_create(void);
  45. void rrdvariables_destroy(DICTIONARY *dict);
  46. void rrdvar_delete_all(DICTIONARY *dict);
  47. const char *rrdvar_name(const RRDVAR_ACQUIRED *rva);
  48. RRDVAR_FLAGS rrdvar_flags(const RRDVAR_ACQUIRED *rva);
  49. RRDVAR_TYPE rrdvar_type(const RRDVAR_ACQUIRED *rva);
  50. #endif //NETDATA_RRDVAR_H