buildinfo.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include <stdio.h>
  3. #include "./config.h"
  4. // Optional features
  5. #ifdef ENABLE_ACLK
  6. #define FEAT_CLOUD 1
  7. #define FEAT_CLOUD_MSG ""
  8. #ifdef ACLK_NG
  9. #define ACLK_IMPL "Next Generation"
  10. #else
  11. #define ACLK_IMPL "Legacy"
  12. #endif
  13. #else
  14. #define ACLK_IMPL ""
  15. #ifdef DISABLE_CLOUD
  16. #define FEAT_CLOUD 0
  17. #define FEAT_CLOUD_MSG "(by user request)"
  18. #else
  19. #define FEAT_CLOUD 0
  20. #define FEAT_CLOUD_MSG ""
  21. #endif
  22. #endif
  23. #ifdef ENABLE_DBENGINE
  24. #define FEAT_DBENGINE 1
  25. #else
  26. #define FEAT_DBENGINE 0
  27. #endif
  28. #if defined(HAVE_X509_VERIFY_PARAM_set1_host) && HAVE_X509_VERIFY_PARAM_set1_host == 1
  29. #define FEAT_TLS_HOST_VERIFY 1
  30. #else
  31. #define FEAT_TLS_HOST_VERIFY 0
  32. #endif
  33. #ifdef ENABLE_HTTPS
  34. #define FEAT_NATIVE_HTTPS 1
  35. #else
  36. #define FEAT_NATIVE_HTTPS 0
  37. #endif
  38. // Optional libraries
  39. #ifdef ENABLE_JSONC
  40. #define FEAT_JSONC 1
  41. #else
  42. #define FEAT_JSONC 0
  43. #endif
  44. #ifdef ENABLE_JEMALLOC
  45. #define FEAT_JEMALLOC 1
  46. #else
  47. #define FEAT_JEMALLOC 0
  48. #endif
  49. #ifdef ENABLE_TCMALLOC
  50. #define FEAT_TCMALLOC 1
  51. #else
  52. #define FEAT_TCMALLOC 0
  53. #endif
  54. #ifdef HAVE_CAPABILITY
  55. #define FEAT_LIBCAP 1
  56. #else
  57. #define FEAT_LIBCAP 0
  58. #endif
  59. #ifndef ACLK_NG
  60. #ifdef ACLK_NO_LIBMOSQ
  61. #define FEAT_MOSQUITTO 0
  62. #else
  63. #define FEAT_MOSQUITTO 1
  64. #endif
  65. #ifdef ACLK_NO_LWS
  66. #define FEAT_LWS 0
  67. #define FEAT_LWS_MSG ""
  68. #else
  69. #ifdef ENABLE_ACLK
  70. #include <libwebsockets.h>
  71. #endif
  72. #ifdef BUNDLED_LWS
  73. #define FEAT_LWS 1
  74. #define FEAT_LWS_MSG "static"
  75. #else
  76. #define FEAT_LWS 1
  77. #define FEAT_LWS_MSG "shared-lib"
  78. #endif
  79. #endif
  80. #endif /* ACLK_NG */
  81. #ifdef NETDATA_WITH_ZLIB
  82. #define FEAT_ZLIB 1
  83. #else
  84. #define FEAT_ZLIB 0
  85. #endif
  86. #ifdef STORAGE_WITH_MATH
  87. #define FEAT_LIBM 1
  88. #else
  89. #define FEAT_LIBM 0
  90. #endif
  91. #ifdef HAVE_CRYPTO
  92. #define FEAT_CRYPTO 1
  93. #else
  94. #define FEAT_CRYPTO 0
  95. #endif
  96. // Optional plugins
  97. #ifdef ENABLE_APPS_PLUGIN
  98. #define FEAT_APPS_PLUGIN 1
  99. #else
  100. #define FEAT_APPS_PLUGIN 0
  101. #endif
  102. #ifdef HAVE_FREEIPMI
  103. #define FEAT_IPMI 1
  104. #else
  105. #define FEAT_IPMI 0
  106. #endif
  107. #ifdef HAVE_CUPS
  108. #define FEAT_CUPS 1
  109. #else
  110. #define FEAT_CUPS 0
  111. #endif
  112. #ifdef HAVE_NFACCT
  113. #define FEAT_NFACCT 1
  114. #else
  115. #define FEAT_NFACCT 0
  116. #endif
  117. #ifdef HAVE_LIBXENSTAT
  118. #define FEAT_XEN 1
  119. #else
  120. #define FEAT_XEN 0
  121. #endif
  122. #ifdef HAVE_XENSTAT_VBD_ERROR
  123. #define FEAT_XEN_VBD_ERROR 1
  124. #else
  125. #define FEAT_XEN_VBD_ERROR 0
  126. #endif
  127. #ifdef HAVE_LIBBPF
  128. #define FEAT_EBPF 1
  129. #else
  130. #define FEAT_EBPF 0
  131. #endif
  132. #ifdef HAVE_SETNS
  133. #define FEAT_CGROUP_NET 1
  134. #else
  135. #define FEAT_CGROUP_NET 0
  136. #endif
  137. #ifdef ENABLE_PERF_PLUGIN
  138. #define FEAT_PERF 1
  139. #else
  140. #define FEAT_PERF 0
  141. #endif
  142. #ifdef ENABLE_SLABINFO
  143. #define FEAT_SLABINFO 1
  144. #else
  145. #define FEAT_SLABINFO 0
  146. #endif
  147. // Optional Exporters
  148. #ifdef HAVE_KINESIS
  149. #define FEAT_KINESIS 1
  150. #else
  151. #define FEAT_KINESIS 0
  152. #endif
  153. #ifdef ENABLE_EXPORTING_PUBSUB
  154. #define FEAT_PUBSUB 1
  155. #else
  156. #define FEAT_PUBSUB 0
  157. #endif
  158. #ifdef HAVE_MONGOC
  159. #define FEAT_MONGO 1
  160. #else
  161. #define FEAT_MONGO 0
  162. #endif
  163. #ifdef ENABLE_PROMETHEUS_REMOTE_WRITE
  164. #define FEAT_REMOTE_WRITE 1
  165. #else
  166. #define FEAT_REMOTE_WRITE 0
  167. #endif
  168. #define FEAT_YES_NO(x) ((x) ? "YES" : "NO")
  169. void print_build_info(void) {
  170. printf("Configure options: %s\n", CONFIGURE_COMMAND);
  171. printf("Features:\n");
  172. printf(" dbengine: %s\n", FEAT_YES_NO(FEAT_DBENGINE));
  173. printf(" Native HTTPS: %s\n", FEAT_YES_NO(FEAT_NATIVE_HTTPS));
  174. printf(" Netdata Cloud: %s %s\n", FEAT_YES_NO(FEAT_CLOUD), FEAT_CLOUD_MSG);
  175. #if FEAT_CLOUD == 1
  176. printf(" Cloud Implementation: %s\n", ACLK_IMPL);
  177. #endif
  178. printf(" TLS Host Verification: %s\n", FEAT_YES_NO(FEAT_TLS_HOST_VERIFY));
  179. printf("Libraries:\n");
  180. printf(" jemalloc: %s\n", FEAT_YES_NO(FEAT_JEMALLOC));
  181. printf(" JSON-C: %s\n", FEAT_YES_NO(FEAT_JSONC));
  182. printf(" libcap: %s\n", FEAT_YES_NO(FEAT_LIBCAP));
  183. printf(" libcrypto: %s\n", FEAT_YES_NO(FEAT_CRYPTO));
  184. printf(" libm: %s\n", FEAT_YES_NO(FEAT_LIBM));
  185. #ifndef ACLK_NG
  186. #if defined(ENABLE_ACLK)
  187. printf(" LWS: %s %s v%d.%d.%d\n", FEAT_YES_NO(FEAT_LWS), FEAT_LWS_MSG, LWS_LIBRARY_VERSION_MAJOR, LWS_LIBRARY_VERSION_MINOR, LWS_LIBRARY_VERSION_PATCH);
  188. #else
  189. printf(" LWS: %s %s\n", FEAT_YES_NO(FEAT_LWS), FEAT_LWS_MSG);
  190. #endif
  191. printf(" mosquitto: %s\n", FEAT_YES_NO(FEAT_MOSQUITTO));
  192. #endif
  193. printf(" tcalloc: %s\n", FEAT_YES_NO(FEAT_TCMALLOC));
  194. printf(" zlib: %s\n", FEAT_YES_NO(FEAT_ZLIB));
  195. printf("Plugins:\n");
  196. printf(" apps: %s\n", FEAT_YES_NO(FEAT_APPS_PLUGIN));
  197. printf(" cgroup Network Tracking: %s\n", FEAT_YES_NO(FEAT_CGROUP_NET));
  198. printf(" CUPS: %s\n", FEAT_YES_NO(FEAT_CUPS));
  199. printf(" EBPF: %s\n", FEAT_YES_NO(FEAT_EBPF));
  200. printf(" IPMI: %s\n", FEAT_YES_NO(FEAT_IPMI));
  201. printf(" NFACCT: %s\n", FEAT_YES_NO(FEAT_NFACCT));
  202. printf(" perf: %s\n", FEAT_YES_NO(FEAT_PERF));
  203. printf(" slabinfo: %s\n", FEAT_YES_NO(FEAT_SLABINFO));
  204. printf(" Xen: %s\n", FEAT_YES_NO(FEAT_XEN));
  205. printf(" Xen VBD Error Tracking: %s\n", FEAT_YES_NO(FEAT_XEN_VBD_ERROR));
  206. printf("Exporters:\n");
  207. printf(" AWS Kinesis: %s\n", FEAT_YES_NO(FEAT_KINESIS));
  208. printf(" GCP PubSub: %s\n", FEAT_YES_NO(FEAT_PUBSUB));
  209. printf(" MongoDB: %s\n", FEAT_YES_NO(FEAT_MONGO));
  210. printf(" Prometheus Remote Write: %s\n", FEAT_YES_NO(FEAT_REMOTE_WRITE));
  211. };
  212. #define FEAT_JSON_BOOL(x) ((x) ? "true" : "false")
  213. // This intentionally does not use JSON-C so it works even if JSON-C is not present
  214. // This is used for anonymous statistics reporting, so it intentionally
  215. // does not include the configure options, which would be very easy to use
  216. // for tracking custom builds (and complicate outputting valid JSON).
  217. void print_build_info_json(void) {
  218. printf("{\n");
  219. printf(" \"features\": {\n");
  220. printf(" \"dbengine\": %s,\n", FEAT_JSON_BOOL(FEAT_DBENGINE));
  221. printf(" \"native-https\": %s,\n", FEAT_JSON_BOOL(FEAT_NATIVE_HTTPS));
  222. printf(" \"cloud\": %s,\n", FEAT_JSON_BOOL(FEAT_CLOUD));
  223. #ifdef DISABLE_CLOUD
  224. printf(" \"cloud-disabled\": true,\n");
  225. #else
  226. printf(" \"cloud-disabled\": false,\n");
  227. #endif
  228. #if FEAT_CLOUD == 1
  229. printf(" \"cloud-implementation\": \"%s\",\n", ACLK_IMPL);
  230. #endif
  231. printf(" \"tls-host-verify\": %s\n", FEAT_JSON_BOOL(FEAT_TLS_HOST_VERIFY));
  232. printf(" },\n");
  233. printf(" \"libs\": {\n");
  234. printf(" \"jemalloc\": %s,\n", FEAT_JSON_BOOL(FEAT_JEMALLOC));
  235. printf(" \"jsonc\": %s,\n", FEAT_JSON_BOOL(FEAT_JSONC));
  236. printf(" \"libcap\": %s,\n", FEAT_JSON_BOOL(FEAT_LIBCAP));
  237. printf(" \"libcrypto\": %s,\n", FEAT_JSON_BOOL(FEAT_CRYPTO));
  238. printf(" \"libm\": %s,\n", FEAT_JSON_BOOL(FEAT_LIBM));
  239. #ifndef ACLK_NG
  240. #if defined(ENABLE_ACLK)
  241. printf(" \"lws\": %s,\n", FEAT_JSON_BOOL(FEAT_LWS));
  242. printf(" \"lws-version\": \"%d.%d.%d\",\n", LWS_LIBRARY_VERSION_MAJOR, LWS_LIBRARY_VERSION_MINOR, LWS_LIBRARY_VERSION_PATCH);
  243. printf(" \"lws-type\": \"%s\",\n", FEAT_LWS_MSG);
  244. #else
  245. printf(" \"lws\": %s,\n", FEAT_JSON_BOOL(FEAT_LWS));
  246. #endif
  247. printf(" \"mosquitto\": %s,\n", FEAT_JSON_BOOL(FEAT_MOSQUITTO));
  248. #endif
  249. printf(" \"tcmalloc\": %s,\n", FEAT_JSON_BOOL(FEAT_TCMALLOC));
  250. printf(" \"zlib\": %s\n", FEAT_JSON_BOOL(FEAT_ZLIB));
  251. printf(" },\n");
  252. printf(" \"plugins\": {\n");
  253. printf(" \"apps\": %s,\n", FEAT_JSON_BOOL(FEAT_APPS_PLUGIN));
  254. printf(" \"cgroup-net\": %s,\n", FEAT_JSON_BOOL(FEAT_CGROUP_NET));
  255. printf(" \"cups\": %s,\n", FEAT_JSON_BOOL(FEAT_CUPS));
  256. printf(" \"ebpf\": %s,\n", FEAT_JSON_BOOL(FEAT_EBPF));
  257. printf(" \"ipmi\": %s,\n", FEAT_JSON_BOOL(FEAT_IPMI));
  258. printf(" \"nfacct\": %s,\n", FEAT_JSON_BOOL(FEAT_NFACCT));
  259. printf(" \"perf\": %s,\n", FEAT_JSON_BOOL(FEAT_PERF));
  260. printf(" \"slabinfo\": %s,\n", FEAT_JSON_BOOL(FEAT_SLABINFO));
  261. printf(" \"xen\": %s,\n", FEAT_JSON_BOOL(FEAT_XEN));
  262. printf(" \"xen-vbd-error\": %s\n", FEAT_JSON_BOOL(FEAT_XEN_VBD_ERROR));
  263. printf(" },\n");
  264. printf(" \"exporters\": {\n");
  265. printf(" \"kinesis\": %s,\n", FEAT_JSON_BOOL(FEAT_KINESIS));
  266. printf(" \"pubsub\": %s,\n", FEAT_JSON_BOOL(FEAT_PUBSUB));
  267. printf(" \"mongodb\": %s,\n", FEAT_JSON_BOOL(FEAT_MONGO));
  268. printf(" \"prom-remote-write\": %s\n", FEAT_JSON_BOOL(FEAT_REMOTE_WRITE));
  269. printf(" }\n");
  270. printf("}\n");
  271. };