diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2020-09-16 07:03:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 07:03:27 -0400 |
commit | 5f3a7224abe61ed0105d3d681b3d2b82aa61e2eb (patch) | |
tree | dc11b4306870c01e2824c173a69f5473585552c9 /daemon | |
parent | a1b997f7bcc5dc8de93473abc27d413035c2d47e (diff) |
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>
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/buildinfo.c | 214 | ||||
-rw-r--r-- | daemon/buildinfo.h | 8 | ||||
-rw-r--r-- | daemon/main.c | 6 |
3 files changed, 228 insertions, 0 deletions
diff --git a/daemon/buildinfo.c b/daemon/buildinfo.c new file mode 100644 index 0000000000..e015e396d3 --- /dev/null +++ b/daemon/buildinfo.c @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#include <stdio.h> +#include "./config.h" + +// Optional features + +#ifdef ENABLE_ACLK +#define FEAT_CLOUD "YES" +#else +#define FEAT_CLOUD "NO" +#endif + +#ifdef ENABLE_DBENGINE +#define FEAT_DBENGINE "YES" +#else +#define FEAT_DBENGINE "NO" +#endif + +#if defined(HAVE_X509_VERIFY_PARAM_set1_host) && HAVE_X509_VERIFY_PARAM_set1_host == 1 +#define FEAT_TLS_HOST_VERIFY "YES" +#else +#define FEAT_TLS_HOST_VERIFY "NO" +#endif + +#ifdef ENABLE_HTTPS +#define FEAT_NATIVE_HTTPS "YES" +#else +#define FEAT_NATIVE_HTTPS "NO" +#endif + +// Optional libraries + +#ifdef ENABLE_JSONC +#define FEAT_JSONC "YES" +#else +#define FEAT_JSONC "NO" +#endif + +#ifdef ENABLE_JEMALLOC +#define FEAT_JEMALLOC "YES" +#else +#define FEAT_JEMALLOC "NO" +#endif + +#ifdef ENABLE_TCMALLOC +#define FEAT_TCMALLOC "YES" +#else +#define FEAT_TCMALLOC "NO" +#endif + +#ifdef HAVE_CAPABILITY +#define FEAT_LIBCAP "YES" +#else +#define FEAT_LIBCAP "NO" +#endif + +#ifdef ACLK_NO_LIBMOSQ +#define FEAT_MOSQUITTO "NO" +#else +#define FEAT_MOSQUITTO "YES" +#endif + +#ifdef ACLK_NO_LWS +#define FEAT_LWS "NO" +#else +#define FEAT_LWS "YES" +#endif + +#ifdef NETDATA_WITH_ZLIB +#define FEAT_ZLIB "YES" +#else +#define FEAT_ZLIB "NO" +#endif + +#ifdef STORAGE_WITH_MATH +#define FEAT_LIBM "YES" +#else +#define FEAT_LIBM "NO" +#endif + +#ifdef HAVE_CRYPTO +#define FEAT_CRYPTO "YES" +#else +#define FEAT_CRYPTO "NO" +#endif + +// Optional plugins + +#ifdef ENABLE_APPS_PLUGIN +#define FEAT_APPS_PLUGIN "YES" +#else +#define FEAT_APPS_PLUGIN "NO" +#endif + +#ifdef HAVE_FREEIPMI +#define FEAT_IPMI "YES" +#else +#define FEAT_IPMI "NO" +#endif + +#ifdef HAVE_CUPS +#define FEAT_CUPS "YES" +#else +#define FEAT_CUPS "NO" +#endif + +#ifdef HAVE_LIBMNL +#define FEAT_NFACCT "YES" +#else +#define FEAT_NFACCT "NO" +#endif + +#ifdef HAVE_LIBXENSTAT +#define FEAT_XEN "YES" +#else +#define FEAT_XEN "NO" +#endif + +#ifdef HAVE_XENSTAT_VBD_ERROR +#define FEAT_XEN_VBD_ERROR "YES" +#else +#define FEAT_XEN_VBD_ERROR "NO" +#endif + +#ifdef HAVE_LIBBPF +#define FEAT_EBPF "YES" +#else +#define FEAT_EBPF "NO" +#endif + +#ifdef HAVE_SETNS +#define FEAT_CGROUP_NET "YES" +#else +#define FEAT_CGROUP_NET "NO" +#endif + +#ifdef ENABLE_PERF_PLUGIN +#define FEAT_PERF "YES" +#else +#define FEAT_PERF "NO" +#endif + +#ifdef ENABLE_SLABINFO +#define FEAT_SLABINFO "YES" +#else +#define FEAT_SLABINFO "NO" +#endif + +// Optional Exporters + +#ifdef HAVE_KINESIS +#define FEAT_KINESIS "YES" +#else +#define FEAT_KINESIS "NO" +#endif + +#ifdef ENABLE_EXPORTING_PUBSUB +#define FEAT_PUBSUB "YES" +#else +#define FEAT_PUBSUB "NO" +#endif + +#ifdef HAVE_MONGOC +#define FEAT_MONGO "YES" +#else +#define FEAT_MONGO "NO" +#endif + +#ifdef ENABLE_PROMETHEUS_REMOTE_WRITE +#define FEAT_REMOTE_WRITE "YES" +#else +#define FEAT_REMOTE_WRITE "NO" +#endif + + +void print_build_info(void) { + printf("Configure options: %s\n", CONFIGURE_COMMAND); + + printf("Features:\n"); + printf(" dbengine: %s\n", FEAT_DBENGINE); + printf(" Native HTTPS: %s\n", FEAT_NATIVE_HTTPS); + printf(" Netdata Cloud: %s\n", FEAT_CLOUD); + printf(" TLS Host Verification: %s\n", FEAT_TLS_HOST_VERIFY); + + printf("Libraries:\n"); + printf(" jemalloc: %s\n", FEAT_JEMALLOC); + printf(" JSON-C: %s\n", FEAT_JSONC); + printf(" libcap: %s\n", FEAT_LIBCAP); + printf(" libcrypto: %s\n", FEAT_CRYPTO); + printf(" libm: %s\n", FEAT_LIBM); + printf(" LWS: %s\n", FEAT_LWS); + printf(" mosquitto: %s\n", FEAT_MOSQUITTO); + printf(" tcalloc: %s\n", FEAT_TCMALLOC); + printf(" zlib: %s\n", FEAT_ZLIB); + + printf("Plugins:\n"); + printf(" apps: %s\n", FEAT_APPS_PLUGIN); + printf(" cgroup Network Tracking: %s\n", FEAT_CGROUP_NET); + printf(" CUPS: %s\n", FEAT_CUPS); + printf(" EBPF: %s\n", FEAT_EBPF); + printf(" IPMI: %s\n", FEAT_IPMI); + printf(" NFACCT: %s\n", FEAT_NFACCT); + printf(" perf: %s\n", FEAT_PERF); + printf(" slabinfo: %s\n", FEAT_SLABINFO); + printf(" Xen: %s\n", FEAT_XEN); + printf(" Xen VBD Error Tracking: %s\n", FEAT_XEN_VBD_ERROR); + + printf("Exporters:\n"); + printf(" AWS Kinesis: %s\n", FEAT_KINESIS); + printf(" GCP PubSub: %s\n", FEAT_PUBSUB); + printf(" MongoDB: %s\n", FEAT_MONGO); + printf(" Prometheus Remote Write: %s\n", FEAT_REMOTE_WRITE); +}; diff --git a/daemon/buildinfo.h b/daemon/buildinfo.h new file mode 100644 index 0000000000..76912ea672 --- /dev/null +++ b/daemon/buildinfo.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef NETDATA_BUILDINFO_H +#define NETDATA_BUILDINFO_H 1 + +extern void print_build_info(void); + +#endif // NETDATA_BUILDINFO_H diff --git a/daemon/main.c b/daemon/main.c index d8b32d6269..ee45e6b3a4 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "common.h" +#include "buildinfo.h" int netdata_zero_metrics_enabled; int netdata_anonymous_statistics_enabled; @@ -1255,6 +1256,11 @@ int main(int argc, char **argv) { /* will trigger a claiming attempt when the agent is initialized */ claiming_pending_arguments = optarg + strlen(claim_string); } + else if(strcmp(optarg, "buildinfo") == 0) { + printf("Version: %s %s\n", program_name, program_version); + print_build_info(); + return 0; + } else { fprintf(stderr, "Unknown -W parameter '%s'\n", optarg); return help(1); |