| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #include "common.h" |
| 4 | #include "web/api/queries/backfill.h" |
| 5 | |
| 6 | #ifdef ENABLE_SYSTEMD_DBUS |
| 7 | #include "daemon-systemd-watcher.h" |
| 8 | #endif |
| 9 | |
| 10 | void aclk_main(void *ptr); |
| 11 | void analytics_main(void *ptr); |
| 12 | void cpuidlejitter_main(void *ptr); |
| 13 | void health_main(void *ptr); |
| 14 | void pluginsd_main(void *ptr); |
| 15 | void service_main(void *ptr); |
| 16 | void statsd_main(void *ptr); |
| 17 | void profile_main(void *ptr); |
| 18 | void replication_thread_main(void *ptr); |
| 19 | |
| 20 | const struct netdata_static_thread static_threads_common[] = { |
| 21 | { |
| 22 | .name = "P[idlejitter]", |
| 23 | .config_section = CONFIG_SECTION_PLUGINS, |
| 24 | .config_name = "idlejitter", |
| 25 | .enabled = 1, |
| 26 | .thread = NULL, |
| 27 | .init_routine = NULL, |
| 28 | .start_routine = cpuidlejitter_main |
| 29 | }, |
| 30 | { |
| 31 | .name = "HEALTH", |
| 32 | .config_section = NULL, |
| 33 | .config_name = NULL, |
| 34 | .enabled = 1, |
| 35 | .thread = NULL, |
| 36 | .init_routine = NULL, |
| 37 | .start_routine = health_main |
| 38 | }, |
| 39 | { |
| 40 | .name = "ANALYTICS", |
| 41 | .config_section = NULL, |
| 42 | .config_name = NULL, |
| 43 | .enabled = 0, |
| 44 | .thread = NULL, |
| 45 | .init_routine = NULL, |
| 46 | .start_routine = analytics_main |
| 47 | }, |
| 48 | { |
| 49 | .name = "PULSE", |
| 50 | .config_section = CONFIG_SECTION_PLUGINS, |
| 51 | .config_name = "netdata pulse", |
| 52 | .env_name = "NETDATA_INTERNALS_MONITORING", |
| 53 | .global_variable = &pulse_enabled, |
| 54 | .enabled = 1, |
| 55 | .thread = NULL, |
| 56 | .init_routine = NULL, |
| 57 | .start_routine = pulse_thread_main |
| 58 | }, |
| 59 | { |
| 60 | .name = "PULSE-SQLITE3", |
| 61 | .config_section = CONFIG_SECTION_PULSE, |
| 62 | .config_name = "extended", |
| 63 | .env_name = NULL, |
| 64 | .global_variable = &pulse_extended_enabled, |
| 65 | .enabled = 0, // the default value - it uses netdata.conf for users to enable it |
| 66 | .thread = NULL, |
| 67 | .init_routine = NULL, |
| 68 | .start_routine = pulse_thread_sqlite3_main |
| 69 | }, |
| 70 | { |
| 71 | .name = "PULSE-WORKERS", |
| 72 | .config_section = CONFIG_SECTION_PULSE, |
| 73 | .config_name = "extended", |
| 74 | .env_name = NULL, |
| 75 | .global_variable = &pulse_extended_enabled, |
| 76 | .enabled = 0, // the default value - it uses netdata.conf for users to enable it |
| 77 | .thread = NULL, |
| 78 | .init_routine = NULL, |
| 79 | .start_routine = pulse_thread_workers_main |
| 80 | }, |
| 81 | { |
| 82 | .name = "PULSE-MEMORY", |
| 83 | .config_section = CONFIG_SECTION_PULSE, |
| 84 | .config_name = "extended", |
| 85 | .env_name = NULL, |
| 86 | .global_variable = &pulse_extended_enabled, |
| 87 | .enabled = 0, // the default value - it uses netdata.conf for users to enable it |
| 88 | .thread = NULL, |
| 89 | .init_routine = NULL, |
| 90 | .start_routine = pulse_thread_memory_extended_main}, |
| 91 | { |
| 92 | .name = "PLUGINSD", |
| 93 | .config_section = NULL, |
| 94 | .config_name = NULL, |
| 95 | .enabled = 1, |
| 96 | .thread = NULL, |
| 97 | .init_routine = NULL, |
| 98 | .start_routine = pluginsd_main |
| 99 | }, |
| 100 | { |
| 101 | .name = "STATSD_FLUSH", |
| 102 | .config_section = NULL, |
| 103 | .config_name = NULL, |
| 104 | .enabled = 1, |
| 105 | .thread = NULL, |
| 106 | .init_routine = NULL, |
| 107 | .start_routine = statsd_main |
| 108 | }, |
| 109 | { |
| 110 | .name = "EXPORTING", |
| 111 | .config_section = NULL, |
| 112 | .config_name = NULL, |
| 113 | .enabled = 1, |
| 114 | .thread = NULL, |
| 115 | .init_routine = NULL, |
| 116 | .start_routine = exporting_main |
| 117 | }, |
| 118 | { |
| 119 | .name = "SNDR[localhost]", |
| 120 | .config_section = NULL, |
| 121 | .config_name = NULL, |
| 122 | .enabled = 0, |
| 123 | .thread = NULL, |
| 124 | .init_routine = NULL, |
| 125 | .start_routine = stream_sender_start_localhost |
| 126 | }, |
| 127 | { |
| 128 | .name = "WEB[1]", |
| 129 | .config_section = NULL, |
| 130 | .config_name = NULL, |
| 131 | .enabled = 0, |
| 132 | .thread = NULL, |
| 133 | .init_routine = NULL, |
| 134 | .start_routine = socket_listen_main_static_threaded |
| 135 | }, |
| 136 | |
| 137 | { |
| 138 | .name = "ACLK_MAIN", |
| 139 | .config_section = NULL, |
| 140 | .config_name = NULL, |
| 141 | .enabled = 1, |
| 142 | .thread = NULL, |
| 143 | .init_routine = NULL, |
| 144 | .start_routine = aclk_main |
| 145 | }, |
| 146 | |
| 147 | { |
| 148 | .name = "RRDCONTEXT", |
| 149 | .config_section = NULL, |
| 150 | .config_name = NULL, |
| 151 | .enabled = 1, |
| 152 | .thread = NULL, |
| 153 | .init_routine = NULL, |
| 154 | .start_routine = rrdcontext_main |
| 155 | }, |
| 156 | |
| 157 | { |
| 158 | .name = "REPLAY[1]", |
| 159 | .config_section = NULL, |
| 160 | .config_name = NULL, |
| 161 | .enabled = 1, |
| 162 | .thread = NULL, |
| 163 | .init_routine = NULL, |
| 164 | .start_routine = replication_thread_main |
| 165 | }, |
| 166 | { |
| 167 | .name = "P[PROFILE]", |
| 168 | .config_section = CONFIG_SECTION_PLUGINS, |
| 169 | .config_name = "profile", |
| 170 | .enabled = 0, |
| 171 | .thread = NULL, |
| 172 | .init_routine = NULL, |
| 173 | .start_routine = profile_main |
| 174 | }, |
| 175 | { |
| 176 | .name = "BACKFILL", |
| 177 | .config_section = NULL, |
| 178 | .config_name = NULL, |
| 179 | .enable_routine = netdata_conf_is_parent, |
| 180 | .enabled = 0, |
| 181 | .thread = NULL, |
| 182 | .init_routine = NULL, |
| 183 | .start_routine = backfill_thread |
| 184 | }, |
| 185 | |
| 186 | #ifdef ENABLE_SYSTEMD_DBUS |
| 187 | { |
| 188 | .name = "SDBUSWATCHER", |
| 189 | .config_section = NULL, |
| 190 | .config_name = NULL, |
| 191 | .enable_routine = NULL, |
| 192 | .enabled = 1, |
| 193 | .thread = NULL, |
| 194 | .init_routine = NULL, |
| 195 | .start_routine = systemd_watcher_thread |
| 196 | }, |
| 197 | #endif |
| 198 | |
| 199 | // terminator |
| 200 | { |
| 201 | .name = NULL, |
| 202 | .config_section = NULL, |
| 203 | .config_name = NULL, |
| 204 | .env_name = NULL, |
| 205 | .enabled = 0, |
| 206 | .thread = NULL, |
| 207 | .init_routine = NULL, |
| 208 | .start_routine = NULL |
| 209 | } |
| 210 | }; |
| 211 | |
| 212 | struct netdata_static_thread * |
| 213 | static_threads_concat(const struct netdata_static_thread *lhs, |
| 214 | const struct netdata_static_thread *rhs) |
| 215 | { |
| 216 | struct netdata_static_thread *res; |
| 217 | |
| 218 | int lhs_size = 0; |
| 219 | for (; lhs[lhs_size].name; lhs_size++) {} |
| 220 | |
| 221 | int rhs_size = 0; |
| 222 | for (; rhs[rhs_size].name; rhs_size++) {} |
| 223 | |
| 224 | res = callocz(lhs_size + rhs_size + 1, sizeof(struct netdata_static_thread)); |
| 225 | |
| 226 | for (int i = 0; i != lhs_size; i++) |
| 227 | memcpy(&res[i], &lhs[i], sizeof(struct netdata_static_thread)); |
| 228 | |
| 229 | for (int i = 0; i != rhs_size; i++) |
| 230 | memcpy(&res[lhs_size + i], &rhs[i], sizeof(struct netdata_static_thread)); |
| 231 | |
| 232 | return res; |
| 233 | } |