static_threads.c 4.1 KB

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