@cryptotaxi247 / netdata-1 / commits / 5f3a7224a

Added a way to get build configuration info from the agent. (#9913)

* Add a way to get build configuration info from the agent. This adds a new option to the `-W` switch called 'buildinfo'. When invoked with this argument, Netdata will print it's version, the configure options, and a list of optional features and whether they are enabled or not. This is intended to serve three purposes: * It allows developers to more quickly get an idea of how Netdata was built when triaging bug reports. * It provides an easier way to validate changes to the build system that affect optional features during the development cycle. * It provides an easier way to build CI workflows that validate that building under a given set of constraints results in a feature being enabled or not. The actual implementation is a bit large but overall exceedingly simple, consisting of a set of preprocessor directives to extract optional feature state information from config.h and then a series of printf() calls to actually report this info (which should end up optimized by smart compilers due to all the arguments being compile-time constants). * Added zlib to optional libraries. * Added remaining optional plugins to buildinfo output. * Changed formatting to be more human friendly. * Add remaining optional libraries. * Fix up formatting to be even more human friendly. * Fix typo in buildinfo output. * Remove unused variable. * Fixed spelling of config.h option name. * Update daemon/buildinfo.c Co-authored-by: Markos Fountoulakis <44345837+mfundul@users.noreply.github.com> * Fix option name mismatch for libcrypto. * Update daemon/buildinfo.c Co-authored-by: Markos Fountoulakis <44345837+mfundul@users.noreply.github.com> Co-authored-by: Markos Fountoulakis <44345837+mfundul@users.noreply.github.com>

Austin S. Hemmelgarn committed Sep 16, 2020 at 07:03 UTC 5f3a7224abe61ed0105d3d681b3d2b82aa61e2eb
6 files changed +246 -2
CMakeLists.txt
+2
@@ -783,6 +783,8 @@ set(MONGODB_BACKEND_FILES
783 )
784
785 set(DAEMON_FILES
786 + daemon/buildinfo.c
787 + daemon/buildinfo.h
788 daemon/common.c
789 daemon/common.h
790 daemon/daemon.c
Makefile.am
+2
@@ -618,6 +618,8 @@ MONGODB_BACKEND_FILES = \
618 $(NULL)
619
620 DAEMON_FILES = \
621 + daemon/buildinfo.c \
622 + daemon/buildinfo.h \
623 daemon/common.c \
624 daemon/common.h \
625 daemon/daemon.c \
configure.ac
+14 -2
@@ -43,7 +43,6 @@ AC_PROG_INSTALL
43 PKG_PROG_PKG_CONFIG
44 AC_USE_SYSTEM_EXTENSIONS
45
46 -
46 # -----------------------------------------------------------------------------
47 # configurable options
48
@@ -329,7 +328,6 @@ AC_CHECK_LIB(
328 )
329
330
332 -
331 # -----------------------------------------------------------------------------
332 # zlib
333
@@ -382,6 +380,9 @@ AC_CHECK_LIB(
380 [ssl_host_validation="no"]
381 )
382
383 +test -z "${SSL_LIBS}" || \
384 + AC_DEFINE([HAVE_CRYPTO], [1], [libcrypto availability])
385 +
386 if test "${ssl_host_validation}" = "no"; then
387 AC_DEFINE([HAVE_X509_VERIFY_PARAM_set1_host], [0], [ssl host validation])
388 AC_MSG_WARN([DISABLING SSL HOSTNAME VALIDATION BECAUSE IT IS NOT AVAILABLE ON THIS SYSTEM.])
@@ -705,6 +706,7 @@ AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"])
706
707 AC_MSG_CHECKING([if apps.plugin should be enabled])
708 if test "${build_target}" != "macos"; then
709 + AC_DEFINE([ENABLE_APPS_PLUGIN], [1], [apps.plugin])
710 enable_plugin_apps="yes"
711 else
712 enable_plugin_apps="no"
@@ -972,6 +974,7 @@ AC_CHECK_HEADER(
974
975 AC_MSG_CHECKING([if perf.plugin should be enabled])
976 if test "${build_target}" == "linux" -a "${have_perf_event}" = "yes"; then
977 + AC_DEFINE([ENABLE_PERF_PLUGIN], [1], [perf.plugin])
978 enable_plugin_perf="yes"
979 else
980 enable_plugin_perf="no"
@@ -1023,6 +1026,7 @@ AM_CONDITIONAL([ENABLE_PLUGIN_EBPF], [test "${enable_ebpf}" = "yes"])
1026
1027 AC_MSG_CHECKING([if slabinfo.plugin should be enabled])
1028 if test "${build_target}" == "linux"; then
1029 + AC_DEFINE([ENABLE_SLABINFO], [1], [slabinfo plugin])
1030 enable_plugin_slabinfo="yes"
1031 else
1032 enable_plugin_slabinfo="no"
@@ -1459,6 +1463,14 @@ TEST_LIBS="${CMOCKA_LIBS}"
1463 AC_SUBST([TEST_CFLAGS])
1464 AC_SUBST([TEST_LIBS])
1465
1466 +# -----------------------------------------------------------------------------
1467 +# save configure options for build info
1468 +AC_DEFINE_UNQUOTED(
1469 + [CONFIGURE_COMMAND],
1470 + ["$ac_configure_args"],
1471 + [options passed to configure script]
1472 +)
1473 +
1474 AC_CONFIG_FILES([
1475 Makefile
1476 netdata.spec
daemon/buildinfo.c new
+214
@@ -0,0 +1,214 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include <stdio.h>
4 +#include "./config.h"
5 +
6 +// Optional features
7 +
8 +#ifdef ENABLE_ACLK
9 +#define FEAT_CLOUD "YES"
10 +#else
11 +#define FEAT_CLOUD "NO"
12 +#endif
13 +
14 +#ifdef ENABLE_DBENGINE
15 +#define FEAT_DBENGINE "YES"
16 +#else
17 +#define FEAT_DBENGINE "NO"
18 +#endif
19 +
20 +#if defined(HAVE_X509_VERIFY_PARAM_set1_host) && HAVE_X509_VERIFY_PARAM_set1_host == 1
21 +#define FEAT_TLS_HOST_VERIFY "YES"
22 +#else
23 +#define FEAT_TLS_HOST_VERIFY "NO"
24 +#endif
25 +
26 +#ifdef ENABLE_HTTPS
27 +#define FEAT_NATIVE_HTTPS "YES"
28 +#else
29 +#define FEAT_NATIVE_HTTPS "NO"
30 +#endif
31 +
32 +// Optional libraries
33 +
34 +#ifdef ENABLE_JSONC
35 +#define FEAT_JSONC "YES"
36 +#else
37 +#define FEAT_JSONC "NO"
38 +#endif
39 +
40 +#ifdef ENABLE_JEMALLOC
41 +#define FEAT_JEMALLOC "YES"
42 +#else
43 +#define FEAT_JEMALLOC "NO"
44 +#endif
45 +
46 +#ifdef ENABLE_TCMALLOC
47 +#define FEAT_TCMALLOC "YES"
48 +#else
49 +#define FEAT_TCMALLOC "NO"
50 +#endif
51 +
52 +#ifdef HAVE_CAPABILITY
53 +#define FEAT_LIBCAP "YES"
54 +#else
55 +#define FEAT_LIBCAP "NO"
56 +#endif
57 +
58 +#ifdef ACLK_NO_LIBMOSQ
59 +#define FEAT_MOSQUITTO "NO"
60 +#else
61 +#define FEAT_MOSQUITTO "YES"
62 +#endif
63 +
64 +#ifdef ACLK_NO_LWS
65 +#define FEAT_LWS "NO"
66 +#else
67 +#define FEAT_LWS "YES"
68 +#endif
69 +
70 +#ifdef NETDATA_WITH_ZLIB
71 +#define FEAT_ZLIB "YES"
72 +#else
73 +#define FEAT_ZLIB "NO"
74 +#endif
75 +
76 +#ifdef STORAGE_WITH_MATH
77 +#define FEAT_LIBM "YES"
78 +#else
79 +#define FEAT_LIBM "NO"
80 +#endif
81 +
82 +#ifdef HAVE_CRYPTO
83 +#define FEAT_CRYPTO "YES"
84 +#else
85 +#define FEAT_CRYPTO "NO"
86 +#endif
87 +
88 +// Optional plugins
89 +
90 +#ifdef ENABLE_APPS_PLUGIN
91 +#define FEAT_APPS_PLUGIN "YES"
92 +#else
93 +#define FEAT_APPS_PLUGIN "NO"
94 +#endif
95 +
96 +#ifdef HAVE_FREEIPMI
97 +#define FEAT_IPMI "YES"
98 +#else
99 +#define FEAT_IPMI "NO"
100 +#endif
101 +
102 +#ifdef HAVE_CUPS
103 +#define FEAT_CUPS "YES"
104 +#else
105 +#define FEAT_CUPS "NO"
106 +#endif
107 +
108 +#ifdef HAVE_LIBMNL
109 +#define FEAT_NFACCT "YES"
110 +#else
111 +#define FEAT_NFACCT "NO"
112 +#endif
113 +
114 +#ifdef HAVE_LIBXENSTAT
115 +#define FEAT_XEN "YES"
116 +#else
117 +#define FEAT_XEN "NO"
118 +#endif
119 +
120 +#ifdef HAVE_XENSTAT_VBD_ERROR
121 +#define FEAT_XEN_VBD_ERROR "YES"
122 +#else
123 +#define FEAT_XEN_VBD_ERROR "NO"
124 +#endif
125 +
126 +#ifdef HAVE_LIBBPF
127 +#define FEAT_EBPF "YES"
128 +#else
129 +#define FEAT_EBPF "NO"
130 +#endif
131 +
132 +#ifdef HAVE_SETNS
133 +#define FEAT_CGROUP_NET "YES"
134 +#else
135 +#define FEAT_CGROUP_NET "NO"
136 +#endif
137 +
138 +#ifdef ENABLE_PERF_PLUGIN
139 +#define FEAT_PERF "YES"
140 +#else
141 +#define FEAT_PERF "NO"
142 +#endif
143 +
144 +#ifdef ENABLE_SLABINFO
145 +#define FEAT_SLABINFO "YES"
146 +#else
147 +#define FEAT_SLABINFO "NO"
148 +#endif
149 +
150 +// Optional Exporters
151 +
152 +#ifdef HAVE_KINESIS
153 +#define FEAT_KINESIS "YES"
154 +#else
155 +#define FEAT_KINESIS "NO"
156 +#endif
157 +
158 +#ifdef ENABLE_EXPORTING_PUBSUB
159 +#define FEAT_PUBSUB "YES"
160 +#else
161 +#define FEAT_PUBSUB "NO"
162 +#endif
163 +
164 +#ifdef HAVE_MONGOC
165 +#define FEAT_MONGO "YES"
166 +#else
167 +#define FEAT_MONGO "NO"
168 +#endif
169 +
170 +#ifdef ENABLE_PROMETHEUS_REMOTE_WRITE
171 +#define FEAT_REMOTE_WRITE "YES"
172 +#else
173 +#define FEAT_REMOTE_WRITE "NO"
174 +#endif
175 +
176 +
177 +void print_build_info(void) {
178 + printf("Configure options: %s\n", CONFIGURE_COMMAND);
179 +
180 + printf("Features:\n");
181 + printf(" dbengine: %s\n", FEAT_DBENGINE);
182 + printf(" Native HTTPS: %s\n", FEAT_NATIVE_HTTPS);
183 + printf(" Netdata Cloud: %s\n", FEAT_CLOUD);
184 + printf(" TLS Host Verification: %s\n", FEAT_TLS_HOST_VERIFY);
185 +
186 + printf("Libraries:\n");
187 + printf(" jemalloc: %s\n", FEAT_JEMALLOC);
188 + printf(" JSON-C: %s\n", FEAT_JSONC);
189 + printf(" libcap: %s\n", FEAT_LIBCAP);
190 + printf(" libcrypto: %s\n", FEAT_CRYPTO);
191 + printf(" libm: %s\n", FEAT_LIBM);
192 + printf(" LWS: %s\n", FEAT_LWS);
193 + printf(" mosquitto: %s\n", FEAT_MOSQUITTO);
194 + printf(" tcalloc: %s\n", FEAT_TCMALLOC);
195 + printf(" zlib: %s\n", FEAT_ZLIB);
196 +
197 + printf("Plugins:\n");
198 + printf(" apps: %s\n", FEAT_APPS_PLUGIN);
199 + printf(" cgroup Network Tracking: %s\n", FEAT_CGROUP_NET);
200 + printf(" CUPS: %s\n", FEAT_CUPS);
201 + printf(" EBPF: %s\n", FEAT_EBPF);
202 + printf(" IPMI: %s\n", FEAT_IPMI);
203 + printf(" NFACCT: %s\n", FEAT_NFACCT);
204 + printf(" perf: %s\n", FEAT_PERF);
205 + printf(" slabinfo: %s\n", FEAT_SLABINFO);
206 + printf(" Xen: %s\n", FEAT_XEN);
207 + printf(" Xen VBD Error Tracking: %s\n", FEAT_XEN_VBD_ERROR);
208 +
209 + printf("Exporters:\n");
210 + printf(" AWS Kinesis: %s\n", FEAT_KINESIS);
211 + printf(" GCP PubSub: %s\n", FEAT_PUBSUB);
212 + printf(" MongoDB: %s\n", FEAT_MONGO);
213 + printf(" Prometheus Remote Write: %s\n", FEAT_REMOTE_WRITE);
214 +};
daemon/buildinfo.h new
+8
@@ -0,0 +1,8 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#ifndef NETDATA_BUILDINFO_H
4 +#define NETDATA_BUILDINFO_H 1
5 +
6 +extern void print_build_info(void);
7 +
8 +#endif // NETDATA_BUILDINFO_H
daemon/main.c
+6
@@ -1,6 +1,7 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #include "common.h"
4 +#include "buildinfo.h"
5
6 int netdata_zero_metrics_enabled;
7 int netdata_anonymous_statistics_enabled;
@@ -1255,6 +1256,11 @@ int main(int argc, char **argv) {
1256 /* will trigger a claiming attempt when the agent is initialized */
1257 claiming_pending_arguments = optarg + strlen(claim_string);
1258 }
1259 + else if(strcmp(optarg, "buildinfo") == 0) {
1260 + printf("Version: %s %s\n", program_name, program_version);
1261 + print_build_info();
1262 + return 0;
1263 + }
1264 else {
1265 fprintf(stderr, "Unknown -W parameter '%s'\n", optarg);
1266 return help(1);