aclk_capas.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include "aclk_capas.h"
  3. #include "ml/ml.h"
  4. #define HTTP_API_V2_VERSION 6
  5. const struct capability *aclk_get_agent_capas()
  6. {
  7. static struct capability agent_capabilities[] = {
  8. { .name = "json", .version = 2, .enabled = 0 },
  9. { .name = "proto", .version = 1, .enabled = 1 },
  10. { .name = "ml", .version = 0, .enabled = 0 }, // index 2, below
  11. { .name = "mc", .version = 0, .enabled = 0 }, // index 3, below
  12. { .name = "ctx", .version = 1, .enabled = 1 },
  13. { .name = "funcs", .version = 1, .enabled = 1 },
  14. { .name = "http_api_v2", .version = HTTP_API_V2_VERSION, .enabled = 1 },
  15. { .name = "health", .version = 1, .enabled = 0 }, // index 7, below
  16. { .name = "req_cancel", .version = 1, .enabled = 1 },
  17. { .name = NULL, .version = 0, .enabled = 0 }
  18. };
  19. agent_capabilities[2].version = ml_capable() ? 1 : 0;
  20. agent_capabilities[2].enabled = ml_enabled(localhost);
  21. agent_capabilities[3].version = enable_metric_correlations ? metric_correlations_version : 0;
  22. agent_capabilities[3].enabled = enable_metric_correlations;
  23. agent_capabilities[7].enabled = localhost->health.health_enabled;
  24. return agent_capabilities;
  25. }
  26. struct capability *aclk_get_node_instance_capas(RRDHOST *host)
  27. {
  28. bool functions = (host == localhost || (host->receiver && stream_has_capability(host->receiver, STREAM_CAP_FUNCTIONS)));
  29. struct capability ni_caps[] = {
  30. { .name = "proto", .version = 1, .enabled = 1 },
  31. { .name = "ml", .version = ml_capable(), .enabled = ml_enabled(host) },
  32. { .name = "mc",
  33. .version = enable_metric_correlations ? metric_correlations_version : 0,
  34. .enabled = enable_metric_correlations },
  35. { .name = "ctx", .version = 1, .enabled = 1 },
  36. { .name = "funcs", .version = functions ? 1 : 0, .enabled = functions ? 1 : 0 },
  37. { .name = "http_api_v2", .version = HTTP_API_V2_VERSION, .enabled = 1 },
  38. { .name = "health", .version = 1, .enabled = host->health.health_enabled },
  39. { .name = "req_cancel", .version = 1, .enabled = 1 },
  40. { .name = NULL, .version = 0, .enabled = 0 }
  41. };
  42. struct capability *ret = mallocz(sizeof(ni_caps));
  43. memcpy(ret, ni_caps, sizeof(ni_caps));
  44. return ret;
  45. }