static_threads.c 4.3 KB

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