static_threads.c 6.0 KB

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