master
h 103 lines 3.26 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_ANALYTICS_H
4 #define NETDATA_ANALYTICS_H 1
5
6 #include "daemon/common.h"
7 #include "database/rrdhost-system-info.h"
8
9 /* Max number of seconds before the first META analytics is sent */
10 #define ANALYTICS_INIT_SLEEP_SEC (120)
11 #define ANALYTICS_INIT_IMMUTABLE_DATA_SEC (10)
12
13
14 /* Send a META event every X seconds */
15 #define ANALYTICS_HEARTBEAT (6 * 3600)
16
17 /* Maximum number of hits to log */
18 #define ANALYTICS_MAX_PROMETHEUS_HITS 255
19 #define ANALYTICS_MAX_SHELL_HITS 255
20 #define ANALYTICS_MAX_JSON_HITS 255
21 #define ANALYTICS_MAX_DASHBOARD_HITS 255
22
23 /* Needed to calculate the space needed for parameters */
24 #define ANALYTICS_NO_OF_ITEMS 40
25
26 struct analytics_data {
27 char *netdata_config_stream_enabled;
28 char *netdata_config_memory_mode;
29 char *netdata_exporting_connectors;
30 char *netdata_config_exporting_enabled;
31 char *netdata_allmetrics_prometheus_used;
32 char *netdata_allmetrics_shell_used;
33 char *netdata_allmetrics_json_used;
34 char *netdata_dashboard_used;
35 char *netdata_collectors;
36 char *netdata_collectors_count;
37 char *netdata_buildinfo;
38 char *netdata_config_page_cache_size;
39 char *netdata_config_multidb_disk_quota;
40 char *netdata_config_https_enabled;
41 char *netdata_config_web_enabled;
42 char *netdata_config_release_channel;
43 char *netdata_mirrored_host_count;
44 char *netdata_mirrored_hosts_reachable;
45 char *netdata_mirrored_hosts_unreachable;
46 char *netdata_notification_methods;
47 char *netdata_alarms_normal;
48 char *netdata_alarms_warning;
49 char *netdata_alarms_critical;
50 char *netdata_charts_count;
51 char *netdata_metrics_count;
52 char *netdata_config_is_parent;
53 char *netdata_config_hosts_available;
54 char *netdata_host_cloud_available;
55 char *netdata_host_aclk_available;
56 char *netdata_host_aclk_protocol;
57 char *netdata_host_aclk_implementation;
58 char *netdata_host_agent_claimed;
59 char *netdata_host_cloud_enabled;
60 char *netdata_config_https_available;
61 char *netdata_install_type;
62 char *netdata_config_is_private_registry;
63 char *netdata_config_use_private_registry;
64 char *netdata_config_oom_score;
65 char *netdata_prebuilt_distro;
66 char *netdata_fail_reason;
67
68 size_t data_length;
69
70 size_t prometheus_hits;
71 size_t shell_hits;
72 size_t json_hits;
73 size_t dashboard_hits;
74
75 size_t charts_count;
76 size_t metrics_count;
77 SPINLOCK spinlock;
78
79 bool exporting_enabled;
80 };
81
82 void set_late_analytics_variables(struct rrdhost_system_info *system_info);
83 void analytics_free_data(void);
84 void analytics_log_shell(void);
85 void analytics_log_json(void);
86 void analytics_log_prometheus(void);
87 void analytics_log_dashboard(void);
88 void analytics_gather_mutable_meta_data(void);
89 void analytics_report_oom_score(long long int score);
90 void get_system_timezone(void);
91 bool system_timezone_is_user_configured(void);
92 bool system_timezone_is_tzdb_name(void);
93 const char *detect_system_timezone_name(char *buffer, size_t buffer_size);
94 bool timezone_name_is_safe_tzdb_path(const char *timezone);
95 void refresh_system_timezone(const char *timezone, bool is_tzdb_name);
96 void analytics_reset(void);
97 void analytics_init(void);
98
99 bool analytics_check_enabled(void);
100
101 extern struct analytics_data analytics_data;
102
103 #endif //NETDATA_ANALYTICS_H