123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- // SPDX-License-Identifier: GPL-3.0-or-later
- #include <stdio.h>
- #include "./config.h"
- #include "common.h"
- #include "buildinfo.h"
- // Optional features
- #ifdef ENABLE_ACLK
- #define FEAT_CLOUD 1
- #define FEAT_CLOUD_MSG ""
- #else
- #ifdef DISABLE_CLOUD
- #define FEAT_CLOUD 0
- #define FEAT_CLOUD_MSG "(by user request)"
- #else
- #define FEAT_CLOUD 0
- #define FEAT_CLOUD_MSG ""
- #endif
- #endif
- #ifdef ENABLE_NEW_CLOUD_PROTOCOL
- #define NEW_CLOUD_PROTO 1
- #else
- #define NEW_CLOUD_PROTO 0
- #endif
- #ifdef ENABLE_DBENGINE
- #define FEAT_DBENGINE 1
- #else
- #define FEAT_DBENGINE 0
- #endif
- #if defined(HAVE_X509_VERIFY_PARAM_set1_host) && HAVE_X509_VERIFY_PARAM_set1_host == 1
- #define FEAT_TLS_HOST_VERIFY 1
- #else
- #define FEAT_TLS_HOST_VERIFY 0
- #endif
- #ifdef ENABLE_HTTPS
- #define FEAT_NATIVE_HTTPS 1
- #else
- #define FEAT_NATIVE_HTTPS 0
- #endif
- #ifdef ENABLE_ML
- #define FEAT_ML 1
- #else
- #define FEAT_ML 0
- #endif
- #ifdef ENABLE_COMPRESSION
- #define FEAT_STREAM_COMPRESSION 1
- #else
- #define FEAT_STREAM_COMPRESSION 0
- #endif //ENABLE_COMPRESSION
- // Optional libraries
- #ifdef HAVE_PROTOBUF
- #define FEAT_PROTOBUF 1
- #ifdef BUNDLED_PROTOBUF
- #define FEAT_PROTOBUF_BUNDLED " (bundled)"
- #else
- #define FEAT_PROTOBUF_BUNDLED " (system)"
- #endif
- #else
- #define FEAT_PROTOBUF 0
- #define FEAT_PROTOBUF_BUNDLED ""
- #endif
- #ifdef ENABLE_JSONC
- #define FEAT_JSONC 1
- #else
- #define FEAT_JSONC 0
- #endif
- #ifdef ENABLE_JEMALLOC
- #define FEAT_JEMALLOC 1
- #else
- #define FEAT_JEMALLOC 0
- #endif
- #ifdef ENABLE_TCMALLOC
- #define FEAT_TCMALLOC 1
- #else
- #define FEAT_TCMALLOC 0
- #endif
- #ifdef HAVE_CAPABILITY
- #define FEAT_LIBCAP 1
- #else
- #define FEAT_LIBCAP 0
- #endif
- #ifdef NETDATA_WITH_ZLIB
- #define FEAT_ZLIB 1
- #else
- #define FEAT_ZLIB 0
- #endif
- #ifdef STORAGE_WITH_MATH
- #define FEAT_LIBM 1
- #else
- #define FEAT_LIBM 0
- #endif
- #ifdef HAVE_CRYPTO
- #define FEAT_CRYPTO 1
- #else
- #define FEAT_CRYPTO 0
- #endif
- // Optional plugins
- #ifdef ENABLE_APPS_PLUGIN
- #define FEAT_APPS_PLUGIN 1
- #else
- #define FEAT_APPS_PLUGIN 0
- #endif
- #ifdef HAVE_FREEIPMI
- #define FEAT_IPMI 1
- #else
- #define FEAT_IPMI 0
- #endif
- #ifdef HAVE_CUPS
- #define FEAT_CUPS 1
- #else
- #define FEAT_CUPS 0
- #endif
- #ifdef HAVE_NFACCT
- #define FEAT_NFACCT 1
- #else
- #define FEAT_NFACCT 0
- #endif
- #ifdef HAVE_LIBXENSTAT
- #define FEAT_XEN 1
- #else
- #define FEAT_XEN 0
- #endif
- #ifdef HAVE_XENSTAT_VBD_ERROR
- #define FEAT_XEN_VBD_ERROR 1
- #else
- #define FEAT_XEN_VBD_ERROR 0
- #endif
- #ifdef HAVE_LIBBPF
- #define FEAT_EBPF 1
- #else
- #define FEAT_EBPF 0
- #endif
- #ifdef HAVE_SETNS
- #define FEAT_CGROUP_NET 1
- #else
- #define FEAT_CGROUP_NET 0
- #endif
- #ifdef ENABLE_PERF_PLUGIN
- #define FEAT_PERF 1
- #else
- #define FEAT_PERF 0
- #endif
- #ifdef ENABLE_SLABINFO
- #define FEAT_SLABINFO 1
- #else
- #define FEAT_SLABINFO 0
- #endif
- // Optional Exporters
- #ifdef HAVE_KINESIS
- #define FEAT_KINESIS 1
- #else
- #define FEAT_KINESIS 0
- #endif
- #ifdef ENABLE_EXPORTING_PUBSUB
- #define FEAT_PUBSUB 1
- #else
- #define FEAT_PUBSUB 0
- #endif
- #ifdef HAVE_MONGOC
- #define FEAT_MONGO 1
- #else
- #define FEAT_MONGO 0
- #endif
- #ifdef ENABLE_PROMETHEUS_REMOTE_WRITE
- #define FEAT_REMOTE_WRITE 1
- #else
- #define FEAT_REMOTE_WRITE 0
- #endif
- #define FEAT_YES_NO(x) ((x) ? "YES" : "NO")
- char *get_value_from_key(char *buffer, char *key) {
- char *s = NULL, *t = NULL;
- s = t = buffer + strlen(key) + 2;
- if (s) {
- while (*s == '\'')
- s++;
- while (*++t != '\0');
- while (--t > s && *t == '\'')
- *t = '\0';
- }
- return s;
- }
- void get_install_type(char **install_type, char **prebuilt_arch, char **prebuilt_dist) {
- char *install_type_filename;
- int install_type_filename_len = (strlen(netdata_configured_user_config_dir) + strlen(".install-type") + 3);
- install_type_filename = mallocz(sizeof(char) * install_type_filename_len);
- snprintfz(install_type_filename, install_type_filename_len - 1, "%s/%s", netdata_configured_user_config_dir, ".install-type");
- FILE *fp = fopen(install_type_filename, "r");
- if (fp) {
- char *s, buf[256 + 1];
- size_t len = 0;
- while ((s = fgets_trim_len(buf, 256, fp, &len))) {
- if (!strncmp(buf, "INSTALL_TYPE='", 14))
- *install_type = strdupz((char *)get_value_from_key(buf, "INSTALL_TYPE"));
- else if (!strncmp(buf, "PREBUILT_ARCH='", 15))
- *prebuilt_arch = strdupz((char *)get_value_from_key(buf, "PREBUILT_ARCH"));
- else if (!strncmp(buf, "PREBUILT_DISTRO='", 17))
- *prebuilt_dist = strdupz((char *)get_value_from_key(buf, "PREBUILT_DISTRO"));
- }
- fclose(fp);
- }
- freez(install_type_filename);
- }
- void print_build_info(void) {
- char *install_type = NULL;
- char *prebuilt_arch = NULL;
- char *prebuilt_distro = NULL;
- get_install_type(&install_type, &prebuilt_arch, &prebuilt_distro);
- printf("Configure options: %s\n", CONFIGURE_COMMAND);
- if (install_type == NULL) {
- printf("Install type: unknown\n");
- } else {
- printf("Install type: %s\n", install_type);
- }
- if (prebuilt_arch != NULL) {
- printf(" Binary architecture: %s\n", prebuilt_arch);
- }
- if (prebuilt_distro != NULL) {
- printf(" Packaging distro: %s\n", prebuilt_distro);
- }
- freez(install_type);
- freez(prebuilt_arch);
- freez(prebuilt_distro);
- printf("Features:\n");
- printf(" dbengine: %s\n", FEAT_YES_NO(FEAT_DBENGINE));
- printf(" Native HTTPS: %s\n", FEAT_YES_NO(FEAT_NATIVE_HTTPS));
- printf(" Netdata Cloud: %s %s\n", FEAT_YES_NO(FEAT_CLOUD), FEAT_CLOUD_MSG);
- printf(" ACLK Next Generation: %s\n", FEAT_YES_NO(FEAT_CLOUD));
- printf(" ACLK-NG New Cloud Protocol: %s\n", FEAT_YES_NO(NEW_CLOUD_PROTO));
- printf(" ACLK Legacy: %s\n", FEAT_YES_NO(0));
- printf(" TLS Host Verification: %s\n", FEAT_YES_NO(FEAT_TLS_HOST_VERIFY));
- printf(" Machine Learning: %s\n", FEAT_YES_NO(FEAT_ML));
- printf(" Stream Compression: %s\n", FEAT_YES_NO(FEAT_STREAM_COMPRESSION));
- printf("Libraries:\n");
- printf(" protobuf: %s%s\n", FEAT_YES_NO(FEAT_PROTOBUF), FEAT_PROTOBUF_BUNDLED);
- printf(" jemalloc: %s\n", FEAT_YES_NO(FEAT_JEMALLOC));
- printf(" JSON-C: %s\n", FEAT_YES_NO(FEAT_JSONC));
- printf(" libcap: %s\n", FEAT_YES_NO(FEAT_LIBCAP));
- printf(" libcrypto: %s\n", FEAT_YES_NO(FEAT_CRYPTO));
- printf(" libm: %s\n", FEAT_YES_NO(FEAT_LIBM));
- printf(" tcalloc: %s\n", FEAT_YES_NO(FEAT_TCMALLOC));
- printf(" zlib: %s\n", FEAT_YES_NO(FEAT_ZLIB));
- printf("Plugins:\n");
- printf(" apps: %s\n", FEAT_YES_NO(FEAT_APPS_PLUGIN));
- printf(" cgroup Network Tracking: %s\n", FEAT_YES_NO(FEAT_CGROUP_NET));
- printf(" CUPS: %s\n", FEAT_YES_NO(FEAT_CUPS));
- printf(" EBPF: %s\n", FEAT_YES_NO(FEAT_EBPF));
- printf(" IPMI: %s\n", FEAT_YES_NO(FEAT_IPMI));
- printf(" NFACCT: %s\n", FEAT_YES_NO(FEAT_NFACCT));
- printf(" perf: %s\n", FEAT_YES_NO(FEAT_PERF));
- printf(" slabinfo: %s\n", FEAT_YES_NO(FEAT_SLABINFO));
- printf(" Xen: %s\n", FEAT_YES_NO(FEAT_XEN));
- printf(" Xen VBD Error Tracking: %s\n", FEAT_YES_NO(FEAT_XEN_VBD_ERROR));
- printf("Exporters:\n");
- printf(" AWS Kinesis: %s\n", FEAT_YES_NO(FEAT_KINESIS));
- printf(" GCP PubSub: %s\n", FEAT_YES_NO(FEAT_PUBSUB));
- printf(" MongoDB: %s\n", FEAT_YES_NO(FEAT_MONGO));
- printf(" Prometheus Remote Write: %s\n", FEAT_YES_NO(FEAT_REMOTE_WRITE));
- };
- #define FEAT_JSON_BOOL(x) ((x) ? "true" : "false")
- // This intentionally does not use JSON-C so it works even if JSON-C is not present
- // This is used for anonymous statistics reporting, so it intentionally
- // does not include the configure options, which would be very easy to use
- // for tracking custom builds (and complicate outputting valid JSON).
- void print_build_info_json(void) {
- printf("{\n");
- printf(" \"features\": {\n");
- printf(" \"dbengine\": %s,\n", FEAT_JSON_BOOL(FEAT_DBENGINE));
- printf(" \"native-https\": %s,\n", FEAT_JSON_BOOL(FEAT_NATIVE_HTTPS));
- printf(" \"cloud\": %s,\n", FEAT_JSON_BOOL(FEAT_CLOUD));
- #ifdef DISABLE_CLOUD
- printf(" \"cloud-disabled\": true,\n");
- #else
- printf(" \"cloud-disabled\": false,\n");
- #endif
- printf(" \"aclk-ng\": %s,\n", FEAT_JSON_BOOL(FEAT_CLOUD));
- printf(" \"aclk-ng-new-cloud-proto\": %s,\n", FEAT_JSON_BOOL(NEW_CLOUD_PROTO));
- printf(" \"aclk-legacy\": %s,\n", FEAT_JSON_BOOL(0));
- printf(" \"tls-host-verify\": %s,\n", FEAT_JSON_BOOL(FEAT_TLS_HOST_VERIFY));
- printf(" \"machine-learning\": %s\n", FEAT_JSON_BOOL(FEAT_ML));
- printf(" \"stream-compression\": %s\n", FEAT_JSON_BOOL(FEAT_STREAM_COMPRESSION));
- printf(" },\n");
- printf(" \"libs\": {\n");
- printf(" \"protobuf\": %s,\n", FEAT_JSON_BOOL(FEAT_PROTOBUF));
- printf(" \"protobuf-source\": \"%s\",\n", FEAT_PROTOBUF_BUNDLED);
- printf(" \"jemalloc\": %s,\n", FEAT_JSON_BOOL(FEAT_JEMALLOC));
- printf(" \"jsonc\": %s,\n", FEAT_JSON_BOOL(FEAT_JSONC));
- printf(" \"libcap\": %s,\n", FEAT_JSON_BOOL(FEAT_LIBCAP));
- printf(" \"libcrypto\": %s,\n", FEAT_JSON_BOOL(FEAT_CRYPTO));
- printf(" \"libm\": %s,\n", FEAT_JSON_BOOL(FEAT_LIBM));
- printf(" \"tcmalloc\": %s,\n", FEAT_JSON_BOOL(FEAT_TCMALLOC));
- printf(" \"zlib\": %s\n", FEAT_JSON_BOOL(FEAT_ZLIB));
- printf(" },\n");
- printf(" \"plugins\": {\n");
- printf(" \"apps\": %s,\n", FEAT_JSON_BOOL(FEAT_APPS_PLUGIN));
- printf(" \"cgroup-net\": %s,\n", FEAT_JSON_BOOL(FEAT_CGROUP_NET));
- printf(" \"cups\": %s,\n", FEAT_JSON_BOOL(FEAT_CUPS));
- printf(" \"ebpf\": %s,\n", FEAT_JSON_BOOL(FEAT_EBPF));
- printf(" \"ipmi\": %s,\n", FEAT_JSON_BOOL(FEAT_IPMI));
- printf(" \"nfacct\": %s,\n", FEAT_JSON_BOOL(FEAT_NFACCT));
- printf(" \"perf\": %s,\n", FEAT_JSON_BOOL(FEAT_PERF));
- printf(" \"slabinfo\": %s,\n", FEAT_JSON_BOOL(FEAT_SLABINFO));
- printf(" \"xen\": %s,\n", FEAT_JSON_BOOL(FEAT_XEN));
- printf(" \"xen-vbd-error\": %s\n", FEAT_JSON_BOOL(FEAT_XEN_VBD_ERROR));
- printf(" },\n");
- printf(" \"exporters\": {\n");
- printf(" \"kinesis\": %s,\n", FEAT_JSON_BOOL(FEAT_KINESIS));
- printf(" \"pubsub\": %s,\n", FEAT_JSON_BOOL(FEAT_PUBSUB));
- printf(" \"mongodb\": %s,\n", FEAT_JSON_BOOL(FEAT_MONGO));
- printf(" \"prom-remote-write\": %s\n", FEAT_JSON_BOOL(FEAT_REMOTE_WRITE));
- printf(" }\n");
- printf("}\n");
- };
- #define add_to_bi(buffer, str) \
- { if(first) { \
- buffer_strcat (b, str); \
- first = 0; \
- } else \
- buffer_strcat (b, "|" str); }
- void analytics_build_info(BUFFER *b) {
- int first = 1;
- #ifdef ENABLE_DBENGINE
- add_to_bi(b, "dbengine");
- #endif
- #ifdef ENABLE_HTTPS
- add_to_bi(b, "Native HTTPS");
- #endif
- #ifdef ENABLE_ACLK
- add_to_bi(b, "Netdata Cloud|ACLK Next Generation");
- #endif
- #ifdef ENABLE_NEW_CLOUD_PROTOCOL
- add_to_bi(b, "New Cloud Protocol Support");
- #endif
- #if (FEAT_TLS_HOST_VERIFY!=0)
- add_to_bi(b, "TLS Host Verification");
- #endif
- #ifdef ENABLE_ML
- add_to_bi(b, "Machine Learning");
- #endif
- #ifdef ENABLE_COMPRESSION
- add_to_bi(b, "Stream Compression");
- #endif
- #ifdef HAVE_PROTOBUF
- add_to_bi(b, "protobuf");
- #endif
- #ifdef ENABLE_JEMALLOC
- add_to_bi(b, "jemalloc");
- #endif
- #ifdef ENABLE_JSONC
- add_to_bi(b, "JSON-C");
- #endif
- #ifdef HAVE_CAPABILITY
- add_to_bi(b, "libcap");
- #endif
- #ifdef HAVE_CRYPTO
- add_to_bi(b, "libcrypto");
- #endif
- #ifdef STORAGE_WITH_MATH
- add_to_bi(b, "libm");
- #endif
- #ifdef ENABLE_TCMALLOC
- add_to_bi(b, "tcalloc");
- #endif
- #ifdef NETDATA_WITH_ZLIB
- add_to_bi(b, "zlib");
- #endif
- #ifdef ENABLE_APPS_PLUGIN
- add_to_bi(b, "apps");
- #endif
- #ifdef HAVE_SETNS
- add_to_bi(b, "cgroup Network Tracking");
- #endif
- #ifdef HAVE_CUPS
- add_to_bi(b, "CUPS");
- #endif
- #ifdef HAVE_LIBBPF
- add_to_bi(b, "EBPF");
- #endif
- #ifdef HAVE_FREEIPMI
- add_to_bi(b, "IPMI");
- #endif
- #ifdef HAVE_NFACCT
- add_to_bi(b, "NFACCT");
- #endif
- #ifdef ENABLE_PERF_PLUGIN
- add_to_bi(b, "perf");
- #endif
- #ifdef ENABLE_SLABINFO
- add_to_bi(b, "slabinfo");
- #endif
- #ifdef HAVE_LIBXENSTAT
- add_to_bi(b, "Xen");
- #endif
- #ifdef HAVE_XENSTAT_VBD_ERROR
- add_to_bi(b, "Xen VBD Error Tracking");
- #endif
- #ifdef HAVE_KINESIS
- add_to_bi(b, "AWS Kinesis");
- #endif
- #ifdef ENABLE_EXPORTING_PUBSUB
- add_to_bi(b, "GCP PubSub");
- #endif
- #ifdef HAVE_MONGOC
- add_to_bi(b, "MongoDB");
- #endif
- #ifdef ENABLE_PROMETHEUS_REMOTE_WRITE
- add_to_bi(b, "Prometheus Remote Write");
- #endif
- }
|