static_threads.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include "common.h"
  3. void *aclk_main(void *ptr);
  4. void *analytics_main(void *ptr);
  5. void *cpuidlejitter_main(void *ptr);
  6. void *global_statistics_main(void *ptr);
  7. void *global_statistics_workers_main(void *ptr);
  8. void *global_statistics_sqlite3_main(void *ptr);
  9. void *health_main(void *ptr);
  10. void *pluginsd_main(void *ptr);
  11. void *service_main(void *ptr);
  12. void *statsd_main(void *ptr);
  13. void *timex_main(void *ptr);
  14. void *profile_main(void *ptr);
  15. void *replication_thread_main(void *ptr __maybe_unused);
  16. extern bool global_statistics_enabled;
  17. const struct netdata_static_thread static_threads_common[] = {
  18. {
  19. .name = "P[timex]",
  20. .config_section = CONFIG_SECTION_PLUGINS,
  21. .config_name = "timex",
  22. .enabled = 1,
  23. .thread = NULL,
  24. .init_routine = NULL,
  25. .start_routine = timex_main
  26. },
  27. {
  28. .name = "P[idlejitter]",
  29. .config_section = CONFIG_SECTION_PLUGINS,
  30. .config_name = "idlejitter",
  31. .enabled = 1,
  32. .thread = NULL,
  33. .init_routine = NULL,
  34. .start_routine = cpuidlejitter_main
  35. },
  36. {
  37. .name = "HEALTH",
  38. .config_section = NULL,
  39. .config_name = NULL,
  40. .enabled = 1,
  41. .thread = NULL,
  42. .init_routine = NULL,
  43. .start_routine = health_main
  44. },
  45. {
  46. .name = "ANALYTICS",
  47. .config_section = NULL,
  48. .config_name = NULL,
  49. .enabled = 0,
  50. .thread = NULL,
  51. .init_routine = NULL,
  52. .start_routine = analytics_main
  53. },
  54. {
  55. .name = "STATS_GLOBAL",
  56. .config_section = CONFIG_SECTION_PLUGINS,
  57. .config_name = "netdata monitoring",
  58. .env_name = "NETDATA_INTERNALS_MONITORING",
  59. .global_variable = &global_statistics_enabled,
  60. .enabled = 1,
  61. .thread = NULL,
  62. .init_routine = NULL,
  63. .start_routine = global_statistics_main
  64. },
  65. {
  66. .name = "STATS_WORKERS",
  67. .config_section = CONFIG_SECTION_PLUGINS,
  68. .config_name = "netdata monitoring",
  69. .env_name = "NETDATA_INTERNALS_MONITORING",
  70. .global_variable = &global_statistics_enabled,
  71. .enabled = 1,
  72. .thread = NULL,
  73. .init_routine = NULL,
  74. .start_routine = global_statistics_workers_main
  75. },
  76. {
  77. .name = "STATS_SQLITE3",
  78. .config_section = CONFIG_SECTION_PLUGINS,
  79. .config_name = "netdata monitoring",
  80. .env_name = "NETDATA_INTERNALS_MONITORING",
  81. .global_variable = &global_statistics_enabled,
  82. .enabled = 1,
  83. .thread = NULL,
  84. .init_routine = NULL,
  85. .start_routine = global_statistics_sqlite3_main
  86. },
  87. {
  88. .name = "PLUGINSD",
  89. .config_section = NULL,
  90. .config_name = NULL,
  91. .enabled = 1,
  92. .thread = NULL,
  93. .init_routine = NULL,
  94. .start_routine = pluginsd_main
  95. },
  96. {
  97. .name = "SERVICE",
  98. .config_section = NULL,
  99. .config_name = NULL,
  100. .enabled = 1,
  101. .thread = NULL,
  102. .init_routine = NULL,
  103. .start_routine = service_main
  104. },
  105. {
  106. .name = "STATSD_FLUSH",
  107. .config_section = NULL,
  108. .config_name = NULL,
  109. .enabled = 1,
  110. .thread = NULL,
  111. .init_routine = NULL,
  112. .start_routine = statsd_main
  113. },
  114. {
  115. .name = "EXPORTING",
  116. .config_section = NULL,
  117. .config_name = NULL,
  118. .enabled = 1,
  119. .thread = NULL,
  120. .init_routine = NULL,
  121. .start_routine = exporting_main
  122. },
  123. {
  124. .name = "SNDR[localhost]",
  125. .config_section = NULL,
  126. .config_name = NULL,
  127. .enabled = 0,
  128. .thread = NULL,
  129. .init_routine = NULL,
  130. .start_routine = rrdpush_sender_thread
  131. },
  132. {
  133. .name = "WEB[1]",
  134. .config_section = NULL,
  135. .config_name = NULL,
  136. .enabled = 0,
  137. .thread = NULL,
  138. .init_routine = NULL,
  139. .start_routine = socket_listen_main_static_threaded
  140. },
  141. #ifdef ENABLE_H2O
  142. {
  143. .name = "h2o",
  144. .config_section = NULL,
  145. .config_name = NULL,
  146. .enabled = 0,
  147. .thread = NULL,
  148. .init_routine = NULL,
  149. .start_routine = h2o_main
  150. },
  151. #endif
  152. #ifdef ENABLE_ACLK
  153. {
  154. .name = "ACLK_MAIN",
  155. .config_section = NULL,
  156. .config_name = NULL,
  157. .enabled = 1,
  158. .thread = NULL,
  159. .init_routine = NULL,
  160. .start_routine = aclk_main
  161. },
  162. #endif
  163. {
  164. .name = "RRDCONTEXT",
  165. .config_section = NULL,
  166. .config_name = NULL,
  167. .enabled = 1,
  168. .thread = NULL,
  169. .init_routine = NULL,
  170. .start_routine = rrdcontext_main
  171. },
  172. {
  173. .name = "REPLAY[1]",
  174. .config_section = NULL,
  175. .config_name = NULL,
  176. .enabled = 1,
  177. .thread = NULL,
  178. .init_routine = NULL,
  179. .start_routine = replication_thread_main
  180. },
  181. {
  182. .name = "P[PROFILE]",
  183. .config_section = CONFIG_SECTION_PLUGINS,
  184. .config_name = "profile",
  185. .enabled = 0,
  186. .thread = NULL,
  187. .init_routine = NULL,
  188. .start_routine = profile_main
  189. },
  190. {
  191. .name = "DYNCFG",
  192. .config_section = NULL,
  193. .config_name = NULL,
  194. .enabled = 1,
  195. .thread = NULL,
  196. .init_routine = NULL,
  197. .start_routine = dyncfg_main
  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. struct netdata_static_thread *
  212. static_threads_concat(const struct netdata_static_thread *lhs,
  213. const struct netdata_static_thread *rhs)
  214. {
  215. struct netdata_static_thread *res;
  216. int lhs_size = 0;
  217. for (; lhs[lhs_size].name; lhs_size++) {}
  218. int rhs_size = 0;
  219. for (; rhs[rhs_size].name; rhs_size++) {}
  220. res = callocz(lhs_size + rhs_size + 1, sizeof(struct netdata_static_thread));
  221. for (int i = 0; i != lhs_size; i++)
  222. memcpy(&res[i], &lhs[i], sizeof(struct netdata_static_thread));
  223. for (int i = 0; i != rhs_size; i++)
  224. memcpy(&res[lhs_size + i], &rhs[i], sizeof(struct netdata_static_thread));
  225. return res;
  226. }