master
c 61 lines 2.63 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #include "aclk_capas.h"
4
5 #include "ml/ml_public.h"
6
7 #define HTTP_API_V2_VERSION 7
8
9 size_t aclk_get_http_api_version(void) {
10 return HTTP_API_V2_VERSION;
11 }
12
13 const struct capability *aclk_get_agent_capas()
14 {
15 static struct capability agent_capabilities[] = {
16 { .name = "json", .version = 2, .enabled = 0 },
17 { .name = "proto", .version = 1, .enabled = 1 },
18 { .name = "ml", .version = 0, .enabled = 0 }, // index 2, below
19 { .name = "mc", .version = 0, .enabled = 0 }, // index 3, below
20 { .name = "ctx", .version = 1, .enabled = 1 },
21 { .name = "funcs", .version = 1, .enabled = 1 },
22 { .name = "http_api_v2", .version = HTTP_API_V2_VERSION, .enabled = 1 },
23 { .name = "health", .version = 2, .enabled = 0 }, // index 7, below
24 { .name = "req_cancel", .version = 1, .enabled = 1 },
25 { .name = "dyncfg", .version = 2, .enabled = 1 },
26 { .name = NULL, .version = 0, .enabled = 0 }
27 };
28 agent_capabilities[2].version = ml_capable() ? 1 : 0;
29 agent_capabilities[2].enabled = ml_enabled(localhost);
30
31 agent_capabilities[3].version = metric_correlations_version;
32 agent_capabilities[3].enabled = 1;
33
34 agent_capabilities[7].enabled = localhost->health.enabled;
35
36 return agent_capabilities;
37 }
38
39 struct capability *aclk_get_node_instance_capas(RRDHOST *host)
40 {
41 bool functions = (host == localhost || receiver_has_capability(host, STREAM_CAP_FUNCTIONS));
42 bool dyncfg = (host == localhost || dyncfg_available_for_rrdhost(host));
43
44 struct capability ni_caps[] = {
45 { .name = "proto", .version = 1, .enabled = 1 },
46 { .name = "ml", .version = ml_capable(), .enabled = ml_enabled(host) },
47 { .name = "mc", .version = metric_correlations_version, .enabled = 1 },
48 { .name = "ctx", .version = 1, .enabled = 1 },
49 { .name = "funcs", .version = functions ? 1 : 0, .enabled = functions ? 1 : 0 },
50 { .name = "http_api_v2", .version = HTTP_API_V2_VERSION, .enabled = 1 },
51 { .name = "health", .version = 2, .enabled = host->health.enabled},
52 { .name = "req_cancel", .version = 1, .enabled = 1 },
53 { .name = "dyncfg", .version = 2, .enabled = dyncfg },
54 { .name = NULL, .version = 0, .enabled = 0 }
55 };
56
57 struct capability *ret = mallocz(sizeof(ni_caps));
58 memcpy(ret, ni_caps, sizeof(ni_caps));
59
60 return ret;
61 }