sqlite_context.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_SQLITE_CONTEXT_H
  3. #define NETDATA_SQLITE_CONTEXT_H
  4. #include "daemon/common.h"
  5. #include "sqlite3.h"
  6. int sql_context_cache_stats(int op);
  7. typedef struct ctx_chart {
  8. uuid_t chart_id;
  9. const char *id;
  10. const char *name;
  11. const char *context;
  12. const char *title;
  13. const char *units;
  14. const char *family;
  15. int chart_type;
  16. int priority;
  17. int update_every;
  18. } SQL_CHART_DATA;
  19. typedef struct ctx_dimension {
  20. uuid_t dim_id;
  21. char *id;
  22. char *name;
  23. bool hidden;
  24. } SQL_DIMENSION_DATA;
  25. typedef struct ctx_label {
  26. char *label_key;
  27. char *label_value;
  28. int label_source;
  29. } SQL_CLABEL_DATA;
  30. // Structure to store or delete
  31. typedef struct versioned_context_data {
  32. uint64_t version; // the version of this context as EPOCH in seconds
  33. const char *id; // the id of the context
  34. const char *title; // the title of the context
  35. const char *chart_type; // the chart_type of the context
  36. const char *units; // the units of the context
  37. const char *family; // the family of the context
  38. uint64_t priority; // the chart priority of the context
  39. uint64_t first_time_s; // the first entry in the database, in seconds
  40. uint64_t last_time_s; // the last point in the database, in seconds
  41. bool deleted; // true when this is deleted
  42. } VERSIONED_CONTEXT_DATA;
  43. void ctx_get_context_list(uuid_t *host_uuid, void (*dict_cb)(VERSIONED_CONTEXT_DATA *, void *), void *data);
  44. void ctx_get_chart_list(uuid_t *host_uuid, void (*dict_cb)(SQL_CHART_DATA *, void *), void *data);
  45. void ctx_get_label_list(uuid_t *chart_uuid, void (*dict_cb)(SQL_CLABEL_DATA *, void *), void *data);
  46. void ctx_get_dimension_list(uuid_t *chart_uuid, void (*dict_cb)(SQL_DIMENSION_DATA *, void *), void *data);
  47. int ctx_store_context(uuid_t *host_uuid, VERSIONED_CONTEXT_DATA *context_data);
  48. #define ctx_update_context(host_uuid, context_data) ctx_store_context(host_uuid, context_data)
  49. int ctx_delete_context(uuid_t *host_id, VERSIONED_CONTEXT_DATA *context_data);
  50. int sql_init_context_database(int memory);
  51. void sql_close_context_database(void);
  52. int ctx_unittest(void);
  53. #endif //NETDATA_SQLITE_CONTEXT_H