master
c 1,724 lines 58.5 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #define RRDHOST_SYSTEM_INFO_INTERNALS
4 #include <stdio.h>
5 #include "./config.h"
6 #include "common.h"
7 #include "buildinfo.h"
8
9 typedef enum __attribute__((packed)) {
10 BIB_PACKAGING_NETDATA_VERSION,
11 BIB_PACKAGING_INSTALL_TYPE,
12 BIB_PACKAGING_ARCHITECTURE,
13 BIB_PACKAGING_DISTRO,
14 BIB_PACKAGING_CONFIGURE_OPTIONS,
15 BIB_DIR_USER_CONFIG,
16 BIB_DIR_STOCK_CONFIG,
17 BIB_DIR_STOCK_DATA,
18 BIB_DIR_CACHE,
19 BIB_DIR_LIB,
20 BIB_DIR_PLUGINS,
21 BIB_DIR_WEB,
22 BIB_DIR_LOG,
23 BIB_DIR_LOCK,
24 BIB_DIR_HOME,
25 BIB_OS_KERNEL_NAME,
26 BIB_OS_KERNEL_VERSION,
27 BIB_OS_NAME,
28 BIB_OS_ID,
29 BIB_OS_ID_LIKE,
30 BIB_OS_VERSION,
31 BIB_OS_VERSION_ID,
32 BIB_OS_DETECTION,
33 BIB_HW_CPU_CORES,
34 BIB_HW_CPU_FREQUENCY,
35 BIB_HW_RAM_SIZE,
36 BIB_HW_DISK_SPACE,
37 BIB_HW_ARCHITECTURE,
38 BIB_HW_VIRTUALIZATION,
39 BIB_HW_VIRTUALIZATION_DETECTION,
40 BIB_CONTAINER_NAME,
41 BIB_CONTAINER_DETECTION,
42 BIB_CONTAINER_ORCHESTRATOR,
43 BIB_CONTAINER_OS_NAME,
44 BIB_CONTAINER_OS_ID,
45 BIB_CONTAINER_OS_ID_LIKE,
46 BIB_CONTAINER_OS_VERSION,
47 BIB_CONTAINER_OS_VERSION_ID,
48 BIB_CONTAINER_OS_DETECTION,
49 BIB_FEATURE_BUILT_FOR,
50 BIB_FEATURE_CLOUD,
51 BIB_FEATURE_HEALTH,
52 BIB_FEATURE_STREAMING,
53 BIB_FEATURE_BACKFILLING,
54 BIB_FEATURE_REPLICATION,
55 BIB_FEATURE_STREAMING_COMPRESSION,
56 BIB_FEATURE_CONTEXTS,
57 BIB_FEATURE_TIERING,
58 BIB_FEATURE_ML,
59 BIB_FEATURE_ALLOCATOR,
60 BIB_DB_SQLITE,
61 BIB_DB_DBENGINE,
62 BIB_DB_ALLOC,
63 BIB_DB_RAM,
64 BIB_DB_NONE,
65 BIB_CONNECTIVITY_ACLK,
66 BIB_CONNECTIVITY_HTTPD_STATIC,
67 BIB_CONNECTIVITY_WEBRTC,
68 BIB_CONNECTIVITY_NATIVE_HTTPS,
69 BIB_CONNECTIVITY_TLS_HOST_VERIFY,
70 BIB_LIB_LZ4,
71 BIB_LIB_ZSTD,
72 BIB_LIB_ZLIB,
73 BIB_LIB_BROTLI,
74 BIB_LIB_PROTOBUF,
75 BIB_LIB_OPENSSL,
76 BIB_LIB_LIBDATACHANNEL,
77 BIB_LIB_JSONC,
78 BIB_LIB_LIBCAP,
79 BIB_LIB_LIBCRYPTO,
80 BIB_LIB_LIBYAML,
81 BIB_LIB_LIBMNL,
82 BIB_LIB_STACKTRACE,
83 BIB_PLUGIN_APPS,
84 BIB_PLUGIN_LINUX_CGROUPS,
85 BIB_PLUGIN_LINUX_CGROUP_NETWORK,
86 BIB_PLUGIN_LINUX_PROC,
87 BIB_PLUGIN_LINUX_TC,
88 BIB_PLUGIN_LINUX_DISKSPACE,
89 BIB_PLUGIN_FREEBSD,
90 BIB_PLUGIN_MACOS,
91 BIB_PLUGIN_WINDOWS,
92 BIB_PLUGIN_STATSD,
93 BIB_PLUGIN_TIMEX,
94 BIB_PLUGIN_IDLEJITTER,
95 BIB_PLUGIN_BASH,
96 BIB_PLUGIN_DEBUGFS,
97 BIB_PLUGIN_CUPS,
98 BIB_PLUGIN_EBPF,
99 BIB_PLUGIN_FREEIPMI,
100 BIB_PLUGIN_NETWORK_VIEWER,
101 BIB_PLUGIN_SYSTEMD_JOURNAL,
102 BIB_PLUGIN_WINDOWS_EVENTS,
103 BIB_PLUGIN_NFACCT,
104 BIB_PLUGIN_PERF,
105 BIB_PLUGIN_SLABINFO,
106 BIB_PLUGIN_XEN,
107 BIB_PLUGIN_XEN_VBD_ERROR,
108 BIB_EXPORT_AWS_KINESIS,
109 BIB_EXPORT_GCP_PUBSUB,
110 BIB_EXPORT_MONGOC,
111 BIB_EXPORT_PROMETHEUS_EXPORTER,
112 BIB_EXPORT_PROMETHEUS_REMOTE_WRITE,
113 BIB_EXPORT_GRAPHITE,
114 BIB_EXPORT_GRAPHITE_HTTP,
115 BIB_EXPORT_JSON,
116 BIB_EXPORT_JSON_HTTP,
117 BIB_EXPORT_OPENTSDB,
118 BIB_EXPORT_OPENTSDB_HTTP,
119 BIB_EXPORT_ALLMETRICS,
120 BIB_EXPORT_SHELL,
121 BIB_DEVEL_TRACE_ALLOCATIONS,
122 BIB_DEVELOPER_MODE,
123 BIB_RUNTIME_PROFILE,
124 BIB_RUNTIME_PARENT,
125 BIB_RUNTIME_CHILD,
126 BIB_RUNTIME_MEM_TOTAL,
127 BIB_RUNTIME_MEM_AVAIL,
128
129 // leave this last
130 BIB_TERMINATOR,
131 } BUILD_INFO_SLOT;
132
133 typedef enum __attribute__((packed)) {
134 BIC_PACKAGING,
135 BIC_DIRECTORIES,
136 BIC_OPERATING_SYSTEM,
137 BIC_HARDWARE,
138 BIC_CONTAINER,
139 BIC_FEATURE,
140 BIC_DATABASE,
141 BIC_CONNECTIVITY,
142 BIC_LIBS,
143 BIC_PLUGINS,
144 BIC_EXPORTERS,
145 BIC_DEBUG_DEVEL,
146 BIC_RUNTIME,
147 } BUILD_INFO_CATEGORY;
148
149 typedef enum __attribute__((packed)) {
150 BIT_BOOLEAN,
151 BIT_STRING,
152 } BUILD_INFO_TYPE;
153
154 static struct {
155 BUILD_INFO_CATEGORY category;
156 BUILD_INFO_TYPE type;
157 const char *analytics;
158 const char *print;
159 const char *json;
160 bool status;
161 const char *value;
162 bool value_allocated;
163 } BUILD_INFO[] = {
164 [BIB_PACKAGING_NETDATA_VERSION] = {
165 .category = BIC_PACKAGING,
166 .type = BIT_STRING,
167 .analytics = NULL,
168 .print = "Netdata Version",
169 .json = "version",
170 .value = "unknown",
171 },
172 [BIB_PACKAGING_INSTALL_TYPE] = {
173 .category = BIC_PACKAGING,
174 .type = BIT_STRING,
175 .analytics = NULL,
176 .print = "Installation Type",
177 .json = "type",
178 .value = "unknown",
179 },
180 [BIB_PACKAGING_ARCHITECTURE] = {
181 .category = BIC_PACKAGING,
182 .type = BIT_STRING,
183 .analytics = NULL,
184 .print = "Package Architecture",
185 .json = "arch",
186 .value = "unknown",
187 },
188 [BIB_PACKAGING_DISTRO] = {
189 .category = BIC_PACKAGING,
190 .type = BIT_STRING,
191 .analytics = NULL,
192 .print = "Package Distro",
193 .json = "distro",
194 .value = "unknown",
195 },
196 [BIB_PACKAGING_CONFIGURE_OPTIONS] = {
197 .category = BIC_PACKAGING,
198 .type = BIT_STRING,
199 .analytics = NULL,
200 .print = "Configure Options",
201 .json = "configure",
202 .value = "unknown",
203 },
204 [BIB_DIR_USER_CONFIG] = {
205 .category = BIC_DIRECTORIES,
206 .type = BIT_STRING,
207 .analytics = NULL,
208 .print = "User Configurations",
209 .json = "user_config",
210 .value = CONFIG_DIR,
211 },
212 [BIB_DIR_STOCK_CONFIG] = {
213 .category = BIC_DIRECTORIES,
214 .type = BIT_STRING,
215 .analytics = NULL,
216 .print = "Stock Configurations",
217 .json = "stock_config",
218 .value = LIBCONFIG_DIR,
219 },
220 [BIB_DIR_STOCK_DATA] = {
221 .category = BIC_DIRECTORIES,
222 .type = BIT_STRING,
223 .analytics = NULL,
224 .print = "Stock Data Files",
225 .json = "stock_data",
226 .value = STOCK_DATA_DIR,
227 },
228 [BIB_DIR_CACHE] = {
229 .category = BIC_DIRECTORIES,
230 .type = BIT_STRING,
231 .analytics = NULL,
232 .print = "Ephemeral Databases (metrics data, metadata)",
233 .json = "ephemeral_db",
234 .value = CACHE_DIR,
235 },
236 [BIB_DIR_LIB] = {
237 .category = BIC_DIRECTORIES,
238 .type = BIT_STRING,
239 .analytics = NULL,
240 .print = "Permanent Databases",
241 .json = "permanent_db",
242 .value = VARLIB_DIR,
243 },
244 [BIB_DIR_PLUGINS] = {
245 .category = BIC_DIRECTORIES,
246 .type = BIT_STRING,
247 .analytics = NULL,
248 .print = "Plugins",
249 .json = "plugins",
250 .value = PLUGINS_DIR,
251 },
252 [BIB_DIR_WEB] = {
253 .category = BIC_DIRECTORIES,
254 .type = BIT_STRING,
255 .analytics = NULL,
256 .print = "Static Web Files",
257 .json = "web",
258 .value = WEB_DIR,
259 },
260 [BIB_DIR_LOG] = {
261 .category = BIC_DIRECTORIES,
262 .type = BIT_STRING,
263 .analytics = NULL,
264 .print = "Log Files",
265 .json = "logs",
266 .value = LOG_DIR,
267 },
268 [BIB_DIR_LOCK] = {
269 .category = BIC_DIRECTORIES,
270 .type = BIT_STRING,
271 .analytics = NULL,
272 .print = "Lock Files",
273 .json = "locks",
274 .value = VARLIB_DIR "/lock",
275 },
276 [BIB_DIR_HOME] = {
277 .category = BIC_DIRECTORIES,
278 .type = BIT_STRING,
279 .analytics = NULL,
280 .print = "Home",
281 .json = "home",
282 .value = VARLIB_DIR,
283 },
284 [BIB_OS_KERNEL_NAME] = {
285 .category = BIC_OPERATING_SYSTEM,
286 .type = BIT_STRING,
287 .analytics = NULL,
288 .print = "Kernel",
289 .json = "kernel",
290 .value = "unknown",
291 },
292 [BIB_OS_KERNEL_VERSION] = {
293 .category = BIC_OPERATING_SYSTEM,
294 .type = BIT_STRING,
295 .analytics = NULL,
296 .print = "Kernel Version",
297 .json = "kernel_version",
298 .value = "unknown",
299 },
300 [BIB_OS_NAME] = {
301 .category = BIC_OPERATING_SYSTEM,
302 .type = BIT_STRING,
303 .analytics = NULL,
304 .print = "Operating System",
305 .json = "os",
306 .value = "unknown",
307 },
308 [BIB_OS_ID] = {
309 .category = BIC_OPERATING_SYSTEM,
310 .type = BIT_STRING,
311 .analytics = NULL,
312 .print = "Operating System ID",
313 .json = "id",
314 .value = "unknown",
315 },
316 [BIB_OS_ID_LIKE] = {
317 .category = BIC_OPERATING_SYSTEM,
318 .type = BIT_STRING,
319 .analytics = NULL,
320 .print = "Operating System ID Like",
321 .json = "id_like",
322 .value = "unknown",
323 },
324 [BIB_OS_VERSION] = {
325 .category = BIC_OPERATING_SYSTEM,
326 .type = BIT_STRING,
327 .analytics = NULL,
328 .print = "Operating System Version",
329 .json = "version",
330 .value = "unknown",
331 },
332 [BIB_OS_VERSION_ID] = {
333 .category = BIC_OPERATING_SYSTEM,
334 .type = BIT_STRING,
335 .analytics = NULL,
336 .print = "Operating System Version ID",
337 .json = "version_id",
338 .value = "unknown",
339 },
340 [BIB_OS_DETECTION] = {
341 .category = BIC_OPERATING_SYSTEM,
342 .type = BIT_STRING,
343 .analytics = NULL,
344 .print = "Detection",
345 .json = "detection",
346 .value = "unknown",
347 },
348 [BIB_HW_CPU_CORES] = {
349 .category = BIC_HARDWARE,
350 .type = BIT_STRING,
351 .analytics = NULL,
352 .print = "CPU Cores",
353 .json = "cpu_cores",
354 .value = "unknown",
355 },
356 [BIB_HW_CPU_FREQUENCY] = {
357 .category = BIC_HARDWARE,
358 .type = BIT_STRING,
359 .analytics = NULL,
360 .print = "CPU Frequency",
361 .json = "cpu_frequency",
362 .value = "unknown",
363 },
364 [BIB_HW_ARCHITECTURE] = {
365 .category = BIC_HARDWARE,
366 .type = BIT_STRING,
367 .analytics = NULL,
368 .print = "CPU Architecture",
369 .json = "cpu_architecture",
370 .value = "unknown",
371 },
372 [BIB_HW_RAM_SIZE] = {
373 .category = BIC_HARDWARE,
374 .type = BIT_STRING,
375 .analytics = NULL,
376 .print = "RAM Bytes",
377 .json = "ram",
378 .value = "unknown",
379 },
380 [BIB_HW_DISK_SPACE] = {
381 .category = BIC_HARDWARE,
382 .type = BIT_STRING,
383 .analytics = NULL,
384 .print = "Disk Capacity",
385 .json = "disk",
386 .value = "unknown",
387 },
388 [BIB_HW_VIRTUALIZATION] = {
389 .category = BIC_HARDWARE,
390 .type = BIT_STRING,
391 .analytics = NULL,
392 .print = "Virtualization Technology",
393 .json = "virtualization",
394 .value = "unknown",
395 },
396 [BIB_HW_VIRTUALIZATION_DETECTION] = {
397 .category = BIC_HARDWARE,
398 .type = BIT_STRING,
399 .analytics = NULL,
400 .print = "Virtualization Detection",
401 .json = "virtualization_detection",
402 .value = "unknown",
403 },
404 [BIB_CONTAINER_NAME] = {
405 .category = BIC_CONTAINER,
406 .type = BIT_STRING,
407 .analytics = NULL,
408 .print = "Container",
409 .json = "container",
410 .value = "unknown",
411 },
412 [BIB_CONTAINER_DETECTION] = {
413 .category = BIC_CONTAINER,
414 .type = BIT_STRING,
415 .analytics = NULL,
416 .print = "Container Detection",
417 .json = "container_detection",
418 .value = "unknown",
419 },
420 [BIB_CONTAINER_ORCHESTRATOR] = {
421 .category = BIC_CONTAINER,
422 .type = BIT_STRING,
423 .analytics = NULL,
424 .print = "Container Orchestrator",
425 .json = "orchestrator",
426 .value = "unknown",
427 },
428 [BIB_CONTAINER_OS_NAME] = {
429 .category = BIC_CONTAINER,
430 .type = BIT_STRING,
431 .analytics = NULL,
432 .print = "Container Operating System",
433 .json = "os",
434 .value = "unknown",
435 },
436 [BIB_CONTAINER_OS_ID] = {
437 .category = BIC_CONTAINER,
438 .type = BIT_STRING,
439 .analytics = NULL,
440 .print = "Container Operating System ID",
441 .json = "os_id",
442 .value = "unknown",
443 },
444 [BIB_CONTAINER_OS_ID_LIKE] = {
445 .category = BIC_CONTAINER,
446 .type = BIT_STRING,
447 .analytics = NULL,
448 .print = "Container Operating System ID Like",
449 .json = "os_id_like",
450 .value = "unknown",
451 },
452 [BIB_CONTAINER_OS_VERSION] = {
453 .category = BIC_CONTAINER,
454 .type = BIT_STRING,
455 .analytics = NULL,
456 .print = "Container Operating System Version",
457 .json = "version",
458 .value = "unknown",
459 },
460 [BIB_CONTAINER_OS_VERSION_ID] = {
461 .category = BIC_CONTAINER,
462 .type = BIT_STRING,
463 .analytics = NULL,
464 .print = "Container Operating System Version ID",
465 .json = "version_id",
466 .value = "unknown",
467 },
468 [BIB_CONTAINER_OS_DETECTION] = {
469 .category = BIC_CONTAINER,
470 .type = BIT_STRING,
471 .analytics = NULL,
472 .print = "Container Operating System Detection",
473 .json = "detection",
474 .value = "unknown",
475 },
476 [BIB_FEATURE_BUILT_FOR] = {
477 .category = BIC_FEATURE,
478 .type = BIT_STRING,
479 .analytics = NULL,
480 .print = "Built For",
481 .json = "built-for",
482 .value = "unknown",
483 },
484 [BIB_FEATURE_CLOUD] = {
485 .category = BIC_FEATURE,
486 .type = BIT_BOOLEAN,
487 .analytics = "Netdata Cloud",
488 .print = "Netdata Cloud",
489 .json = "cloud",
490 .value = NULL,
491 },
492 [BIB_FEATURE_HEALTH] = {
493 .category = BIC_FEATURE,
494 .type = BIT_BOOLEAN,
495 .analytics = NULL,
496 .print = "Health (trigger alerts and send notifications)",
497 .json = "health",
498 .value = NULL,
499 },
500 [BIB_FEATURE_STREAMING] = {
501 .category = BIC_FEATURE,
502 .type = BIT_BOOLEAN,
503 .analytics = NULL,
504 .print = "Streaming (stream metrics to parent Netdata servers)",
505 .json = "streaming",
506 .value = NULL,
507 },
508 [BIB_FEATURE_BACKFILLING] = {
509 .category = BIC_FEATURE,
510 .type = BIT_BOOLEAN,
511 .analytics = NULL,
512 .print = "Back-filling (of higher database tiers)",
513 .json = "back-filling",
514 .value = NULL,
515 },
516 [BIB_FEATURE_REPLICATION] = {
517 .category = BIC_FEATURE,
518 .type = BIT_BOOLEAN,
519 .analytics = NULL,
520 .print = "Replication (fill the gaps of parent Netdata servers)",
521 .json = "replication",
522 .value = NULL,
523 },
524 [BIB_FEATURE_STREAMING_COMPRESSION] = {
525 .category = BIC_FEATURE,
526 .type = BIT_BOOLEAN,
527 .analytics = "Stream Compression",
528 .print = "Streaming and Replication Compression",
529 .json = "stream-compression",
530 .value = NULL,
531 },
532 [BIB_FEATURE_CONTEXTS] = {
533 .category = BIC_FEATURE,
534 .type = BIT_BOOLEAN,
535 .analytics = NULL,
536 .print = "Contexts (index all active and archived metrics)",
537 .json = "contexts",
538 .value = NULL,
539 },
540 [BIB_FEATURE_TIERING] = {
541 .category = BIC_FEATURE,
542 .type = BIT_BOOLEAN,
543 .analytics = NULL,
544 .print = "Tiering (multiple dbs with different metrics resolution)",
545 .json = "tiering",
546 .value = TOSTRING(RRD_STORAGE_TIERS),
547 },
548 [BIB_FEATURE_ML] = {
549 .category = BIC_FEATURE,
550 .type = BIT_BOOLEAN,
551 .analytics = "Machine Learning",
552 .print = "Machine Learning",
553 .json = "ml",
554 .value = NULL,
555 },
556 [BIB_FEATURE_ALLOCATOR] = {
557 .category = BIC_FEATURE,
558 .type = BIT_STRING,
559 .analytics = "allocator",
560 .print = "Memory Allocator",
561 .json = "allocator",
562 .value = NULL,
563 },
564 [BIB_DB_SQLITE] = {
565 .category = BIC_DATABASE,
566 .type = BIT_STRING,
567 .analytics = NULL,
568 .print = "sqlite",
569 .json = "sqlite",
570 .value = "unknown",
571 },
572 [BIB_DB_DBENGINE] = {
573 .category = BIC_DATABASE,
574 .type = BIT_BOOLEAN,
575 .analytics = "dbengine",
576 .print = "dbengine (compression)",
577 .json = "dbengine",
578 .value = NULL,
579 },
580 [BIB_DB_ALLOC] = {
581 .category = BIC_DATABASE,
582 .type = BIT_BOOLEAN,
583 .analytics = NULL,
584 .print = "alloc",
585 .json = "alloc",
586 .value = NULL,
587 },
588 [BIB_DB_RAM] = {
589 .category = BIC_DATABASE,
590 .type = BIT_BOOLEAN,
591 .analytics = NULL,
592 .print = "ram",
593 .json = "ram",
594 .value = NULL,
595 },
596 [BIB_DB_NONE] = {
597 .category = BIC_DATABASE,
598 .type = BIT_BOOLEAN,
599 .analytics = NULL,
600 .print = "none",
601 .json = "none",
602 .value = NULL,
603 },
604 [BIB_CONNECTIVITY_ACLK] = {
605 .category = BIC_CONNECTIVITY,
606 .type = BIT_BOOLEAN,
607 .analytics = NULL,
608 .print = "ACLK (Agent-Cloud Link: MQTT over WebSockets over TLS)",
609 .json = "aclk",
610 .value = NULL,
611 },
612 [BIB_CONNECTIVITY_HTTPD_STATIC] = {
613 .category = BIC_CONNECTIVITY,
614 .type = BIT_BOOLEAN,
615 .analytics = NULL,
616 .print = "static (Netdata internal web server)",
617 .json = "static",
618 .value = NULL,
619 },
620 [BIB_CONNECTIVITY_WEBRTC] = {
621 .category = BIC_CONNECTIVITY,
622 .type = BIT_BOOLEAN,
623 .analytics = NULL,
624 .print = "WebRTC (experimental)",
625 .json = "webrtc",
626 .value = NULL,
627 },
628 [BIB_CONNECTIVITY_NATIVE_HTTPS] = {
629 .category = BIC_CONNECTIVITY,
630 .type = BIT_BOOLEAN,
631 .analytics = "Native HTTPS",
632 .print = "Native HTTPS (TLS Support)",
633 .json = "native-https",
634 .value = NULL,
635 },
636 [BIB_CONNECTIVITY_TLS_HOST_VERIFY] = {
637 .category = BIC_CONNECTIVITY,
638 .type = BIT_BOOLEAN,
639 .analytics = "TLS Host Verification",
640 .print = "TLS Host Verification",
641 .json = "tls-host-verify",
642 .value = NULL,
643 },
644 [BIB_LIB_LZ4] = {
645 .category = BIC_LIBS,
646 .type = BIT_BOOLEAN,
647 .analytics = NULL,
648 .print = "LZ4 (extremely fast lossless compression algorithm)",
649 .json = "lz4",
650 .value = NULL,
651 },
652 [BIB_LIB_ZSTD] = {
653 .category = BIC_LIBS,
654 .type = BIT_BOOLEAN,
655 .analytics = NULL,
656 .print = "ZSTD (fast, lossless compression algorithm)",
657 .json = "zstd",
658 .value = NULL,
659 },
660 [BIB_LIB_ZLIB] = {
661 .category = BIC_LIBS,
662 .type = BIT_BOOLEAN,
663 .analytics = "zlib",
664 .print = "zlib (lossless data-compression library)",
665 .json = "zlib",
666 .value = NULL,
667 },
668 [BIB_LIB_BROTLI] = {
669 .category = BIC_LIBS,
670 .type = BIT_BOOLEAN,
671 .analytics = NULL,
672 .print = "Brotli (generic-purpose lossless compression algorithm)",
673 .json = "brotli",
674 .value = NULL,
675 },
676 [BIB_LIB_PROTOBUF] = {
677 .category = BIC_LIBS,
678 .type = BIT_BOOLEAN,
679 .analytics = "protobuf",
680 .print = "protobuf (platform-neutral data serialization protocol)",
681 .json = "protobuf",
682 .value = NULL,
683 },
684 [BIB_LIB_OPENSSL] = {
685 .category = BIC_LIBS,
686 .type = BIT_BOOLEAN,
687 .analytics = NULL,
688 .print = "OpenSSL (cryptography)",
689 .json = "openssl",
690 .value = NULL,
691 },
692 [BIB_LIB_LIBDATACHANNEL] = {
693 .category = BIC_LIBS,
694 .type = BIT_BOOLEAN,
695 .analytics = NULL,
696 .print = "libdatachannel (stand-alone WebRTC data channels)",
697 .json = "libdatachannel",
698 .value = NULL,
699 },
700 [BIB_LIB_JSONC] = {
701 .category = BIC_LIBS,
702 .type = BIT_BOOLEAN,
703 .analytics = "JSON-C",
704 .print = "JSON-C (lightweight JSON manipulation)",
705 .json = "jsonc",
706 .value = NULL,
707 },
708 [BIB_LIB_LIBCAP] = {
709 .category = BIC_LIBS,
710 .type = BIT_BOOLEAN,
711 .analytics = "libcap",
712 .print = "libcap (Linux capabilities system operations)",
713 .json = "libcap",
714 .value = NULL,
715 },
716 [BIB_LIB_LIBCRYPTO] = {
717 .category = BIC_LIBS,
718 .type = BIT_BOOLEAN,
719 .analytics = "libcrypto",
720 .print = "libcrypto (cryptographic functions)",
721 .json = "libcrypto",
722 .value = NULL,
723 },
724 [BIB_LIB_LIBYAML] = {
725 .category = BIC_LIBS,
726 .type = BIT_BOOLEAN,
727 .analytics = "libyaml",
728 .print = "libyaml (library for parsing and emitting YAML)",
729 .json = "libyaml",
730 .value = NULL,
731 },
732 [BIB_LIB_LIBMNL] = {
733 .category = BIC_LIBS,
734 .type = BIT_BOOLEAN,
735 .analytics = "libmnl",
736 .print = "libmnl (library for working with netfilter)",
737 .json = "libmnl",
738 .value = NULL,
739 },
740 [BIB_LIB_STACKTRACE] = {
741 .category = BIC_LIBS,
742 .type = BIT_STRING,
743 .analytics = "stacktraces",
744 .print = "stacktraces (library for getting stack traces)",
745 .json = "stacktraces",
746 .value = NULL,
747 },
748 [BIB_PLUGIN_APPS] = {
749 .category = BIC_PLUGINS,
750 .type = BIT_BOOLEAN,
751 .analytics = "apps",
752 .print = "apps (monitor processes)",
753 .json = "apps",
754 .value = NULL,
755 },
756 [BIB_PLUGIN_LINUX_CGROUPS] = {
757 .category = BIC_PLUGINS,
758 .type = BIT_BOOLEAN,
759 .analytics = NULL,
760 .print = "cgroups (monitor containers and VMs)",
761 .json = "cgroups",
762 .value = NULL,
763 },
764 [BIB_PLUGIN_LINUX_CGROUP_NETWORK] = {
765 .category = BIC_PLUGINS,
766 .type = BIT_BOOLEAN,
767 .analytics = "cgroup Network Tracking",
768 .print = "cgroup-network (associate interfaces to CGROUPS)",
769 .json = "cgroup-network",
770 .value = NULL,
771 },
772 [BIB_PLUGIN_LINUX_PROC] = {
773 .category = BIC_PLUGINS,
774 .type = BIT_BOOLEAN,
775 .analytics = NULL,
776 .print = "proc (monitor Linux systems)",
777 .json = "proc",
778 .value = NULL,
779 },
780 [BIB_PLUGIN_LINUX_TC] = {
781 .category = BIC_PLUGINS,
782 .type = BIT_BOOLEAN,
783 .analytics = NULL,
784 .print = "tc (monitor Linux network QoS)",
785 .json = "tc",
786 .value = NULL,
787 },
788 [BIB_PLUGIN_LINUX_DISKSPACE] = {
789 .category = BIC_PLUGINS,
790 .type = BIT_BOOLEAN,
791 .analytics = NULL,
792 .print = "diskspace (monitor Linux mount points)",
793 .json = "diskspace",
794 .value = NULL,
795 },
796 [BIB_PLUGIN_FREEBSD] = {
797 .category = BIC_PLUGINS,
798 .type = BIT_BOOLEAN,
799 .analytics = NULL,
800 .print = "freebsd (monitor FreeBSD systems)",
801 .json = "freebsd",
802 .value = NULL,
803 },
804 [BIB_PLUGIN_MACOS] = {
805 .category = BIC_PLUGINS,
806 .type = BIT_BOOLEAN,
807 .analytics = NULL,
808 .print = "macos (monitor MacOS systems)",
809 .json = "macos",
810 .value = NULL,
811 },
812 [BIB_PLUGIN_WINDOWS] = {
813 .category = BIC_PLUGINS,
814 .type = BIT_BOOLEAN,
815 .analytics = NULL,
816 .print = "windows (monitor Windows systems)",
817 .json = "windows",
818 .value = NULL,
819 },
820 [BIB_PLUGIN_STATSD] = {
821 .category = BIC_PLUGINS,
822 .type = BIT_BOOLEAN,
823 .analytics = NULL,
824 .print = "statsd (collect custom application metrics)",
825 .json = "statsd",
826 .value = NULL,
827 },
828 [BIB_PLUGIN_TIMEX] = {
829 .category = BIC_PLUGINS,
830 .type = BIT_BOOLEAN,
831 .analytics = NULL,
832 .print = "timex (check system clock synchronization)",
833 .json = "timex",
834 .value = NULL,
835 },
836 [BIB_PLUGIN_IDLEJITTER] = {
837 .category = BIC_PLUGINS,
838 .type = BIT_BOOLEAN,
839 .analytics = NULL,
840 .print = "idlejitter (check system latency and jitter)",
841 .json = "idlejitter",
842 .value = NULL,
843 },
844 [BIB_PLUGIN_BASH] = {
845 .category = BIC_PLUGINS,
846 .type = BIT_BOOLEAN,
847 .analytics = NULL,
848 .print = "bash (support shell data collection jobs - charts.d)",
849 .json = "charts.d",
850 .value = NULL,
851 },
852 [BIB_PLUGIN_DEBUGFS] = {
853 .category = BIC_PLUGINS,
854 .type = BIT_BOOLEAN,
855 .analytics = "debugfs",
856 .print = "debugfs (kernel debugging metrics)",
857 .json = "debugfs",
858 .value = NULL,
859 },
860 [BIB_PLUGIN_CUPS] = {
861 .category = BIC_PLUGINS,
862 .type = BIT_BOOLEAN,
863 .analytics = "CUPS",
864 .print = "cups (monitor printers and print jobs)",
865 .json = "cups",
866 .value = NULL,
867 },
868 [BIB_PLUGIN_EBPF] = {
869 .category = BIC_PLUGINS,
870 .type = BIT_BOOLEAN,
871 .analytics = "EBPF",
872 .print = "ebpf (monitor system calls)",
873 .json = "ebpf",
874 .value = NULL,
875 },
876 [BIB_PLUGIN_FREEIPMI] = {
877 .category = BIC_PLUGINS,
878 .type = BIT_BOOLEAN,
879 .analytics = "IPMI",
880 .print = "freeipmi (monitor enterprise server H/W)",
881 .json = "freeipmi",
882 .value = NULL,
883 },
884 [BIB_PLUGIN_NETWORK_VIEWER] = {
885 .category = BIC_PLUGINS,
886 .type = BIT_BOOLEAN,
887 .analytics = "NETWORK-VIEWER",
888 .print = "network-viewer (monitor TCP/UDP IPv4/6 sockets)",
889 .json = "network-viewer",
890 .value = NULL,
891 },
892 [BIB_PLUGIN_SYSTEMD_JOURNAL] = {
893 .category = BIC_PLUGINS,
894 .type = BIT_BOOLEAN,
895 .analytics = "SYSTEMD-JOURNAL",
896 .print = "systemd-journal (monitor journal logs)",
897 .json = "systemd-journal",
898 .value = NULL,
899 },
900 [BIB_PLUGIN_WINDOWS_EVENTS] = {
901 .category = BIC_PLUGINS,
902 .type = BIT_BOOLEAN,
903 .analytics = "WINDOWS-EVENTS",
904 .print = "windows-events (monitor Windows events)",
905 .json = "windows-events",
906 .value = NULL,
907 },
908 [BIB_PLUGIN_NFACCT] = {
909 .category = BIC_PLUGINS,
910 .type = BIT_BOOLEAN,
911 .analytics = "NFACCT",
912 .print = "nfacct (gather netfilter accounting)",
913 .json = "nfacct",
914 .value = NULL,
915 },
916 [BIB_PLUGIN_PERF] = {
917 .category = BIC_PLUGINS,
918 .type = BIT_BOOLEAN,
919 .analytics = "perf",
920 .print = "perf (collect kernel performance events)",
921 .json = "perf",
922 .value = NULL,
923 },
924 [BIB_PLUGIN_SLABINFO] = {
925 .category = BIC_PLUGINS,
926 .type = BIT_BOOLEAN,
927 .analytics = "slabinfo",
928 .print = "slabinfo (monitor kernel object caching)",
929 .json = "slabinfo",
930 .value = NULL,
931 },
932 [BIB_PLUGIN_XEN] = {
933 .category = BIC_PLUGINS,
934 .type = BIT_BOOLEAN,
935 .analytics = "Xen",
936 .print = "Xen",
937 .json = "xen",
938 .value = NULL,
939 },
940 [BIB_PLUGIN_XEN_VBD_ERROR] = {
941 .category = BIC_PLUGINS,
942 .type = BIT_BOOLEAN,
943 .analytics = "Xen VBD Error Tracking",
944 .print = "Xen VBD Error Tracking",
945 .json = "xen-vbd-error",
946 .value = NULL,
947 },
948 [BIB_EXPORT_MONGOC] = {
949 .category = BIC_EXPORTERS,
950 .type = BIT_BOOLEAN,
951 .analytics = "MongoDB",
952 .print = "MongoDB",
953 .json = "mongodb",
954 .value = NULL,
955 },
956 [BIB_EXPORT_GRAPHITE] = {
957 .category = BIC_EXPORTERS,
958 .type = BIT_BOOLEAN,
959 .analytics = NULL,
960 .print = "Graphite",
961 .json = "graphite",
962 .value = NULL,
963 },
964 [BIB_EXPORT_GRAPHITE_HTTP] = {
965 .category = BIC_EXPORTERS,
966 .type = BIT_BOOLEAN,
967 .analytics = NULL,
968 .print = "Graphite HTTP / HTTPS",
969 .json = "graphite:http",
970 .value = NULL,
971 },
972 [BIB_EXPORT_JSON] = {
973 .category = BIC_EXPORTERS,
974 .type = BIT_BOOLEAN,
975 .analytics = NULL,
976 .print = "JSON",
977 .json = "json",
978 .value = NULL,
979 },
980 [BIB_EXPORT_JSON_HTTP] = {
981 .category = BIC_EXPORTERS,
982 .type = BIT_BOOLEAN,
983 .analytics = NULL,
984 .print = "JSON HTTP / HTTPS",
985 .json = "json:http",
986 .value = NULL,
987 },
988 [BIB_EXPORT_OPENTSDB] = {
989 .category = BIC_EXPORTERS,
990 .type = BIT_BOOLEAN,
991 .analytics = NULL,
992 .print = "OpenTSDB",
993 .json = "opentsdb",
994 .value = NULL,
995 },
996 [BIB_EXPORT_OPENTSDB_HTTP] = {
997 .category = BIC_EXPORTERS,
998 .type = BIT_BOOLEAN,
999 .analytics = NULL,
1000 .print = "OpenTSDB HTTP / HTTPS",
1001 .json = "opentsdb:http",
1002 .value = NULL,
1003 },
1004 [BIB_EXPORT_ALLMETRICS] = {
1005 .category = BIC_EXPORTERS,
1006 .analytics = NULL,
1007 .type = BIT_BOOLEAN,
1008 .print = "All Metrics API",
1009 .json = "allmetrics",
1010 .value = NULL,
1011 },
1012 [BIB_EXPORT_SHELL] = {
1013 .category = BIC_EXPORTERS,
1014 .type = BIT_BOOLEAN,
1015 .analytics = NULL,
1016 .print = "Shell (use metrics in shell scripts)",
1017 .json = "shell",
1018 .value = NULL,
1019 },
1020 [BIB_EXPORT_PROMETHEUS_EXPORTER] = {
1021 .category = BIC_EXPORTERS,
1022 .type = BIT_BOOLEAN,
1023 .analytics = NULL,
1024 .print = "Prometheus (OpenMetrics) Exporter",
1025 .json = "openmetrics",
1026 .value = NULL,
1027 },
1028 [BIB_EXPORT_PROMETHEUS_REMOTE_WRITE] = {
1029 .category = BIC_EXPORTERS,
1030 .type = BIT_BOOLEAN,
1031 .analytics = "Prometheus Remote Write",
1032 .print = "Prometheus Remote Write",
1033 .json = "prom-remote-write",
1034 .value = NULL,
1035 },
1036 [BIB_EXPORT_AWS_KINESIS] = {
1037 .category = BIC_EXPORTERS,
1038 .type = BIT_BOOLEAN,
1039 .analytics = "AWS Kinesis",
1040 .print = "AWS Kinesis",
1041 .json = "kinesis",
1042 .value = NULL,
1043 },
1044 [BIB_EXPORT_GCP_PUBSUB] = {
1045 .category = BIC_EXPORTERS,
1046 .type = BIT_BOOLEAN,
1047 .analytics = "GCP PubSub",
1048 .print = "GCP PubSub",
1049 .json = "pubsub",
1050 .value = NULL,
1051 },
1052 [BIB_DEVEL_TRACE_ALLOCATIONS] = {
1053 .category = BIC_DEBUG_DEVEL,
1054 .type = BIT_BOOLEAN,
1055 .analytics = "DebugTraceAlloc",
1056 .print = "Trace All Netdata Allocations (with charts)",
1057 .json = "trace-allocations",
1058 .value = NULL,
1059 },
1060 [BIB_DEVELOPER_MODE] = {
1061 .category = BIC_DEBUG_DEVEL,
1062 .type = BIT_BOOLEAN,
1063 .analytics = NULL,
1064 .print = "Developer Mode (more runtime checks, slower)",
1065 .json = "dev-mode",
1066 .value = NULL,
1067 },
1068 [BIB_RUNTIME_PROFILE] = {
1069 .category = BIC_RUNTIME,
1070 .type = BIT_STRING,
1071 .analytics = "ConfigProfile",
1072 .print = "Profile",
1073 .json = "profile",
1074 .value = NULL,
1075 },
1076 [BIB_RUNTIME_PARENT] = {
1077 .category = BIC_RUNTIME,
1078 .type = BIT_BOOLEAN,
1079 .analytics = "StreamParent",
1080 .print = "Stream Parent (accept data from Children)",
1081 .json = "parent",
1082 .value = NULL,
1083 },
1084 [BIB_RUNTIME_CHILD] = {
1085 .category = BIC_RUNTIME,
1086 .type = BIT_BOOLEAN,
1087 .analytics = "StreamChild",
1088 .print = "Stream Child (send data to a Parent)",
1089 .json = "child",
1090 .value = NULL,
1091 },
1092 [BIB_RUNTIME_MEM_TOTAL] = {
1093 .category = BIC_RUNTIME,
1094 .type = BIT_STRING,
1095 .analytics = "TotalMemory",
1096 .print = "Total System Memory",
1097 .json = "mem-total",
1098 .value = NULL,
1099 },
1100 [BIB_RUNTIME_MEM_AVAIL] = {
1101 .category = BIC_RUNTIME,
1102 .type = BIT_STRING,
1103 .analytics = "AvailableMemory",
1104 .print = "Available System Memory",
1105 .json = "mem-available",
1106 .value = NULL,
1107 },
1108
1109 // leave this last
1110 [BIB_TERMINATOR] = {
1111 .category = 0,
1112 .type = 0,
1113 .analytics = NULL,
1114 .print = NULL,
1115 .json = NULL,
1116 .value = NULL,
1117 },
1118 };
1119
1120 static void build_info_set_value(BUILD_INFO_SLOT slot, const char *value) {
1121 const char *old = BUILD_INFO[slot].value;
1122
1123 BUILD_INFO[slot].value = value;
1124
1125 if(BUILD_INFO[slot].value_allocated)
1126 freez((void *)old);
1127
1128 BUILD_INFO[slot].value_allocated = false;
1129 }
1130
1131 static void build_info_append_value(BUILD_INFO_SLOT slot, const char *value) {
1132 size_t size = BUILD_INFO[slot].value ? strlen(BUILD_INFO[slot].value) + 1 : 0;
1133 size += strlen(value);
1134 CLEAN_CHAR_P *buf = mallocz(size + 1);
1135
1136 if(BUILD_INFO[slot].value) {
1137 strcpy(buf, BUILD_INFO[slot].value);
1138 strcat(buf, " ");
1139 strcat(buf, value);
1140 }
1141 else
1142 strcpy(buf, value);
1143
1144 const char *old = BUILD_INFO[slot].value;
1145
1146 BUILD_INFO[slot].value = strdupz(buf);
1147
1148 if(BUILD_INFO[slot].value_allocated)
1149 freez((void *)old);
1150
1151 BUILD_INFO[slot].value_allocated = true;
1152 }
1153
1154 static void build_info_set_value_strdupz(BUILD_INFO_SLOT slot, const char *value) {
1155 if(!value) value = "";
1156
1157 if(BUILD_INFO[slot].value && strcmp(BUILD_INFO[slot].value, value) == 0)
1158 return;
1159
1160 const char *old = BUILD_INFO[slot].value;
1161
1162 BUILD_INFO[slot].value = strdupz(value);
1163
1164 if(old && BUILD_INFO[slot].value_allocated)
1165 freez((void *)old);
1166
1167 BUILD_INFO[slot].value_allocated = true;
1168 }
1169
1170 static void build_info_set_status(BUILD_INFO_SLOT slot, bool status) {
1171 BUILD_INFO[slot].status = status;
1172 }
1173
1174 __attribute__((constructor)) void initialize_build_info(void) {
1175 build_info_set_value(BIB_PACKAGING_NETDATA_VERSION, NETDATA_VERSION);
1176 build_info_set_value(BIB_PACKAGING_CONFIGURE_OPTIONS, CONFIGURE_COMMAND);
1177
1178 #ifdef OS_LINUX
1179 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1180 build_info_set_value(BIB_FEATURE_BUILT_FOR, "Linux");
1181 build_info_set_status(BIB_PLUGIN_LINUX_CGROUPS, true);
1182 build_info_set_status(BIB_PLUGIN_LINUX_PROC, true);
1183 build_info_set_status(BIB_PLUGIN_LINUX_DISKSPACE, true);
1184 build_info_set_status(BIB_PLUGIN_LINUX_TC, true);
1185 #endif
1186 #ifdef OS_FREEBSD
1187 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1188 build_info_set_value(BIB_FEATURE_BUILT_FOR, "FreeBSD");
1189 build_info_set_status(BIB_PLUGIN_FREEBSD, true);
1190 #endif
1191 #ifdef OS_MACOS
1192 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1193 build_info_set_value(BIB_FEATURE_BUILT_FOR, "MacOS");
1194 build_info_set_status(BIB_PLUGIN_MACOS, true);
1195 #endif
1196 #ifdef OS_WINDOWS
1197 build_info_set_status(BIB_PLUGIN_WINDOWS, true);
1198 build_info_set_status(BIB_PLUGIN_WINDOWS_EVENTS, true);
1199 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1200 #if defined(__CYGWIN__) && defined(__MSYS__)
1201 build_info_set_value(BIB_FEATURE_BUILT_FOR, "Windows (MSYS)");
1202 #elif defined(__CYGWIN__)
1203 build_info_set_value(BIB_FEATURE_BUILT_FOR, "Windows (CYGWIN)");
1204 #else
1205 build_info_set_value(BIB_FEATURE_BUILT_FOR, "Windows");
1206 #endif
1207 #endif
1208
1209 build_info_set_status(BIB_FEATURE_CLOUD, true);
1210 build_info_set_status(BIB_CONNECTIVITY_ACLK, true);
1211 build_info_set_status(BIB_FEATURE_HEALTH, true);
1212 build_info_set_status(BIB_FEATURE_STREAMING, true);
1213 build_info_set_status(BIB_FEATURE_BACKFILLING, true);
1214 build_info_set_status(BIB_FEATURE_REPLICATION, true);
1215
1216 build_info_set_status(BIB_FEATURE_STREAMING_COMPRESSION, true);
1217
1218 #ifdef ENABLE_ZSTD
1219 build_info_append_value(BIB_FEATURE_STREAMING_COMPRESSION, "zstd");
1220 #endif
1221 #ifdef ENABLE_LZ4
1222 build_info_append_value(BIB_FEATURE_STREAMING_COMPRESSION, "lz4");
1223 #endif
1224 build_info_append_value(BIB_FEATURE_STREAMING_COMPRESSION, "gzip");
1225 #ifdef ENABLE_BROTLI
1226 build_info_append_value(BIB_FEATURE_STREAMING_COMPRESSION, "brotli");
1227 #endif
1228
1229 build_info_set_status(BIB_FEATURE_CONTEXTS, true);
1230 build_info_set_status(BIB_FEATURE_TIERING, true);
1231
1232 #ifdef ENABLE_ML
1233 build_info_set_status(BIB_FEATURE_ML, true);
1234 #endif
1235
1236 #if defined(ENABLE_MIMALLOC)
1237 build_info_set_status(BIB_FEATURE_ALLOCATOR, true);
1238 build_info_set_value(BIB_FEATURE_ALLOCATOR, "mimalloc");
1239 #else
1240 build_info_set_status(BIB_FEATURE_ALLOCATOR, true);
1241 build_info_set_value(BIB_FEATURE_ALLOCATOR, "system");
1242 #endif
1243
1244 build_info_set_value(BIB_DB_SQLITE, sqlite3_libversion());
1245
1246 #ifdef ENABLE_DBENGINE
1247 build_info_set_status(BIB_DB_DBENGINE, true);
1248 #ifdef ENABLE_ZSTD
1249 build_info_append_value(BIB_DB_DBENGINE, "zstd");
1250 #endif
1251 #ifdef ENABLE_LZ4
1252 build_info_append_value(BIB_DB_DBENGINE, "lz4");
1253 #endif
1254 #endif
1255 build_info_set_status(BIB_DB_ALLOC, true);
1256 build_info_set_status(BIB_DB_RAM, true);
1257 build_info_set_status(BIB_DB_NONE, true);
1258
1259 build_info_set_status(BIB_CONNECTIVITY_HTTPD_STATIC, true);
1260 #ifdef ENABLE_WEBRTC
1261 build_info_set_status(BIB_CONNECTIVITY_WEBRTC, true);
1262 #endif
1263 build_info_set_status(BIB_CONNECTIVITY_NATIVE_HTTPS, true);
1264 #if defined(HAVE_X509_VERIFY_PARAM_set1_host) && HAVE_X509_VERIFY_PARAM_set1_host == 1
1265 build_info_set_status(BIB_CONNECTIVITY_TLS_HOST_VERIFY, true);
1266 #endif
1267
1268 #ifdef ENABLE_LZ4
1269 build_info_set_status(BIB_LIB_LZ4, true);
1270 #endif
1271 #ifdef ENABLE_ZSTD
1272 build_info_set_status(BIB_LIB_ZSTD, true);
1273 #endif
1274 #ifdef ENABLE_BROTLI
1275 build_info_set_status(BIB_LIB_BROTLI, true);
1276 #endif
1277
1278 build_info_set_status(BIB_LIB_ZLIB, true);
1279
1280 #ifdef HAVE_DLIB
1281 build_info_set_status(BIB_LIB_DLIB, true);
1282 build_info_set_value(BIB_LIB_DLIB, "bundled");
1283 #endif
1284
1285 #ifdef HAVE_PROTOBUF
1286 build_info_set_status(BIB_LIB_PROTOBUF, true);
1287 #ifdef BUNDLED_PROTOBUF
1288 build_info_set_value(BIB_LIB_PROTOBUF, "bundled");
1289 #else
1290 build_info_set_value(BIB_LIB_PROTOBUF, "system");
1291 #endif
1292 #endif
1293
1294 #ifdef HAVE_LIBDATACHANNEL
1295 build_info_set_status(BIB_LIB_LIBDATACHANNEL, true);
1296 #endif
1297 build_info_set_status(BIB_LIB_OPENSSL, true);
1298 #ifdef ENABLE_JSONC
1299 build_info_set_status(BIB_LIB_JSONC, true);
1300 #endif
1301 #ifdef HAVE_CAPABILITY
1302 build_info_set_status(BIB_LIB_LIBCAP, true);
1303 #endif
1304 #ifdef HAVE_CRYPTO
1305 build_info_set_status(BIB_LIB_LIBCRYPTO, true);
1306 #endif
1307 #ifdef HAVE_LIBYAML
1308 build_info_set_status(BIB_LIB_LIBYAML, true);
1309 #endif
1310 #ifdef HAVE_LIBMNL
1311 build_info_set_status(BIB_LIB_LIBMNL, true);
1312 #endif
1313 #ifdef HAVE_LIBBACKTRACE
1314 build_info_set_value(BIB_LIB_STACKTRACE, stacktrace_backend());
1315 #endif
1316
1317 #ifdef ENABLE_PLUGIN_APPS
1318 build_info_set_status(BIB_PLUGIN_APPS, true);
1319 #endif
1320 #ifdef HAVE_SETNS
1321 build_info_set_status(BIB_PLUGIN_LINUX_CGROUP_NETWORK, true);
1322 #endif
1323
1324 build_info_set_status(BIB_PLUGIN_STATSD, true);
1325 build_info_set_status(BIB_PLUGIN_TIMEX, true);
1326 build_info_set_status(BIB_PLUGIN_IDLEJITTER, true);
1327 build_info_set_status(BIB_PLUGIN_BASH, true);
1328
1329 #ifdef ENABLE_PLUGIN_DEBUGFS
1330 build_info_set_status(BIB_PLUGIN_DEBUGFS, true);
1331 #endif
1332 #ifdef ENABLE_PLUGIN_CUPS
1333 build_info_set_status(BIB_PLUGIN_CUPS, true);
1334 #endif
1335 #ifdef ENABLE_PLUGIN_EBPF
1336 build_info_set_status(BIB_PLUGIN_EBPF, true);
1337 #endif
1338 #ifdef ENABLE_PLUGIN_FREEIPMI
1339 build_info_set_status(BIB_PLUGIN_FREEIPMI, true);
1340 #endif
1341 #ifdef ENABLE_PLUGIN_SYSTEMD_JOURNAL
1342 build_info_set_status(BIB_PLUGIN_SYSTEMD_JOURNAL, true);
1343 #endif
1344 #ifdef ENABLE_PLUGIN_NETWORK_VIEWER
1345 build_info_set_status(BIB_PLUGIN_NETWORK_VIEWER, true);
1346 #endif
1347 #ifdef ENABLE_PLUGIN_NFACCT
1348 build_info_set_status(BIB_PLUGIN_NFACCT, true);
1349 #endif
1350 #ifdef ENABLE_PLUGIN_PERF
1351 build_info_set_status(BIB_PLUGIN_PERF, true);
1352 #endif
1353 #ifdef ENABLE_PLUGIN_SLABINFO
1354 build_info_set_status(BIB_PLUGIN_SLABINFO, true);
1355 #endif
1356 #ifdef ENABLE_PLUGIN_XENSTAT
1357 build_info_set_status(BIB_PLUGIN_XEN, true);
1358 #endif
1359 #ifdef HAVE_XENSTAT_VBD_ERROR
1360 build_info_set_status(BIB_PLUGIN_XEN_VBD_ERROR, true);
1361 #endif
1362
1363 build_info_set_status(BIB_EXPORT_PROMETHEUS_EXPORTER, true);
1364 build_info_set_status(BIB_EXPORT_GRAPHITE, true);
1365 build_info_set_status(BIB_EXPORT_GRAPHITE_HTTP, true);
1366 build_info_set_status(BIB_EXPORT_JSON, true);
1367 build_info_set_status(BIB_EXPORT_JSON_HTTP, true);
1368 build_info_set_status(BIB_EXPORT_OPENTSDB, true);
1369 build_info_set_status(BIB_EXPORT_OPENTSDB_HTTP, true);
1370 build_info_set_status(BIB_EXPORT_ALLMETRICS, true);
1371 build_info_set_status(BIB_EXPORT_SHELL, true);
1372
1373 #ifdef HAVE_KINESIS
1374 build_info_set_status(BIB_EXPORT_AWS_KINESIS, true);
1375 #endif
1376 #ifdef ENABLE_EXPORTING_PUBSUB
1377 build_info_set_status(BIB_EXPORT_GCP_PUBSUB, true);
1378 #endif
1379 #ifdef HAVE_MONGOC
1380 build_info_set_status(BIB_EXPORT_MONGOC, true);
1381 #endif
1382 #ifdef ENABLE_PROMETHEUS_REMOTE_WRITE
1383 build_info_set_status(BIB_EXPORT_PROMETHEUS_REMOTE_WRITE, true);
1384 #endif
1385
1386 #ifdef NETDATA_TRACE_ALLOCATIONS
1387 build_info_set_status(BIB_DEVEL_TRACE_ALLOCATIONS, true);
1388 #endif
1389
1390 #if defined(NETDATA_DEV_MODE) || defined(NETDATA_INTERNAL_CHECKS)
1391 build_info_set_status(BIB_DEVELOPER_MODE, true);
1392 #endif
1393 }
1394
1395 // ----------------------------------------------------------------------------
1396 // system info
1397
1398 static void populate_system_info(void) {
1399 FUNCTION_RUN_ONCE();
1400
1401 struct rrdhost_system_info *system_info;
1402 bool free_system_info = false;
1403
1404 if(localhost && localhost->system_info) {
1405 system_info = localhost->system_info;
1406 }
1407 else {
1408 bool started_spawn_server = false;
1409 if(!netdata_main_spawn_server) {
1410 started_spawn_server = true;
1411 netdata_main_spawn_server_init(NULL, 0, NULL);
1412 }
1413
1414 system_info = rrdhost_system_info_create();
1415 rrdhost_system_info_detect(system_info);
1416 free_system_info = true;
1417
1418 if(started_spawn_server)
1419 netdata_main_spawn_server_cleanup();
1420 }
1421
1422 build_info_set_value_strdupz(BIB_OS_KERNEL_NAME, system_info->kernel_name);
1423 build_info_set_value_strdupz(BIB_OS_KERNEL_VERSION, system_info->kernel_version);
1424 build_info_set_value_strdupz(BIB_OS_NAME, system_info->host_os_name);
1425 build_info_set_value_strdupz(BIB_OS_ID, system_info->host_os_id);
1426 build_info_set_value_strdupz(BIB_OS_ID_LIKE, system_info->host_os_id_like);
1427 build_info_set_value_strdupz(BIB_OS_VERSION, system_info->host_os_version);
1428 build_info_set_value_strdupz(BIB_OS_VERSION_ID, system_info->container_os_version_id);
1429 build_info_set_value_strdupz(BIB_OS_DETECTION, system_info->host_os_detection);
1430 build_info_set_value_strdupz(BIB_HW_CPU_CORES, system_info->host_cores);
1431 build_info_set_value_strdupz(BIB_HW_CPU_FREQUENCY, system_info->host_cpu_freq);
1432 build_info_set_value_strdupz(BIB_HW_RAM_SIZE, system_info->host_ram_total);
1433 build_info_set_value_strdupz(BIB_HW_DISK_SPACE, system_info->host_disk_space);
1434 build_info_set_value_strdupz(BIB_HW_ARCHITECTURE, system_info->architecture);
1435 build_info_set_value_strdupz(BIB_HW_VIRTUALIZATION, system_info->virtualization);
1436 build_info_set_value_strdupz(BIB_HW_VIRTUALIZATION_DETECTION, system_info->virt_detection);
1437 build_info_set_value_strdupz(BIB_CONTAINER_NAME, system_info->container);
1438 build_info_set_value_strdupz(BIB_CONTAINER_DETECTION, system_info->container_detection);
1439
1440 if(system_info->is_k8s_node && !strcmp(system_info->is_k8s_node, "true"))
1441 build_info_set_value_strdupz(BIB_CONTAINER_ORCHESTRATOR, "kubernetes");
1442 else
1443 build_info_set_value_strdupz(BIB_CONTAINER_ORCHESTRATOR, "none");
1444
1445 build_info_set_value_strdupz(BIB_CONTAINER_OS_NAME, system_info->container_os_name);
1446 build_info_set_value_strdupz(BIB_CONTAINER_OS_ID, system_info->container_os_id);
1447 build_info_set_value_strdupz(BIB_CONTAINER_OS_ID_LIKE, system_info->container_os_id_like);
1448 build_info_set_value_strdupz(BIB_CONTAINER_OS_VERSION, system_info->container_os_version);
1449 build_info_set_value_strdupz(BIB_CONTAINER_OS_VERSION_ID, system_info->container_os_version_id);
1450 build_info_set_value_strdupz(BIB_CONTAINER_OS_DETECTION, system_info->container_os_detection);
1451
1452 if(free_system_info)
1453 rrdhost_system_info_free(system_info);
1454 }
1455
1456 // ----------------------------------------------------------------------------
1457 // packaging info
1458
1459 char *get_value_from_key(char *buffer, char *key) {
1460 char *s = NULL, *t = NULL;
1461 s = t = buffer + strlen(key) + 2;
1462 if (s) {
1463 while (*s == '\'')
1464 s++;
1465 while (*++t != '\0');
1466 while (--t > s && *t == '\'')
1467 *t = '\0';
1468 }
1469 return s;
1470 }
1471
1472 void get_install_type_internal(char **install_type, char **prebuilt_arch __maybe_unused, char **prebuilt_dist __maybe_unused) {
1473 #ifndef OS_WINDOWS
1474 char *install_type_filename;
1475
1476 unsigned long install_type_filename_len = (strlen(netdata_configured_user_config_dir) + strlen(".install-type") + 3);
1477 install_type_filename = mallocz(sizeof(char) * install_type_filename_len);
1478 snprintfz(install_type_filename, install_type_filename_len - 1, "%s/%s", netdata_configured_user_config_dir, ".install-type");
1479
1480 FILE *fp = fopen(install_type_filename, "r");
1481 if (fp) {
1482 char *s, buf[256 + 1];
1483 size_t len = 0;
1484
1485 while ((s = fgets_trim_len(buf, 256, fp, &len))) {
1486 if (!strncmp(buf, "INSTALL_TYPE='", 14))
1487 *install_type = strdupz((char *)get_value_from_key(buf, "INSTALL_TYPE"));
1488 else if (!strncmp(buf, "PREBUILT_ARCH='", 15))
1489 *prebuilt_arch = strdupz((char *)get_value_from_key(buf, "PREBUILT_ARCH"));
1490 else if (!strncmp(buf, "PREBUILT_DISTRO='", 17))
1491 *prebuilt_dist = strdupz((char *)get_value_from_key(buf, "PREBUILT_DISTRO"));
1492 }
1493 fclose(fp);
1494 }
1495 freez(install_type_filename);
1496 #else
1497 *install_type = strdupz("netdata_installer.exe");
1498 #endif
1499 }
1500
1501 void get_install_type(struct rrdhost_system_info *system_info) {
1502 get_install_type_internal(&system_info->install_type, &system_info->prebuilt_arch, &system_info->prebuilt_dist);
1503 }
1504
1505 static struct {
1506 char *install_type;
1507 char *prebuilt_arch;
1508 char *prebuilt_distro;
1509 } BUILD_PACKAGING_INFO = { 0 };
1510
1511 static void populate_packaging_info() {
1512 FUNCTION_RUN_ONCE();
1513
1514 get_install_type_internal(&BUILD_PACKAGING_INFO.install_type, &BUILD_PACKAGING_INFO.prebuilt_arch, &BUILD_PACKAGING_INFO.prebuilt_distro);
1515
1516 if(!BUILD_PACKAGING_INFO.install_type)
1517 BUILD_PACKAGING_INFO.install_type = "unknown";
1518
1519 if(!BUILD_PACKAGING_INFO.prebuilt_arch)
1520 BUILD_PACKAGING_INFO.prebuilt_arch = "unknown";
1521
1522 if(!BUILD_PACKAGING_INFO.prebuilt_distro)
1523 BUILD_PACKAGING_INFO.prebuilt_distro = "unknown";
1524
1525 build_info_set_value_strdupz(BIB_PACKAGING_INSTALL_TYPE, BUILD_PACKAGING_INFO.install_type);
1526 build_info_set_value_strdupz(BIB_PACKAGING_ARCHITECTURE, BUILD_PACKAGING_INFO.prebuilt_arch);
1527 build_info_set_value_strdupz(BIB_PACKAGING_DISTRO, BUILD_PACKAGING_INFO.prebuilt_distro);
1528
1529 CLEAN_BUFFER *wb = buffer_create(0, NULL);
1530 ND_PROFILE_2buffer(wb, nd_profile_detect_and_configure(false), " ");
1531 build_info_set_value_strdupz(BIB_RUNTIME_PROFILE, buffer_tostring(wb));
1532
1533 build_info_set_status(BIB_RUNTIME_PARENT, stream_conf_is_parent(false));
1534 build_info_set_status(BIB_RUNTIME_CHILD, stream_conf_is_child());
1535
1536 OS_SYSTEM_MEMORY sm = os_system_memory(true);
1537 if(OS_SYSTEM_MEMORY_OK(sm)) {
1538 char buf[1024];
1539 snprintfz(buf, sizeof(buf), "%" PRIu64, sm.ram_total_bytes);
1540 // size_snprintf(buf, sizeof(buf), sm.ram_total_bytes, "B", false);
1541 build_info_set_value_strdupz(BIB_RUNTIME_MEM_TOTAL, buf);
1542
1543 snprintfz(buf, sizeof(buf), "%" PRIu64, sm.ram_available_bytes);
1544 // size_snprintf(buf, sizeof(buf), sm.ram_available_bytes, "B", false);
1545 build_info_set_value_strdupz(BIB_RUNTIME_MEM_AVAIL, buf);
1546 }
1547 }
1548
1549 // ----------------------------------------------------------------------------
1550
1551 static void populate_directories(void) {
1552 build_info_set_value(BIB_DIR_USER_CONFIG, netdata_configured_user_config_dir);
1553 build_info_set_value(BIB_DIR_STOCK_CONFIG, netdata_configured_stock_config_dir);
1554 build_info_set_value(BIB_DIR_STOCK_DATA, netdata_configured_stock_data_dir);
1555 build_info_set_value(BIB_DIR_CACHE, netdata_configured_cache_dir);
1556 build_info_set_value(BIB_DIR_LIB, netdata_configured_varlib_dir);
1557 build_info_set_value(BIB_DIR_PLUGINS, netdata_configured_primary_plugins_dir);
1558 build_info_set_value(BIB_DIR_WEB, netdata_configured_web_dir);
1559 build_info_set_value(BIB_DIR_LOG, netdata_configured_log_dir);
1560 build_info_set_value(BIB_DIR_HOME, netdata_configured_home_dir);
1561 }
1562
1563 // ----------------------------------------------------------------------------
1564
1565 static const char *build_info_value_for_display(size_t i, char **allocated) {
1566 const char *value = BUILD_INFO[i].value;
1567
1568 if(allocated)
1569 *allocated = NULL;
1570
1571 #if defined(OS_WINDOWS)
1572 if(BUILD_INFO[i].category == BIC_DIRECTORIES && BUILD_INFO[i].type == BIT_STRING && value) {
1573 if(!allocated)
1574 return value;
1575
1576 *allocated = os_translate_msys_to_windows_path(value);
1577 return *allocated;
1578 }
1579 #endif
1580
1581 return value;
1582 }
1583
1584 static void print_build_info_category_to_json(BUFFER *b, BUILD_INFO_CATEGORY category, const char *key) {
1585 buffer_json_member_add_object(b, key);
1586 for(size_t i = 0; i < BIB_TERMINATOR ;i++) {
1587 if(BUILD_INFO[i].category == category && BUILD_INFO[i].json) {
1588 #if defined(OS_WINDOWS)
1589 CLEAN_CHAR_P *display_path = NULL;
1590 const char *value = build_info_value_for_display(i, &display_path);
1591 #else
1592 const char *value = build_info_value_for_display(i, NULL);
1593 #endif
1594
1595 if(value)
1596 buffer_json_member_add_string(b, BUILD_INFO[i].json, value);
1597 else
1598 buffer_json_member_add_boolean(b, BUILD_INFO[i].json, BUILD_INFO[i].status);
1599 }
1600 }
1601 buffer_json_object_close(b); // key
1602 }
1603
1604 static void print_build_info_category_to_console(BUILD_INFO_CATEGORY category, const char *title) {
1605 printf("%s:\n", title);
1606 for(size_t i = 0; i < BIB_TERMINATOR ;i++) {
1607 if(BUILD_INFO[i].category == category && BUILD_INFO[i].print) {
1608 const char *v = BUILD_INFO[i].status ? "YES" : "NO";
1609 const char *k = BUILD_INFO[i].print;
1610 #if defined(OS_WINDOWS)
1611 CLEAN_CHAR_P *display_path = NULL;
1612 const char *d = build_info_value_for_display(i, &display_path);
1613 #else
1614 const char *d = build_info_value_for_display(i, NULL);
1615 #endif
1616
1617 int padding_length = 60 - strlen(k) - 1;
1618 if (padding_length < 0) padding_length = 0;
1619
1620 char padding[61];
1621 memset(padding, '_', padding_length);
1622 padding[padding_length] = '\0';
1623
1624 if(BUILD_INFO[i].type == BIT_STRING)
1625 printf(" %s %s : %s\n", k, padding, d?d:"unknown");
1626 else
1627 printf(" %s %s : %s%s%s%s\n", k, padding, v,
1628 d?" (":"", d?d:"", d?")":"");
1629 }
1630 }
1631 }
1632
1633 void print_build_info(void) {
1634 populate_packaging_info();
1635 populate_system_info();
1636 populate_directories();
1637
1638 print_build_info_category_to_console(BIC_PACKAGING, "Packaging");
1639 print_build_info_category_to_console(BIC_DIRECTORIES, "Default Directories");
1640 print_build_info_category_to_console(BIC_OPERATING_SYSTEM, "Operating System");
1641 print_build_info_category_to_console(BIC_HARDWARE, "Hardware");
1642 print_build_info_category_to_console(BIC_CONTAINER, "Container");
1643 print_build_info_category_to_console(BIC_FEATURE, "Features");
1644 print_build_info_category_to_console(BIC_DATABASE, "Database Engines");
1645 print_build_info_category_to_console(BIC_CONNECTIVITY, "Connectivity Capabilities");
1646 print_build_info_category_to_console(BIC_LIBS, "Libraries");
1647 print_build_info_category_to_console(BIC_PLUGINS, "Plugins");
1648 print_build_info_category_to_console(BIC_EXPORTERS, "Exporters");
1649 print_build_info_category_to_console(BIC_DEBUG_DEVEL, "Debug/Developer Features");
1650 print_build_info_category_to_console(BIC_RUNTIME, "Runtime Information");
1651 }
1652
1653 void build_info_to_json_object(BUFFER *b) {
1654 populate_packaging_info();
1655 populate_system_info();
1656 populate_directories();
1657
1658 print_build_info_category_to_json(b, BIC_PACKAGING, "package");
1659 print_build_info_category_to_json(b, BIC_DIRECTORIES, "directories");
1660 print_build_info_category_to_json(b, BIC_OPERATING_SYSTEM, "os");
1661 print_build_info_category_to_json(b, BIC_HARDWARE, "hw");
1662 print_build_info_category_to_json(b, BIC_CONTAINER, "container");
1663 print_build_info_category_to_json(b, BIC_FEATURE, "features");
1664 print_build_info_category_to_json(b, BIC_DATABASE, "databases");
1665 print_build_info_category_to_json(b, BIC_CONNECTIVITY, "connectivity");
1666 print_build_info_category_to_json(b, BIC_LIBS, "libs");
1667 print_build_info_category_to_json(b, BIC_PLUGINS, "plugins");
1668 print_build_info_category_to_json(b, BIC_EXPORTERS, "exporters");
1669 print_build_info_category_to_json(b, BIC_DEBUG_DEVEL, "debug-n-devel");
1670 print_build_info_category_to_json(b, BIC_RUNTIME, "runtime");
1671 }
1672
1673 void print_build_info_json(void) {
1674 populate_packaging_info();
1675 populate_system_info();
1676 populate_directories();
1677
1678 BUFFER *b = buffer_create(0, NULL);
1679 buffer_json_initialize(b, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT);
1680
1681 build_info_to_json_object(b);
1682
1683 buffer_json_finalize(b);
1684 printf("%s\n", buffer_tostring(b));
1685 buffer_free(b);
1686 }
1687
1688 void analytics_build_info(BUFFER *b) {
1689 populate_packaging_info();
1690 populate_system_info();
1691 populate_directories();
1692
1693 size_t added = 0;
1694 for(size_t i = 0; i < BIB_TERMINATOR ;i++) {
1695 if(BUILD_INFO[i].analytics && BUILD_INFO[i].status) {
1696
1697 if(added)
1698 buffer_strcat(b, "|");
1699
1700 buffer_strcat (b, BUILD_INFO[i].analytics);
1701 added++;
1702 }
1703 }
1704 }
1705
1706 void print_build_info_cmake_cache(void) {
1707 const char *path = NETDATA_RUNTIME_PREFIX "/"
1708 BUILD_INFO_CMAKE_CACHE_ARCHIVE_PATH "/"
1709 BUILD_INFO_CMAKE_CACHE_ARCHIVE_NAME;
1710
1711 gzFile f = gzopen(path, "rb");
1712 if (!f) {
1713 printf("Could not open build info cmake cache archive located at %s\n",
1714 path);
1715 return;
1716 }
1717
1718 char line[1024];
1719 while (gzgets(f, line, sizeof(line))) {
1720 printf("%s", line);
1721 }
1722
1723 gzclose(f);
1724 }