aclk_capas.c 1.8 KB

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