static_threads.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 *health_main(void *ptr);
  8. void *pluginsd_main(void *ptr);
  9. void *service_main(void *ptr);
  10. void *statsd_main(void *ptr);
  11. void *timex_main(void *ptr);
  12. void *replication_thread_main(void *ptr __maybe_unused);
  13. extern bool global_statistics_enabled;
  14. const struct netdata_static_thread static_threads_common[] = {
  15. {
  16. .name = "PLUGIN[timex]",
  17. .config_section = CONFIG_SECTION_PLUGINS,
  18. .config_name = "timex",
  19. .enabled = 1,
  20. .thread = NULL,
  21. .init_routine = NULL,
  22. .start_routine = timex_main
  23. },
  24. {
  25. .name = "PLUGIN[idlejitter]",
  26. .config_section = CONFIG_SECTION_PLUGINS,
  27. .config_name = "idlejitter",
  28. .enabled = 1,
  29. .thread = NULL,
  30. .init_routine = NULL,
  31. .start_routine = cpuidlejitter_main
  32. },
  33. {
  34. .name = "ANALYTICS",
  35. .config_section = NULL,
  36. .config_name = NULL,
  37. .enabled = 0,
  38. .thread = NULL,
  39. .init_routine = NULL,
  40. .start_routine = analytics_main
  41. },
  42. {
  43. .name = "GLOBAL_STATS",
  44. .config_section = CONFIG_SECTION_PLUGINS,
  45. .config_name = "netdata monitoring",
  46. .env_name = "NETDATA_INTERNALS_MONITORING",
  47. .global_variable = &global_statistics_enabled,
  48. .enabled = 1,
  49. .thread = NULL,
  50. .init_routine = NULL,
  51. .start_routine = global_statistics_main
  52. },
  53. {
  54. .name = "PLUGINSD",
  55. .config_section = NULL,
  56. .config_name = NULL,
  57. .enabled = 1,
  58. .thread = NULL,
  59. .init_routine = NULL,
  60. .start_routine = pluginsd_main
  61. },
  62. {
  63. .name = "SERVICE",
  64. .config_section = NULL,
  65. .config_name = NULL,
  66. .enabled = 1,
  67. .thread = NULL,
  68. .init_routine = NULL,
  69. .start_routine = service_main
  70. },
  71. {
  72. .name = "STATSD",
  73. .config_section = NULL,
  74. .config_name = NULL,
  75. .enabled = 1,
  76. .thread = NULL,
  77. .init_routine = NULL,
  78. .start_routine = statsd_main
  79. },
  80. {
  81. .name = "EXPORTING",
  82. .config_section = NULL,
  83. .config_name = NULL,
  84. .enabled = 1,
  85. .thread = NULL,
  86. .init_routine = NULL,
  87. .start_routine = exporting_main
  88. },
  89. {
  90. .name = "STREAM",
  91. .config_section = NULL,
  92. .config_name = NULL,
  93. .enabled = 0,
  94. .thread = NULL,
  95. .init_routine = NULL,
  96. .start_routine = rrdpush_sender_thread
  97. },
  98. {
  99. .name = "WEB_SERVER[static1]",
  100. .config_section = NULL,
  101. .config_name = NULL,
  102. .enabled = 0,
  103. .thread = NULL,
  104. .init_routine = NULL,
  105. .start_routine = socket_listen_main_static_threaded
  106. },
  107. #ifdef ENABLE_ACLK
  108. {
  109. .name = "ACLK_Main",
  110. .config_section = NULL,
  111. .config_name = NULL,
  112. .enabled = 1,
  113. .thread = NULL,
  114. .init_routine = NULL,
  115. .start_routine = aclk_main
  116. },
  117. #endif
  118. {
  119. .name = "rrdcontext",
  120. .config_section = NULL,
  121. .config_name = NULL,
  122. .enabled = 1,
  123. .thread = NULL,
  124. .init_routine = NULL,
  125. .start_routine = rrdcontext_main
  126. },
  127. {
  128. .name = "replication",
  129. .config_section = NULL,
  130. .config_name = NULL,
  131. .enabled = 1,
  132. .thread = NULL,
  133. .init_routine = NULL,
  134. .start_routine = replication_thread_main
  135. },
  136. // terminator
  137. {
  138. .name = NULL,
  139. .config_section = NULL,
  140. .config_name = NULL,
  141. .env_name = NULL,
  142. .enabled = 0,
  143. .thread = NULL,
  144. .init_routine = NULL,
  145. .start_routine = NULL
  146. }
  147. };
  148. struct netdata_static_thread *
  149. static_threads_concat(const struct netdata_static_thread *lhs,
  150. const struct netdata_static_thread *rhs)
  151. {
  152. struct netdata_static_thread *res;
  153. int lhs_size = 0;
  154. for (; lhs[lhs_size].name; lhs_size++) {}
  155. int rhs_size = 0;
  156. for (; rhs[rhs_size].name; rhs_size++) {}
  157. res = callocz(lhs_size + rhs_size + 1, sizeof(struct netdata_static_thread));
  158. for (int i = 0; i != lhs_size; i++)
  159. memcpy(&res[i], &lhs[i], sizeof(struct netdata_static_thread));
  160. for (int i = 0; i != rhs_size; i++)
  161. memcpy(&res[lhs_size + i], &rhs[i], sizeof(struct netdata_static_thread));
  162. return res;
  163. }