aclk_capas.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 = "dyncfg", .version = 1, .enabled = 1 },
  18. { .name = NULL, .version = 0, .enabled = 0 }
  19. };
  20. agent_capabilities[2].version = ml_capable() ? 1 : 0;
  21. agent_capabilities[2].enabled = ml_enabled(localhost);
  22. agent_capabilities[3].version = enable_metric_correlations ? metric_correlations_version : 0;
  23. agent_capabilities[3].enabled = enable_metric_correlations;
  24. agent_capabilities[7].enabled = localhost->health.health_enabled;
  25. return agent_capabilities;
  26. }
  27. struct capability *aclk_get_node_instance_capas(RRDHOST *host)
  28. {
  29. bool functions = (host == localhost || (host->receiver && stream_has_capability(host->receiver, STREAM_CAP_FUNCTIONS)));
  30. bool dyncfg = (host == localhost || dyncfg_available_for_rrdhost(host));
  31. struct capability ni_caps[] = {
  32. { .name = "proto", .version = 1, .enabled = 1 },
  33. { .name = "ml", .version = ml_capable(), .enabled = ml_enabled(host) },
  34. { .name = "mc",
  35. .version = enable_metric_correlations ? metric_correlations_version : 0,
  36. .enabled = enable_metric_correlations },
  37. { .name = "ctx", .version = 1, .enabled = 1 },
  38. { .name = "funcs", .version = functions ? 1 : 0, .enabled = functions ? 1 : 0 },
  39. { .name = "http_api_v2", .version = HTTP_API_V2_VERSION, .enabled = 1 },
  40. { .name = "health", .version = 1, .enabled = host->health.health_enabled },
  41. { .name = "req_cancel", .version = 1, .enabled = 1 },
  42. { .name = "dyncfg", .version = 1, .enabled = dyncfg },
  43. { .name = NULL, .version = 0, .enabled = 0 }
  44. };
  45. struct capability *ret = mallocz(sizeof(ni_caps));
  46. memcpy(ret, ni_caps, sizeof(ni_caps));
  47. return ret;
  48. }