@cryptotaxi247 / netdata-1 / commits / ed6d0c454

Simplify and unify the way we are handling versions. (#17693)

* Define a single variable to identify OS. * Remove comments. * Move version-detection logic to separate module. * s/VERSION/NETDATA_VERSION/g * Hard-code NETDATA_VERSION wherever possible. Now `program_version` is only used for getting or setting the host's field. * Update version variables * Add license, fix variable name and provide better message.

vkalintiris committed May 23, 2024 at 17:38 UTC ed6d0c4542bc7941a808961c94a4d81f4cebb478
50 files changed +311 -318
CMakeLists.txt
+32 -95
@@ -2,68 +2,15 @@
2
3 cmake_minimum_required(VERSION 3.13.0...3.28)
4
5 -#
6 -# version atrocities
7 -#
8 -
9 -find_package(Git)
10 -
11 -if(GIT_EXECUTABLE)
12 - execute_process(COMMAND ${GIT_EXECUTABLE} describe
13 - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
14 - RESULT_VARIABLE GIT_DESCRIBE_RESULT
15 - OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT)
16 - if(GIT_DESCRIBE_RESULT)
17 - file(STRINGS packaging/version GIT_DESCRIBE_OUTPUT)
18 - message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
19 - endif()
20 -else()
21 - file(STRINGS packaging/version GIT_DESCRIBE_OUTPUT)
22 - message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
23 -endif()
24 -
25 -string(STRIP ${GIT_DESCRIBE_OUTPUT} GIT_DESCRIBE_OUTPUT)
26 -string(REGEX MATCH "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-?([0-9]+)?-?([0-9a-zA-Z]+)?" MATCHES "${GIT_DESCRIBE_OUTPUT}")
27 -
28 -if(CMAKE_MATCH_COUNT EQUAL 3)
29 - set(FIELD_MAJOR ${CMAKE_MATCH_1})
30 - set(FIELD_MINOR ${CMAKE_MATCH_2})
31 - set(FIELD_PATCH ${CMAKE_MATCH_3})
32 - set(FIELD_TWEAK 0)
33 - set(FIELD_DESCR "N/A")
34 -elseif(CMAKE_MATCH_COUNT EQUAL 4)
35 - set(FIELD_MAJOR ${CMAKE_MATCH_1})
36 - set(FIELD_MINOR ${CMAKE_MATCH_2})
37 - set(FIELD_PATCH ${CMAKE_MATCH_3})
38 - set(FIELD_TWEAK ${CMAKE_MATCH_4})
39 - set(FIELD_DESCR "N/A")
40 -elseif(CMAKE_MATCH_COUNT EQUAL 5)
41 - set(FIELD_MAJOR ${CMAKE_MATCH_1})
42 - set(FIELD_MINOR ${CMAKE_MATCH_2})
43 - set(FIELD_PATCH ${CMAKE_MATCH_3})
44 - set(FIELD_TWEAK ${CMAKE_MATCH_4})
45 - set(FIELD_DESCR ${CMAKE_MATCH_5})
46 -else()
47 - message(FATAL_ERROR "Wrong version regex match count ${CMAKE_MATCH_COUNT} (should be in 3, 4 or 5)")
48 -endif()
49 -
50 -set(NETDATA_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}.${FIELD_TWEAK})
5 +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/packaging/cmake/Modules")
6
52 -if(FIELD_DESCR STREQUAL "N/A")
53 - set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH})
54 -else()
55 - set(CPACK_PACKAGE_VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}-${FIELD_TWEAK}-${FIELD_DESCR})
56 -endif()
57 -
58 -#
59 -# project
60 -#
7 +include(NetdataVersion)
8 +netdata_version()
9
10 project(netdata
63 - VERSION ${NETDATA_VERSION}
11 + VERSION "${NETDATA_VERSION_MAJOR}.${NETDATA_VERSION_MINOR}.${NETDATA_VERSION_PATCH}.${NETDATA_VERSION_TWEAK}"
12 HOMEPAGE_URL "https://www.netdata.cloud"
13 LANGUAGES C CXX)
66 -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/packaging/cmake/Modules")
14 include(CMakeDependentOption)
15
16 if(DEFINED BUILD_SHARED_LIBS)
@@ -139,30 +86,25 @@ set(CONFIG_H ${CONFIG_H_DIR}/config.h)
86 # detect OS
87 #
88
142 -set(LINUX False)
143 -set(FREEBSD False)
144 -set(MACOS False)
145 -set(WINDOWS False)
146 -set(FOREIGN_OS False)
89 +set(OS_FREEBSD False)
90 +set(OS_LINUX False)
91 +set(OS_MACOS False)
92 +set(OS_WINDOWS False)
93
94 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
149 - set(MACOS True)
150 - set(COMPILED_FOR_MACOS True)
95 + set(OS_MACOS True)
96 find_library(IOKIT IOKit)
97 find_library(FOUNDATION Foundation)
98 message(INFO " Compiling for MacOS... ")
99 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
155 - set(FREEBSD True)
156 - set(COMPILED_FOR_FREEBSD True)
100 + set(OS_FREEBSD True)
101 message(INFO " Compiling for FreeBSD... ")
102 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
159 - set(LINUX True)
160 - set(COMPILED_FOR_LINUX True)
103 + set(OS_LINUX True)
104 add_definitions(-D_GNU_SOURCE)
105 message(INFO " Compiling for Linux... ")
106 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "MSYS" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
164 - set(WINDOWS True)
165 - set(COMPILED_FOR_WINDOWS True)
107 + set(OS_WINDOWS True)
108 add_definitions(-D_GNU_SOURCE)
109
110 if($ENV{CLION_IDE})
@@ -181,9 +123,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN" OR "${CMAKE_SYSTEM_NAME}" STREQU
123
124 message(INFO " Compiling for Windows (${CMAKE_SYSTEM_NAME}, MSYSTEM=$ENV{MSYSTEM})... ")
125 else()
184 - set(FOREIGN_OS True)
185 - set(COMPILED_FOR_FOREIGN_OS True)
186 - message(WARNING " Compiling for Unknown O/S... (${CMAKE_SYSTEM_NAME})")
126 + message(FATAL_ERROR "Unknown/unsupported platform: ${CMAKE_SYSTEM_NAME} (Supported platforms: FreeBSD, Linux, macOS, Windows)")
127 endif()
128
129 # This is intended to make life easier for developers who are working on one
@@ -293,6 +233,10 @@ if(ENABLE_PLUGIN_EBPF)
233 include(NetdataLibBPF)
234 include(NetdataEBPFCORE)
235
236 + if(NOT OS_LINUX)
237 + message(FATAL_ERROR "The eBPF plugin is not supported on non-Linux systems")
238 + endif()
239 +
240 netdata_bundle_libbpf()
241 netdata_fetch_ebpf_co_re()
242 endif()
@@ -555,7 +499,7 @@ int my_function() {
499 }
500 " HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT)
501
558 -if(FREEBSD OR MACOS)
502 +if(OS_FREEBSD OR OS_MACOS)
503 set(HAVE_BUILTIN_ATOMICS True)
504 endif()
505
@@ -564,7 +508,7 @@ set(ENABLE_OPENSSL True)
508 pkg_check_modules(TLS IMPORTED_TARGET openssl)
509
510 if(NOT TARGET PkgConfig::TLS)
567 - if(MACOS)
511 + if(OS_MACOS)
512 execute_process(COMMAND
513 brew --prefix --installed openssl
514 RESULT_VARIABLE BREW_OPENSSL
@@ -592,7 +536,6 @@ else()
536 pkg_check_modules(CRYPTO IMPORTED_TARGET REQUIRED libcrypto)
537 endif()
538
595 -
539 #
540 # figure out if we need protoc/protobuf
541 #
@@ -1441,7 +1384,7 @@ set(NETDATA_FILES
1384 ${PROFILE_PLUGIN_FILES}
1385 )
1386
1444 -if(LINUX)
1387 +if(OS_LINUX)
1388 list(APPEND NETDATA_FILES
1389 src/daemon/static_threads_linux.c
1390 ${CGROUPS_PLUGIN_FILES}
@@ -1457,21 +1400,21 @@ if(LINUX)
1400 src/daemon/sentry-native/sentry-native.c
1401 src/daemon/sentry-native/sentry-native.h)
1402 endif()
1460 -elseif(MACOS)
1403 +elseif(OS_MACOS)
1404 list(APPEND NETDATA_FILES
1405 src/daemon/static_threads_macos.c
1406 ${MACOS_PLUGIN_FILES}
1407 ${TIMEX_PLUGIN_FILES}
1408 ${INTERNAL_COLLECTORS_FILES}
1409 )
1467 -elseif(FREEBSD)
1410 +elseif(OS_FREEBSD)
1411 list(APPEND NETDATA_FILES
1412 src/daemon/static_threads_freebsd.c
1413 ${FREEBSD_PLUGIN_FILES}
1414 ${TIMEX_PLUGIN_FILES}
1415 ${INTERNAL_COLLECTORS_FILES}
1416 )
1474 -elseif(WINDOWS)
1417 +elseif(OS_WINDOWS)
1418 list(APPEND NETDATA_FILES
1419 src/daemon/static_threads_windows.c
1420 ${WINDOWS_PLUGIN_FILES}
@@ -1631,7 +1574,7 @@ set_source_files_properties(JudyLTables.c PROPERTIES COMPILE_OPTIONS "-I${CMAKE_
1574 # build libnetdata
1575 #
1576
1634 -if(LINUX)
1577 +if(OS_LINUX)
1578 include(NetdataDetectSystemd)
1579 detect_systemd()
1580 endif()
@@ -1651,8 +1594,8 @@ target_include_directories(libnetdata BEFORE PUBLIC ${CONFIG_H_DIR} ${CMAKE_SOUR
1594
1595 target_link_libraries(libnetdata PUBLIC
1596 "$<$<NOT:$<BOOL:${HAVE_BUILTIN_ATOMICS}>>:atomic>"
1654 - "$<$<OR:$<BOOL:${LINUX}>,$<BOOL:${FREEBSD}>>:pthread;rt>"
1655 - "$<$<BOOL:${WINDOWS}>:kernel32;advapi32;winmm;rpcrt4>"
1597 + "$<$<OR:$<BOOL:${OS_LINUX}>,$<BOOL:${OS_FREEBSD}>>:pthread;rt>"
1598 + "$<$<BOOL:${OS_WINDOWS}>:kernel32;advapi32;winmm;rpcrt4>"
1599 "$<$<BOOL:${LINK_LIBM}>:m>"
1600 "${SYSTEMD_LDFLAGS}")
1601
@@ -1669,7 +1612,7 @@ netdata_add_jsonc_to_target(libnetdata)
1612 netdata_add_libyaml_to_target(libnetdata)
1613
1614 # zlib
1672 -if(MACOS)
1615 +if(OS_MACOS)
1616 find_package(ZLIB REQUIRED)
1617 target_include_directories(libnetdata BEFORE PUBLIC ${ZLIB_INCLUDE_DIRS})
1618 target_link_libraries(libnetdata PUBLIC ZLIB::ZLIB)
@@ -1713,7 +1656,7 @@ if(LIBBROTLI_FOUND)
1656 endif()
1657
1658 # uuid
1716 -if(MACOS OR WINDOWS)
1659 +if(OS_MACOS OR OS_WINDOWS)
1660 # UUID functionality is part of the system libraries here, so no extra
1661 # stuff needed.
1662 else()
@@ -1736,7 +1679,7 @@ target_link_libraries(libnetdata PUBLIC PkgConfig::CRYPTO)
1679 target_link_libraries(libnetdata PUBLIC PkgConfig::TLS)
1680
1681 # mnl
1739 -if(NOT MACOS)
1682 +if(NOT OS_MACOS)
1683 pkg_check_modules(MNL libmnl)
1684 if(MNL_FOUND)
1685 set(HAVE_LIBMNL True)
@@ -1751,12 +1694,6 @@ if (ENABLE_H2O OR ENABLE_ACLK)
1694 endif()
1695
1696 if(ENABLE_MQTTWEBSOCKETS)
1754 - # include_directories(BEFORE
1755 - # ${CMAKE_SOURCE_DIR}/aclk/mqtt_websockets/src/include
1756 - # ${CMAKE_SOURCE_DIR}/aclk/mqtt_websockets/c-rbuf/include
1757 - # ${CMAKE_SOURCE_DIR}/aclk/mqtt_websockets/c_rhash/include
1758 - # )
1759 -
1697 add_library(mqttwebsockets STATIC ${MQTT_WEBSOCKETS_FILES})
1698
1699 target_compile_options(mqttwebsockets PUBLIC -DMQTT_WSS_CUSTOM_ALLOC
@@ -2300,11 +2237,11 @@ target_include_directories(netdata PRIVATE
2237 target_link_libraries(netdata PRIVATE
2238 m
2239 libnetdata
2303 - "$<$<BOOL:${LINUX}>:rt>"
2240 + "$<$<BOOL:${OS_LINUX}>:rt>"
2241 "$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:mqttwebsockets>"
2242 "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_LIBRARIES}>"
2243 "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_LIBRARIES}>"
2307 - "$<$<BOOL:${MACOS}>:${IOKIT};${FOUNDATION}>"
2244 + "$<$<BOOL:${OS_MACOS}>:${IOKIT};${FOUNDATION}>"
2245 "$<$<BOOL:${ENABLE_SENTRY}>:sentry>"
2246 "$<$<BOOL:${ENABLE_WEBRTC}>:LibDataChannel::LibDataChannelStatic>"
2247 "$<$<BOOL:${ENABLE_H2O}>:h2o>"
@@ -3048,7 +2985,7 @@ install(FILES
2985 COMPONENT netdata
2986 DESTINATION ${WEB_DEST}/.well-known/dnt)
2987
3051 -if(NOT WINDOWS)
2988 +if(NOT OS_WINDOWS)
2989 # v0 dashboard
2990 install(FILES
2991 src/web/gui/v0/index.html
packaging/cmake/Modules/NetdataProtobuf.cmake
+1 -1
@@ -56,7 +56,7 @@ endfunction()
56
57 # Handle detection of Protobuf
58 macro(netdata_detect_protobuf)
59 - if(COMPILED_FOR_WINDOWS)
59 + if(OS_WINDOWS)
60 set(PROTOBUF_PROTOC_EXECUTABLE "$ENV{PROTOBUF_PROTOC_EXECUTABLE}")
61 if(NOT PROTOBUF_PROTOC_EXECUTABLE)
62 set(PROTOBUF_PROTOC_EXECUTABLE "/bin/protoc")
packaging/cmake/Modules/NetdataVersion.cmake new
+51
@@ -0,0 +1,51 @@
1 +# Copyright (c) 2024 Netdata Inc.
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +
4 +# Function to provide information regarding the Netdata version.
5 +#
6 +# The high-level logic is (a) use git-describe, (b) fallback to info from
7 +# packaging/version. This version field are used for cmake's project,
8 +# cpack's packaging, and the agent's functionality.
9 +function(netdata_version)
10 + find_package(Git)
11 +
12 + if(GIT_EXECUTABLE)
13 + execute_process(COMMAND ${GIT_EXECUTABLE} describe
14 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
15 + RESULT_VARIABLE GIT_DESCRIBE_RESULT
16 + OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT)
17 + if(GIT_DESCRIBE_RESULT)
18 + file(STRINGS "${CMAKE_SOURCE_DIR}/packaging/version" GIT_DESCRIBE_OUTPUT)
19 + message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
20 + endif()
21 + else()
22 + file(STRINGS packaging/version GIT_DESCRIBE_OUTPUT)
23 + message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
24 + endif()
25 +
26 + string(STRIP ${GIT_DESCRIBE_OUTPUT} GIT_DESCRIBE_OUTPUT)
27 + set(GIT_DESCRIBE_OUTPUT "${GIT_DESCRIBE_OUTPUT}" PARENT_SCOPE)
28 +
29 + string(REGEX MATCH "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-?([0-9]+)?-?([0-9a-zA-Z]+)?" MATCHES "${GIT_DESCRIBE_OUTPUT}")
30 + if(CMAKE_MATCH_COUNT EQUAL 3)
31 + set(NETDATA_VERSION_MAJOR ${CMAKE_MATCH_1} PARENT_SCOPE)
32 + set(NETDATA_VERSION_MINOR ${CMAKE_MATCH_2} PARENT_SCOPE)
33 + set(NETDATA_VERSION_PATCH ${CMAKE_MATCH_3} PARENT_SCOPE)
34 + set(NETDATA_VERSION_TWEAK 0 PARENT_SCOPE)
35 + set(NETDATA_VERSION_DESCR "N/A" PARENT_SCOPE)
36 + elseif(CMAKE_MATCH_COUNT EQUAL 4)
37 + set(NETDATA_VERSION_MAJOR ${CMAKE_MATCH_1} PARENT_SCOPE)
38 + set(NETDATA_VERSION_MINOR ${CMAKE_MATCH_2} PARENT_SCOPE)
39 + set(NETDATA_VERSION_PATCH ${CMAKE_MATCH_3} PARENT_SCOPE)
40 + set(NETDATA_VERSION_TWEAK ${CMAKE_MATCH_4} PARENT_SCOPE)
41 + set(NETDATA_VERSION_DESCR "N/A" PARENT_SCOPE)
42 + elseif(CMAKE_MATCH_COUNT EQUAL 5)
43 + set(NETDATA_VERSION_MAJOR ${CMAKE_MATCH_1} PARENT_SCOPE)
44 + set(NETDATA_VERSION_MINOR ${CMAKE_MATCH_2} PARENT_SCOPE)
45 + set(NETDATA_VERSION_PATCH ${CMAKE_MATCH_3} PARENT_SCOPE)
46 + set(NETDATA_VERSION_TWEAK ${CMAKE_MATCH_4} PARENT_SCOPE)
47 + set(NETDATA_VERSION_DESCR ${CMAKE_MATCH_5} PARENT_SCOPE)
48 + else()
49 + message(FATAL_ERROR "Wrong version regex match count ${CMAKE_MATCH_COUNT} (should be in 3, 4 or 5)")
50 + endif()
51 +endfunction()
packaging/cmake/Modules/Packaging.cmake
+6
@@ -2,6 +2,12 @@
2 # CPack options
3 #
4
5 +if(NETDATA_VERSION_DESCR STREQUAL "N/A")
6 + set(CPACK_PACKAGE_VERSION ${NETDATA_VERSION_MAJOR}.${NETDATA_VERSION_MINOR}.${NETDATA_VERSION_PATCH})
7 +else()
8 + set(CPACK_PACKAGE_VERSION ${NETDATA_VERSION_MAJOR}.${NETDATA_VERSION_MINOR}.${NETDATA_VERSION_PATCH}-${NETDATA_VERSION_TWEAK}-${NETDATA_VERSION_DESCR})
9 +endif()
10 +
11 set(CPACK_THREADS 0)
12
13 set(CPACK_STRIP_FILES NO)
packaging/cmake/config.cmake.h.in
+11 -6
@@ -9,11 +9,10 @@
9 #cmakedefine SIZEOF_VOID_P ${SIZEOF_VOID_P}
10
11 // platform
12 -#cmakedefine COMPILED_FOR_FREEBSD
13 -#cmakedefine COMPILED_FOR_LINUX
14 -#cmakedefine COMPILED_FOR_MACOS
15 -#cmakedefine COMPILED_FOR_WINDOWS
16 -#cmakedefine COMPILED_FOR_FOREIGN_OS
12 +#cmakedefine OS_FREEBSD
13 +#cmakedefine OS_LINUX
14 +#cmakedefine OS_MACOS
15 +#cmakedefine OS_WINDOWS
16
17 // checked headers
18
@@ -161,7 +160,13 @@
160 #cmakedefine CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
161 #cmakedefine NETDATA_USER "@NETDATA_USER@"
162
164 -#cmakedefine VERSION "@GIT_DESCRIBE_OUTPUT@"
163 +#define NETDATA_VERSION_MAJOR "@NETDATA_VERSION_MAJOR@"
164 +#define NETDATA_VERSION_MINOR "@NETDATA_VERSION_MINOR@"
165 +#define NETDATA_VERSION_PATCH "@NETDATA_VERSION_PATCH@"
166 +#define NETDATA_VERSION_TWEAK "@NETDATA_VERSION_TWEAK@"
167 +#define NETDATA_VERSION_DESCR "@NETDATA_VERSION_DESCR@"
168 +
169 +#define NETDATA_VERSION "@GIT_DESCRIBE_OUTPUT@"
170
171 #define ENABLE_JSONC 1
172
src/aclk/aclk_otp.c
+1 -1
@@ -839,7 +839,7 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
839 return 1;
840 }
841
842 - buffer_sprintf(buf, "/api/v1/env?v=%s&cap=proto,ctx&claim_id=%s", &(VERSION[1]) /* skip 'v' at beginning */, agent_id);
842 + buffer_sprintf(buf, "/api/v1/env?v=%s&cap=proto,ctx&claim_id=%s", &(NETDATA_VERSION[1]) /* skip 'v' at beginning */, agent_id);
843
844 freez(agent_id);
845
src/collectors/apps.plugin/apps_plugin.c
+2 -2
@@ -729,7 +729,7 @@ static void parse_args(int argc, char **argv)
729 }
730
731 if(strcmp("version", argv[i]) == 0 || strcmp("-version", argv[i]) == 0 || strcmp("--version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
732 - printf("apps.plugin %s\n", VERSION);
732 + printf("apps.plugin %s\n", NETDATA_VERSION);
733 exit(0);
734 }
735
@@ -863,7 +863,7 @@ static void parse_args(int argc, char **argv)
863 #endif
864 " version or -v or -V print program version and exit\n"
865 "\n"
866 - , VERSION
866 + , NETDATA_VERSION
867 #if !defined(__FreeBSD__) && !defined(__APPLE__)
868 , max_fds_cache_seconds
869 #endif
src/collectors/cgroups.plugin/cgroup-network.c
+1 -2
@@ -648,7 +648,6 @@ void usage(void) {
648 int main(int argc, char **argv) {
649 pid_t pid = 0;
650
651 - program_version = VERSION;
651 clocks_init();
652 nd_log_initialize_for_external_plugins("cgroup-network");
653
@@ -686,7 +685,7 @@ int main(int argc, char **argv) {
685 // ------------------------------------------------------------------------
686
687 if(argc == 2 && (!strcmp(argv[1], "version") || !strcmp(argv[1], "-version") || !strcmp(argv[1], "--version") || !strcmp(argv[1], "-v") || !strcmp(argv[1], "-V"))) {
689 - fprintf(stderr, "cgroup-network %s\n", VERSION);
688 + fprintf(stderr, "cgroup-network %s\n", NETDATA_VERSION);
689 exit(0);
690 }
691
src/collectors/common-contexts/system.ram.h
+68 -68
@@ -1,68 +1,68 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#ifndef NETDATA_SYSTEM_RAM_H
4 -#define NETDATA_SYSTEM_RAM_H
5 -
6 -#include "common-contexts.h"
7 -
8 -#define _system_ram_chart() \
9 - rrdset_create_localhost( \
10 - "system" \
11 - , "ram" \
12 - , NULL \
13 - , "ram" \
14 - , NULL \
15 - , "System RAM" \
16 - , "MiB" \
17 - , _COMMON_PLUGIN_NAME \
18 - , _COMMON_PLUGIN_MODULE_NAME \
19 - , NETDATA_CHART_PRIO_SYSTEM_RAM \
20 - , update_every \
21 - , RRDSET_TYPE_STACKED \
22 - )
23 -
24 -#if defined(COMPILED_FOR_WINDOWS)
25 -static inline void common_system_ram(uint64_t free_bytes, uint64_t used_bytes, int update_every) {
26 - static RRDSET *st_system_ram = NULL;
27 - static RRDDIM *rd_free = NULL;
28 - static RRDDIM *rd_used = NULL;
29 -
30 - if(unlikely(!st_system_ram)) {
31 - st_system_ram = _system_ram_chart();
32 - rd_free = rrddim_add(st_system_ram, "free", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
33 - rd_used = rrddim_add(st_system_ram, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
34 - }
35 -
36 - // this always have to be in base units, so that exporting sends base units to other time-series db
37 - rrddim_set_by_pointer(st_system_ram, rd_free, (collected_number)free_bytes);
38 - rrddim_set_by_pointer(st_system_ram, rd_used, (collected_number)used_bytes);
39 - rrdset_done(st_system_ram);
40 -}
41 -#endif
42 -
43 -#if defined(COMPILED_FOR_LINUX)
44 -static inline void common_system_ram(uint64_t free_bytes, uint64_t used_bytes, uint64_t cached_bytes, uint64_t buffers_bytes, int update_every) {
45 - static RRDSET *st_system_ram = NULL;
46 - static RRDDIM *rd_free = NULL;
47 - static RRDDIM *rd_used = NULL;
48 - static RRDDIM *rd_cached = NULL;
49 - static RRDDIM *rd_buffers = NULL;
50 -
51 - if(unlikely(!st_system_ram)) {
52 - st_system_ram = _system_ram_chart();
53 - rd_free = rrddim_add(st_system_ram, "free", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
54 - rd_used = rrddim_add(st_system_ram, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
55 - rd_cached = rrddim_add(st_system_ram, "cached", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
56 - rd_buffers = rrddim_add(st_system_ram, "buffers", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
57 - }
58 -
59 - // this always have to be in base units, so that exporting sends base units to other time-series db
60 - rrddim_set_by_pointer(st_system_ram, rd_free, (collected_number)free_bytes);
61 - rrddim_set_by_pointer(st_system_ram, rd_used, (collected_number)used_bytes);
62 - rrddim_set_by_pointer(st_system_ram, rd_cached, (collected_number)cached_bytes);
63 - rrddim_set_by_pointer(st_system_ram, rd_buffers, (collected_number)buffers_bytes);
64 - rrdset_done(st_system_ram);
65 -}
66 -#endif
67 -
68 -#endif //NETDATA_SYSTEM_RAM_H
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#ifndef NETDATA_SYSTEM_RAM_H
4 +#define NETDATA_SYSTEM_RAM_H
5 +
6 +#include "common-contexts.h"
7 +
8 +#define _system_ram_chart() \
9 + rrdset_create_localhost( \
10 + "system" \
11 + , "ram" \
12 + , NULL \
13 + , "ram" \
14 + , NULL \
15 + , "System RAM" \
16 + , "MiB" \
17 + , _COMMON_PLUGIN_NAME \
18 + , _COMMON_PLUGIN_MODULE_NAME \
19 + , NETDATA_CHART_PRIO_SYSTEM_RAM \
20 + , update_every \
21 + , RRDSET_TYPE_STACKED \
22 + )
23 +
24 +#ifdef OS_WINDOWS
25 +static inline void common_system_ram(uint64_t free_bytes, uint64_t used_bytes, int update_every) {
26 + static RRDSET *st_system_ram = NULL;
27 + static RRDDIM *rd_free = NULL;
28 + static RRDDIM *rd_used = NULL;
29 +
30 + if(unlikely(!st_system_ram)) {
31 + st_system_ram = _system_ram_chart();
32 + rd_free = rrddim_add(st_system_ram, "free", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
33 + rd_used = rrddim_add(st_system_ram, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
34 + }
35 +
36 + // this always have to be in base units, so that exporting sends base units to other time-series db
37 + rrddim_set_by_pointer(st_system_ram, rd_free, (collected_number)free_bytes);
38 + rrddim_set_by_pointer(st_system_ram, rd_used, (collected_number)used_bytes);
39 + rrdset_done(st_system_ram);
40 +}
41 +#endif
42 +
43 +#ifdef OS_LINUX
44 +static inline void common_system_ram(uint64_t free_bytes, uint64_t used_bytes, uint64_t cached_bytes, uint64_t buffers_bytes, int update_every) {
45 + static RRDSET *st_system_ram = NULL;
46 + static RRDDIM *rd_free = NULL;
47 + static RRDDIM *rd_used = NULL;
48 + static RRDDIM *rd_cached = NULL;
49 + static RRDDIM *rd_buffers = NULL;
50 +
51 + if(unlikely(!st_system_ram)) {
52 + st_system_ram = _system_ram_chart();
53 + rd_free = rrddim_add(st_system_ram, "free", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
54 + rd_used = rrddim_add(st_system_ram, "used", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
55 + rd_cached = rrddim_add(st_system_ram, "cached", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
56 + rd_buffers = rrddim_add(st_system_ram, "buffers", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
57 + }
58 +
59 + // this always have to be in base units, so that exporting sends base units to other time-series db
60 + rrddim_set_by_pointer(st_system_ram, rd_free, (collected_number)free_bytes);
61 + rrddim_set_by_pointer(st_system_ram, rd_used, (collected_number)used_bytes);
62 + rrddim_set_by_pointer(st_system_ram, rd_cached, (collected_number)cached_bytes);
63 + rrddim_set_by_pointer(st_system_ram, rd_buffers, (collected_number)buffers_bytes);
64 + rrdset_done(st_system_ram);
65 +}
66 +#endif
67 +
68 +#endif //NETDATA_SYSTEM_RAM_H
src/collectors/cups.plugin/cups_plugin.c
+2 -2
@@ -72,7 +72,7 @@ void print_help() {
72 "\n"
73 " -h print this message and exit\n"
74 "\n",
75 - VERSION);
75 + NETDATA_VERSION);
76 }
77
78 void parse_command_line(int argc, char **argv) {
@@ -87,7 +87,7 @@ void parse_command_line(int argc, char **argv) {
87 continue;
88 }
89 } else if (strcmp("-v", argv[i]) == 0) {
90 - printf("cups.plugin %s\n", VERSION);
90 + printf("cups.plugin %s\n", NETDATA_VERSION);
91 exit(0);
92 } else if (strcmp("-d", argv[i]) == 0) {
93 debug = 1;
src/collectors/ebpf.plugin/ebpf.c
+2 -2
@@ -2272,7 +2272,7 @@ void ebpf_print_help()
2272 "\n"
2273 " [-]-core Use CO-RE when available(Working in progress).\n"
2274 "\n",
2275 - VERSION,
2275 + NETDATA_VERSION,
2276 (year >= 116) ? year + 1900 : 2020);
2277 }
2278
@@ -3249,7 +3249,7 @@ static void ebpf_parse_args(int argc, char **argv)
3249 break;
3250 }
3251 case EBPF_OPTION_VERSION: {
3252 - printf("ebpf.plugin %s\n", VERSION);
3252 + printf("ebpf.plugin %s\n", NETDATA_VERSION);
3253 exit(0);
3254 }
3255 case EBPF_OPTION_HELP: {
src/collectors/freeipmi.plugin/freeipmi_plugin.c
+2 -2
@@ -1665,7 +1665,7 @@ int main (int argc, char **argv) {
1665 }
1666 }
1667 else if(strcmp("version", argv[i]) == 0 || strcmp("-version", argv[i]) == 0 || strcmp("--version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
1668 - printf("%s %s\n", program_name, VERSION);
1668 + printf("%s %s\n", program_name, NETDATA_VERSION);
1669 exit(0);
1670 }
1671 else if(strcmp("debug", argv[i]) == 0) {
@@ -1827,7 +1827,7 @@ int main (int argc, char **argv) {
1827 " For more information:\n"
1828 " https://github.com/netdata/netdata/tree/master/src/collectors/freeipmi.plugin\n"
1829 "\n"
1830 - , program_name, VERSION
1830 + , program_name, NETDATA_VERSION
1831 , update_every
1832 , netdata_do_sel?"enabled":"disabled"
1833 , sdr_cache_directory?sdr_cache_directory:"system default"
src/collectors/log2journal/log2journal-help.c
+1 -1
@@ -44,7 +44,7 @@ static void config_dir_print_available(void) {
44
45 void log_job_command_line_help(const char *name) {
46 printf("\n");
47 - printf("Netdata log2journal " VERSION "\n");
47 + printf("Netdata log2journal " NETDATA_VERSION "\n");
48 printf("\n");
49 printf("Convert logs to systemd Journal Export Format.\n");
50 printf("\n");
src/collectors/nfacct.plugin/plugin_nfacct.c
+2 -2
@@ -763,7 +763,7 @@ int main(int argc, char **argv) {
763 }
764 }
765 else if(strcmp("version", argv[i]) == 0 || strcmp("-version", argv[i]) == 0 || strcmp("--version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
766 - printf("nfacct.plugin %s\n", VERSION);
766 + printf("nfacct.plugin %s\n", NETDATA_VERSION);
767 exit(0);
768 }
769 else if(strcmp("debug", argv[i]) == 0) {
@@ -798,7 +798,7 @@ int main(int argc, char **argv) {
798 " For more information:\n"
799 " https://github.com/netdata/netdata/tree/master/src/collectors/nfacct.plugin\n"
800 "\n"
801 - , VERSION
801 + , NETDATA_VERSION
802 , netdata_update_every
803 );
804 exit(1);
src/collectors/perf.plugin/perf_plugin.c
+2 -2
@@ -1093,7 +1093,7 @@ void parse_command_line(int argc, char **argv) {
1093 }
1094 }
1095 else if(strcmp("version", argv[i]) == 0 || strcmp("-version", argv[i]) == 0 || strcmp("--version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
1096 - printf("perf.plugin %s\n", VERSION);
1096 + printf("perf.plugin %s\n", NETDATA_VERSION);
1097 exit(0);
1098 }
1099 else if(strcmp("all", argv[i]) == 0) {
@@ -1266,7 +1266,7 @@ void parse_command_line(int argc, char **argv) {
1266 " For more information:\n"
1267 " https://github.com/netdata/netdata/tree/master/src/collectors/perf.plugin\n"
1268 "\n"
1269 - , VERSION
1269 + , NETDATA_VERSION
1270 , update_every
1271 );
1272 exit(1);
src/collectors/plugins.d/pluginsd_parser.c
+1 -1
@@ -185,7 +185,7 @@ static inline PARSER_RC pluginsd_host_define_end(char **words __maybe_unused, si
185 netdata_configured_abbrev_timezone,
186 netdata_configured_utc_offset,
187 program_name,
188 - program_version,
188 + NETDATA_VERSION,
189 default_rrd_update_every,
190 default_rrd_history_entries,
191 default_rrd_memory_mode,
src/collectors/slabinfo.plugin/slabinfo.c
+1 -3
@@ -343,8 +343,6 @@ int main(int argc, char **argv) {
343 nd_log_initialize_for_external_plugins("slabinfo.plugin");
344
345 program_name = argv[0];
346 - program_version = "0.1";
347 -
346 int update_every = 1, i, n, freq = 0;
347
348 for (i = 1; i < argc; i++) {
@@ -376,7 +374,7 @@ int main(int argc, char **argv) {
374 " debug enable verbose output\n"
375 " default: disabled\n"
376 "\n",
379 - program_version,
377 + NETDATA_VERSION,
378 update_every
379 );
380 exit(1);
src/collectors/xenstat.plugin/xenstat_plugin.c
+2 -2
@@ -942,7 +942,7 @@ int main(int argc, char **argv) {
942 }
943 }
944 else if(strcmp("version", argv[i]) == 0 || strcmp("-version", argv[i]) == 0 || strcmp("--version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
945 - printf("xenstat.plugin %s\n", VERSION);
945 + printf("xenstat.plugin %s\n", NETDATA_VERSION);
946 exit(0);
947 }
948 else if(strcmp("debug", argv[i]) == 0) {
@@ -977,7 +977,7 @@ int main(int argc, char **argv) {
977 " For more information:\n"
978 " https://github.com/netdata/netdata/tree/master/src/collectors/xenstat.plugin\n"
979 "\n"
980 - , VERSION
980 + , NETDATA_VERSION
981 , netdata_update_every
982 );
983 exit(1);
src/daemon/analytics.c
+1 -1
@@ -842,7 +842,7 @@ void set_global_environment() {
842 setenv("NETDATA_UPDATE_EVERY", b, 1);
843 }
844
845 - setenv("NETDATA_VERSION", program_version, 1);
845 + setenv("NETDATA_VERSION", NETDATA_VERSION, 1);
846 setenv("NETDATA_HOSTNAME", netdata_configured_hostname, 1);
847 setenv("NETDATA_CONFIG_DIR", verify_required_directory(netdata_configured_user_config_dir), 1);
848 setenv("NETDATA_USER_CONFIG_DIR", verify_required_directory(netdata_configured_user_config_dir), 1);
src/daemon/buildinfo.c
+5 -5
@@ -1037,10 +1037,10 @@ static void build_info_set_status(BUILD_INFO_SLOT slot, bool status) {
1037 }
1038
1039 __attribute__((constructor)) void initialize_build_info(void) {
1040 - build_info_set_value(BIB_PACKAGING_NETDATA_VERSION, program_version);
1040 + build_info_set_value(BIB_PACKAGING_NETDATA_VERSION, NETDATA_VERSION);
1041 build_info_set_value(BIB_PACKAGING_CONFIGURE_OPTIONS, CONFIGURE_COMMAND);
1042
1043 -#ifdef COMPILED_FOR_LINUX
1043 +#ifdef OS_LINUX
1044 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1045 build_info_set_value(BIB_FEATURE_BUILT_FOR, "Linux");
1046 build_info_set_status(BIB_PLUGIN_LINUX_CGROUPS, true);
@@ -1048,17 +1048,17 @@ __attribute__((constructor)) void initialize_build_info(void) {
1048 build_info_set_status(BIB_PLUGIN_LINUX_DISKSPACE, true);
1049 build_info_set_status(BIB_PLUGIN_LINUX_TC, true);
1050 #endif
1051 -#ifdef COMPILED_FOR_FREEBSD
1051 +#ifdef OS_FREEBSD
1052 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1053 build_info_set_value(BIB_FEATURE_BUILT_FOR, "FreeBSD");
1054 build_info_set_status(BIB_PLUGIN_FREEBSD, true);
1055 #endif
1056 -#ifdef COMPILED_FOR_MACOS
1056 +#ifdef OS_MACOS
1057 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1058 build_info_set_value(BIB_FEATURE_BUILT_FOR, "MacOS");
1059 build_info_set_status(BIB_PLUGIN_MACOS, true);
1060 #endif
1061 -#ifdef COMPILED_FOR_WINDOWS
1061 +#ifdef OS_WINDOWS
1062 build_info_set_status(BIB_FEATURE_BUILT_FOR, true);
1063 #if defined(__CYGWIN__) && defined(__MSYS__)
1064 build_info_set_value(BIB_FEATURE_BUILT_FOR, "Windows (MSYS)");
src/daemon/commands.c
+1 -1
@@ -318,7 +318,7 @@ static cmd_status_t cmd_version(char *args, char **message)
318 (void)args;
319
320 char version[MAX_COMMAND_LENGTH];
321 - snprintfz(version, MAX_COMMAND_LENGTH -1, "%s %s", program_name, program_version);
321 + snprintfz(version, MAX_COMMAND_LENGTH -1, "%s %s", program_name, NETDATA_VERSION);
322
323 *message = strdupz(version);
324
src/daemon/main.c
+6 -6
@@ -824,7 +824,7 @@ int help(int exitcode) {
824 " Check if string matches pattern and exit.\n\n"
825 " -W \"claim -token=TOKEN -rooms=ROOM1,ROOM2\"\n"
826 " Claim the agent to the workspace rooms pointed to by TOKEN and ROOM*.\n\n"
827 -#ifdef COMPILED_FOR_WINDOWS
827 +#ifdef OS_WINDOWS
828 " -W perflibdump [key]\n"
829 " Dump the Windows Performance Counters Registry in JSON.\n\n"
830 #endif
@@ -1390,7 +1390,7 @@ int uuid_unittest(void);
1390 int progress_unittest(void);
1391 int dyncfg_unittest(void);
1392
1393 -#ifdef COMPILED_FOR_WINDOWS
1393 +#ifdef OS_WINDOWS
1394 int windows_perflib_dump(const char *key);
1395 #endif
1396
@@ -1501,7 +1501,7 @@ int main(int argc, char **argv) {
1501 break;
1502 case 'v':
1503 case 'V':
1504 - printf("%s %s\n", program_name, program_version);
1504 + printf("%s %s\n", program_name, NETDATA_VERSION);
1505 return 0;
1506 case 'W':
1507 {
@@ -1601,7 +1601,7 @@ int main(int argc, char **argv) {
1601 unittest_running = true;
1602 return uuid_unittest();
1603 }
1604 -#ifdef COMPILED_FOR_WINDOWS
1604 +#ifdef OS_WINDOWS
1605 else if(strcmp(optarg, "perflibdump") == 0) {
1606 return windows_perflib_dump(optind + 1 > argc ? NULL : argv[optind]);
1607 }
@@ -1996,7 +1996,7 @@ int main(int argc, char **argv) {
1996
1997 // initialize the log files
1998 nd_log_initialize();
1999 - netdata_log_info("Netdata agent version \""VERSION"\" is starting");
1999 + netdata_log_info("Netdata agent version '%s' is starting", NETDATA_VERSION);
2000
2001 ieee754_doubles = is_system_ieee754_double();
2002 if(!ieee754_doubles)
@@ -2126,7 +2126,7 @@ int main(int argc, char **argv) {
2126
2127 delta_startup_time("become daemon");
2128
2129 -#if defined(COMPILED_FOR_LINUX) || defined(COMPILED_FOR_MACOS) || defined(COMPILED_FOR_FREEBSD)
2129 +#if defined(OS_LINUX) || defined(OS_MACOS) || defined(OS_FREEBSD)
2130 // fork, switch user, create pid file, set process priority
2131 if(become_daemon(dont_fork, user) == -1)
2132 fatal("Cannot daemonize myself.");
src/daemon/static_threads.c
+1 -1
@@ -105,7 +105,7 @@ const struct netdata_static_thread static_threads_common[] = {
105 .init_routine = NULL,
106 .start_routine = statsd_main
107 },
108 -#ifndef COMPILED_FOR_WINDOWS
108 +#ifndef OS_WINDOWS
109 // this crashes the debugger under windows
110 {
111 .name = "EXPORTING",
src/database/engine/dbengine-stresstest.c
+2 -2
@@ -17,7 +17,7 @@ static RRDHOST *dbengine_rrdhost_find_or_create(char *name) {
17 netdata_configured_abbrev_timezone,
18 netdata_configured_utc_offset,
19 program_name,
20 - program_version,
20 + NETDATA_VERSION,
21 default_rrd_update_every,
22 default_rrd_history_entries,
23 RRD_MEMORY_MODE_DBENGINE,
@@ -453,4 +453,4 @@ void dbengine_stress_test(unsigned TEST_DURATION_SEC, unsigned DSET_CHARTS, unsi
453 rrd_wrunlock();
454 }
455
456 -#endif
\ No newline at end of file
456 +#endif
src/database/engine/dbengine-unittest.c
+1 -1
@@ -103,7 +103,7 @@ static RRDHOST *dbengine_rrdhost_find_or_create(char *name) {
103 netdata_configured_abbrev_timezone,
104 netdata_configured_utc_offset,
105 program_name,
106 - program_version,
106 + NETDATA_VERSION,
107 default_rrd_update_every,
108 default_rrd_history_entries,
109 RRD_MEMORY_MODE_DBENGINE,
src/database/rrdhost.c
+1 -1
@@ -1049,7 +1049,7 @@ int rrd_init(char *hostname, struct rrdhost_system_info *system_info, bool unitt
1049 , netdata_configured_abbrev_timezone
1050 , netdata_configured_utc_offset
1051 , program_name
1052 - , program_version
1052 + , NETDATA_VERSION
1053 , default_rrd_update_every
1054 , default_rrd_history_entries
1055 , default_rrd_memory_mode
src/database/sqlite/sqlite_aclk_node.c
+1 -1
@@ -82,7 +82,7 @@ static void build_node_info(RRDHOST *host)
82 node_info.data.cpu_frequency = host->system_info->host_cpu_freq ? host->system_info->host_cpu_freq : "0";
83 node_info.data.memory = host->system_info->host_ram_total ? host->system_info->host_ram_total : "0";
84 node_info.data.disk_space = host->system_info->host_disk_space ? host->system_info->host_disk_space : "0";
85 - node_info.data.version = host_version ? host_version : VERSION;
85 + node_info.data.version = host_version ? host_version : NETDATA_VERSION;
86 node_info.data.release_channel = get_release_channel();
87 node_info.data.timezone = rrdhost_abbrev_timezone(host);
88 node_info.data.virtualization_type = host->system_info->virtualization ? host->system_info->virtualization : "unknown";
src/libnetdata/libnetdata.c
-1
@@ -19,7 +19,6 @@ int enable_ksm = 0;
19 #endif
20
21 volatile sig_atomic_t netdata_exit = 0;
22 -const char *program_version = VERSION;
22
23 #define MAX_JUDY_SIZE_TO_ARAL 24
24 static bool judy_sizes_config[MAX_JUDY_SIZE_TO_ARAL + 1] = {
src/libnetdata/libnetdata.h
+1 -3
@@ -76,7 +76,7 @@ extern "C" {
76 #define NETDATA_OS_TYPE "freebsd"
77 #elif defined(__APPLE__)
78 #define NETDATA_OS_TYPE "macos"
79 -#elif defined(COMPILED_FOR_WINDOWS)
79 +#elif defined(OS_WINDOWS)
80 #define NETDATA_OS_TYPE "windows"
81 #else
82 #define NETDATA_OS_TYPE "linux"
@@ -391,8 +391,6 @@ int verify_netdata_host_prefix(bool log_msg);
391
392 extern volatile sig_atomic_t netdata_exit;
393
394 -extern const char *program_version;
395 -
394 char *strdupz_path_subpath(const char *path, const char *subpath);
395 int path_is_dir(const char *path, const char *subpath);
396 int path_is_file(const char *path, const char *subpath);
src/libnetdata/log/systemd-cat-native.c
+1 -1
@@ -436,7 +436,7 @@ cleanup:
436 static int help(void) {
437 fprintf(stderr,
438 "\n"
439 - "Netdata systemd-cat-native " VERSION "\n"
439 + "Netdata systemd-cat-native " NETDATA_VERSION "\n"
440 "\n"
441 "This program reads from its standard input, lines in the format:\n"
442 "\n"
src/libnetdata/os/adjtimex.c
+2 -2
@@ -3,11 +3,11 @@
3 #include "../libnetdata.h"
4
5 int os_adjtimex(struct timex *buf __maybe_unused) {
6 -#if defined(COMPILED_FOR_MACOS) || defined(COMPILED_FOR_FREEBSD)
6 +#if defined(OS_MACOS) || defined(OS_FREEBSD)
7 return ntp_adjtime(buf);
8 #endif
9
10 -#if defined(COMPILED_FOR_LINUX)
10 +#if defined(OS_LINUX)
11 return adjtimex(buf);
12 #endif
13
src/libnetdata/os/adjtimex.h
+1 -1
@@ -3,7 +3,7 @@
3 #ifndef NETDATA_ADJTIMEX_H
4 #define NETDATA_ADJTIMEX_H
5
6 -#if defined(COMPILED_FOR_LINUX) || defined(COMPILED_FOR_FREEBSD) || defined(COMPILED_FOR_MACOS)
6 +#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_MACOS)
7 #include <sys/timex.h>
8 #endif
9
src/libnetdata/os/get_pid_max.c
+3 -3
@@ -4,14 +4,14 @@
4
5 pid_t pid_max = 32768;
6 pid_t os_get_system_pid_max(void) {
7 -#if defined(COMPILED_FOR_MACOS)
7 +#if defined(OS_MACOS)
8
9 // As we currently do not know a solution to query pid_max from the os
10 // we use the number defined in bsd/sys/proc_internal.h in XNU sources
11 pid_max = 99999;
12 return pid_max;
13
14 -#elif defined(COMPILED_FOR_FREEBSD)
14 +#elif defined(OS_FREEBSD)
15
16 int32_t tmp_pid_max;
17
@@ -24,7 +24,7 @@ pid_t os_get_system_pid_max(void) {
24
25 return pid_max;
26
27 -#elif defined(COMPILED_FOR_LINUX)
27 +#elif defined(OS_LINUX)
28
29 static char read = 0;
30 if(unlikely(read)) return pid_max;
src/libnetdata/os/get_system_cpus.c
+5 -5
@@ -2,7 +2,7 @@
2
3 #include "../libnetdata.h"
4
5 -#if defined(COMPILED_FOR_WINDOWS)
5 +#if defined(OS_WINDOWS)
6 #include <windows.h>
7 #endif
8
@@ -17,8 +17,8 @@ long os_get_system_cpus_cached(bool cache, bool for_netdata) {
17 if(likely(cache && processors[index] > 0))
18 return processors[index];
19
20 -#if defined(COMPILED_FOR_FREEBSD) || defined(COMPILED_FOR_MACOS)
21 -#if defined(COMPILED_FOR_MACOS)
20 +#if defined(OS_FREEBSD) || defined(OS_MACOS)
21 +#if defined(OS_MACOS)
22 #define HW_CPU_NAME "hw.logicalcpu"
23 #else
24 #define HW_CPU_NAME "hw.ncpu"
@@ -40,7 +40,7 @@ long os_get_system_cpus_cached(bool cache, bool for_netdata) {
40 }
41
42 return processors[index];
43 -#elif defined(COMPILED_FOR_LINUX)
43 +#elif defined(OS_LINUX)
44
45 char filename[FILENAME_MAX + 1];
46 snprintfz(filename, FILENAME_MAX, "%s/proc/stat",
@@ -78,7 +78,7 @@ long os_get_system_cpus_cached(bool cache, bool for_netdata) {
78 netdata_log_debug(D_SYSTEM, "System has %ld processors.", processors[index]);
79 return processors[index];
80
81 -#elif defined(COMPILED_FOR_WINDOWS)
81 +#elif defined(OS_WINDOWS)
82
83 SYSTEM_INFO sysInfo;
84 GetSystemInfo(&sysInfo);
src/libnetdata/os/getgrouplist.c
+2 -2
@@ -3,11 +3,11 @@
3 #include "../libnetdata.h"
4
5 int os_getgrouplist(const char *username __maybe_unused, gid_t gid __maybe_unused, gid_t *supplementary_groups __maybe_unused, int *ngroups __maybe_unused) {
6 -#if defined(COMPILED_FOR_LINUX) || defined(COMPILED_FOR_FREEBSD)
6 +#if defined(OS_LINUX) || defined(OS_FREEBSD)
7 return getgrouplist(username, gid, supplementary_groups, ngroups);
8 #endif
9
10 -#if defined(COMPILED_FOR_MACOS)
10 +#if defined(OS_MACOS)
11 return getgrouplist(username, gid, (int *)supplementary_groups, ngroups);
12 #endif
13
src/libnetdata/os/gettid.c
+3 -3
@@ -2,7 +2,7 @@
2
3 #include "../libnetdata.h"
4
5 -#if defined(COMPILED_FOR_WINDOWS)
5 +#if defined(OS_WINDOWS)
6 #include <windows.h>
7 #endif
8
@@ -15,9 +15,9 @@ pid_t os_gettid(void) {
15 uint64_t curthreadid;
16 pthread_threadid_np(NULL, &curthreadid);
17 return curthreadid;
18 -#elif defined(COMPILED_FOR_WINDOWS)
18 +#elif defined(OS_WINDOWS)
19 return (pid_t)GetCurrentThreadId();
20 -#elif defined(COMPILED_FOR_LINUX)
20 +#elif defined(OS_LINUX)
21 return (pid_t)syscall(SYS_gettid);
22 #else
23 return (pid_t)pthread_self();
src/libnetdata/os/os-freebsd-wrappers.c
+1 -1
@@ -2,7 +2,7 @@
2
3 #include "../libnetdata.h"
4
5 -#if defined(COMPILED_FOR_FREEBSD)
5 +#if defined(OS_FREEBSD)
6
7 int getsysctl_by_name(const char *name, void *ptr, size_t len) {
8 size_t nlen = len;
src/libnetdata/os/os-freebsd-wrappers.h
+1 -1
@@ -5,7 +5,7 @@
5
6 #include "../libnetdata.h"
7
8 -#if defined(COMPILED_FOR_FREEBSD)
8 +#if defined(OS_FREEBSD)
9 #include <sys/sysctl.h>
10
11 #define GETSYSCTL_BY_NAME(name, var) getsysctl_by_name(name, &(var), sizeof(var))
src/libnetdata/os/os-macos-wrappers.c
+1 -1
@@ -2,7 +2,7 @@
2
3 #include "../libnetdata.h"
4
5 -#if defined(COMPILED_FOR_MACOS)
5 +#if defined(OS_MACOS)
6
7 int getsysctl_by_name(const char *name, void *ptr, size_t len) {
8 size_t nlen = len;
src/libnetdata/os/os-macos-wrappers.h
+1 -1
@@ -5,7 +5,7 @@
5
6 #include "../libnetdata.h"
7
8 -#if defined(COMPILED_FOR_MACOS)
8 +#if defined(OS_MACOS)
9 #include <sys/sysctl.h>
10 #include "byteorder.h"
11
src/libnetdata/os/os.c
+4 -4
@@ -74,19 +74,19 @@ unsigned long os_read_cpuset_cpus(const char *filename, long system_cpus) {
74 // =====================================================================================================================
75 // os_type
76
77 -#if defined(COMPILED_FOR_LINUX)
77 +#if defined(OS_LINUX)
78 const char *os_type = "linux";
79 #endif
80
81 -#if defined(COMPILED_FOR_FREEBSD)
81 +#if defined(OS_FREEBSD)
82 const char *os_type = "freebsd";
83 #endif
84
85 -#if defined(COMPILED_FOR_MACOS)
85 +#if defined(OS_MACOS)
86 const char *os_type = "macos";
87 #endif
88
89 -#if defined(COMPILED_FOR_WINDOWS)
89 +#if defined(OS_WINDOWS)
90 const char *os_type = "windows";
91 #endif
92
src/libnetdata/os/os.h
+1 -1
@@ -3,7 +3,7 @@
3 #ifndef NETDATA_OS_H
4 #define NETDATA_OS_H
5
6 -#if defined(COMPILED_FOR_LINUX) || defined(COMPILED_FOR_FREEBSD) || defined(COMPILED_FOR_MACOS)
6 +#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_MACOS)
7 #include <sys/syscall.h>
8 #endif
9
src/libnetdata/os/setresgid.c
+2 -2
@@ -3,11 +3,11 @@
3 #include "../libnetdata.h"
4
5 int os_setresgid(gid_t gid __maybe_unused, gid_t egid __maybe_unused, gid_t sgid __maybe_unused) {
6 -#if defined(COMPILED_FOR_LINUX) || defined(COMPILED_FOR_FREEBSD)
6 +#if defined(OS_LINUX) || defined(OS_FREEBSD)
7 return setresgid(gid, egid, sgid);
8 #endif
9
10 -#if defined(COMPILED_FOR_MACOS)
10 +#if defined(OS_MACOS)
11 return setregid(gid, egid);
12 #endif
13
src/libnetdata/os/setresuid.c
+2 -2
@@ -3,11 +3,11 @@
3 #include "../libnetdata.h"
4
5 int os_setresuid(uid_t uid __maybe_unused, uid_t euid __maybe_unused, uid_t suid __maybe_unused) {
6 -#if defined(COMPILED_FOR_LINUX) || defined(COMPILED_FOR_FREEBSD)
6 +#if defined(OS_LINUX) || defined(OS_FREEBSD)
7 return setresuid(uid, euid, suid);
8 #endif
9
10 -#if defined(COMPILED_FOR_MACOS)
10 +#if defined(OS_MACOS)
11 return setreuid(uid, euid);
12 #endif
13
src/libnetdata/os/tinysleep.c
+23 -23
@@ -1,23 +1,23 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#include "../libnetdata.h"
4 -
5 -#ifdef COMPILED_FOR_WINDOWS
6 -#include <windows.h>
7 -
8 -void tinysleep(void) {
9 - // Improve the system timer resolution to 1 ms
10 - timeBeginPeriod(1);
11 -
12 - // Sleep for the desired duration
13 - Sleep(1);
14 -
15 - // Reset the system timer resolution
16 - timeEndPeriod(1);
17 -}
18 -#else
19 -void tinysleep(void) {
20 - static const struct timespec ns = { .tv_sec = 0, .tv_nsec = 1 };
21 - nanosleep(&ns, NULL);
22 -}
23 -#endif
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "../libnetdata.h"
4 +
5 +#ifdef OS_WINDOWS
6 +#include <windows.h>
7 +
8 +void tinysleep(void) {
9 + // Improve the system timer resolution to 1 ms
10 + timeBeginPeriod(1);
11 +
12 + // Sleep for the desired duration
13 + Sleep(1);
14 +
15 + // Reset the system timer resolution
16 + timeEndPeriod(1);
17 +}
18 +#else
19 +void tinysleep(void) {
20 + static const struct timespec ns = { .tv_sec = 0, .tv_nsec = 1 };
21 + nanosleep(&ns, NULL);
22 +}
23 +#endif
src/libnetdata/os/uuid_generate.c
+45 -45
@@ -1,45 +1,45 @@
1 -// SPDX-License-Identifier: GPL-3.0-or-later
2 -
3 -#include "../libnetdata.h"
4 -#undef uuid_generate
5 -#undef uuid_generate_random
6 -#undef uuid_generate_time
7 -
8 -#ifdef COMPILED_FOR_WINDOWS
9 -#include <windows.h>
10 -
11 -void os_uuid_generate(void *out) {
12 - RPC_STATUS status = UuidCreate(out);
13 - while (status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY) {
14 - tinysleep();
15 - status = UuidCreate(out);
16 - }
17 -}
18 -
19 -void os_uuid_generate_random(void *out) {
20 - os_uuid_generate(out);
21 -}
22 -
23 -void os_uuid_generate_time(void *out) {
24 - os_uuid_generate(out);
25 -}
26 -
27 -#else
28 -
29 -#if !defined(COMPILED_FOR_MACOS)
30 -#include <uuid.h>
31 -#endif
32 -
33 -void os_uuid_generate(void *out) {
34 - uuid_generate(out);
35 -}
36 -
37 -void os_uuid_generate_random(void *out) {
38 - uuid_generate_random(out);
39 -}
40 -
41 -void os_uuid_generate_time(void *out) {
42 - uuid_generate_time(out);
43 -}
44 -
45 -#endif
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "../libnetdata.h"
4 +#undef uuid_generate
5 +#undef uuid_generate_random
6 +#undef uuid_generate_time
7 +
8 +#ifdef OS_WINDOWS
9 +#include <windows.h>
10 +
11 +void os_uuid_generate(void *out) {
12 + RPC_STATUS status = UuidCreate(out);
13 + while (status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY) {
14 + tinysleep();
15 + status = UuidCreate(out);
16 + }
17 +}
18 +
19 +void os_uuid_generate_random(void *out) {
20 + os_uuid_generate(out);
21 +}
22 +
23 +void os_uuid_generate_time(void *out) {
24 + os_uuid_generate(out);
25 +}
26 +
27 +#else
28 +
29 +#if !defined(OS_MACOS)
30 +#include <uuid.h>
31 +#endif
32 +
33 +void os_uuid_generate(void *out) {
34 + uuid_generate(out);
35 +}
36 +
37 +void os_uuid_generate_random(void *out) {
38 + uuid_generate_random(out);
39 +}
40 +
41 +void os_uuid_generate_time(void *out) {
42 + uuid_generate_time(out);
43 +}
44 +
45 +#endif
src/libnetdata/os/waitid.h
+1 -1
@@ -33,7 +33,7 @@ struct pid_status {
33 int status;
34 };
35
36 -#if defined(COMPILED_FOR_WINDOWS) && !defined(__CYGWIN__)
36 +#if defined(OS_WINDOWS) && !defined(__CYGWIN__)
37 typedef uint32_t id_t;
38 typedef struct {
39 int si_code; /* Signal code. */
src/logsmanagement/logsmanagement.c
+2 -2
@@ -99,7 +99,7 @@ int main(int argc, char **argv) {
99 !strcmp("--version", argv[i]) ||
100 !strcmp("-v", argv[i]) ||
101 !strcmp("-V", argv[i])) {
102 - printf(VERSION"\n");
102 + printf(NETDATA_VERSION"\n");
103 exit(0);
104 }
105 else if(!strcmp("-h", argv[i]) ||
@@ -128,7 +128,7 @@ int main(int argc, char **argv) {
128 " https://github.com/netdata/netdata/tree/master/src/collectors/logs-management.plugin\n"
129 "\n",
130 program_name,
131 - VERSION
131 + NETDATA_VERSION
132 );
133 exit(1);
134 }
src/web/api/formatters/charts2json.c
+1 -1
@@ -31,7 +31,7 @@ const char* get_release_channel() {
31 }
32 }
33 if (use_stable == -1)
34 - use_stable = strchr(program_version, '-') ? 0 : 1;
34 + use_stable = strchr(NETDATA_VERSION, '-') ? 0 : 1;
35 }
36 return (use_stable)?"stable":"nightly";
37 }
src/web/server/web_client.c
+1 -1
@@ -882,7 +882,7 @@ void web_client_build_http_header(struct web_client *w) {
882 w->response.code,
883 code_msg,
884 web_client_has_keepalive(w)?"keep-alive":"close",
885 - VERSION,
885 + NETDATA_VERSION,
886 w->origin ? w->origin : "*",
887 rfc7231_date);
888