buildinfo.c 11 KB

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