static_threads.c 5.7 KB

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