Unverified Commit cc70c14a authored by Maciej Krüger's avatar Maciej Krüger Committed by GitHub
Browse files

netdata: 1.47.5 -> 2.4.0 (#390165)

parents a6e4ff30 547813ca
Loading
Loading
Loading
Loading
+9 −18
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import ./make-test-python.nix (
          ];
          services.netdata = {
            enable = true;
            package = pkgs.netdataCloud;
            python.recommendedPythonPackages = true;

            configDir."apps_groups.conf" = pkgs.writeText "apps_groups.conf" ''
@@ -40,27 +41,17 @@ import ./make-test-python.nix (
        netdata.wait_for_open_port(19999)

      # check if the netdata main page loads.
      netdata.succeed("curl --fail http://localhost:19999/")
      netdata.succeed("curl --fail http://127.0.0.1:19999")
      netdata.succeed("sleep 4")

      # check if netdata can read disk ops for root owned processes.
      # if > 0, successful. verifies both netdata working and
      # apps.plugin has elevated capabilities.
      url = "http://localhost:19999/api/v1/data?chart=user.root_disk_physical_io"
      filter = '[.data[range(10)][2]] | add | . < 0'
      # check if netdata api shows correct os
      url = "http://127.0.0.1:19999/api/v3/info"
      filter = '.agents[0].application.os.os | . == "NixOS"'
      cmd = f"curl -s {url} | jq -e '{filter}'"
      netdata.wait_until_succeeds(cmd)

      # check if the control socket is available
      netdata.succeed("sudo netdatacli ping")

      # check that custom groups in apps_groups.conf are used.
      # if > 0, successful. verifies that user-specified apps_group.conf
      # is used.
      url = "http://localhost:19999/api/v1/data?chart=app.netdata_test_cpu_utilization"
      filter = '[.data[range(10)][2]] | add | . > 0'
      cmd = f"curl -s {url} | jq -e '{filter}'"
      netdata.wait_until_succeeds(cmd, timeout=30)
    '';
  }
)
+0 −25
Original line number Diff line number Diff line
# Original: https://github.com/netdata/netdata/pull/17240

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f37cbd18a..6db4c9f52 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,6 +134,7 @@ mark_as_advanced(DEFAULT_FEATURE_STATE)
 # High-level features
 option(ENABLE_ACLK "Enable Netdata Cloud support (ACLK)" ${DEFAULT_FEATURE_STATE})
 option(ENABLE_CLOUD "Enable Netdata Cloud by default at runtime" ${DEFAULT_FEATURE_STATE})
+option(ENABLE_DASHBOARD_V2 "enable dashboard v2" True)
 option(ENABLE_ML "Enable machine learning features" ${DEFAULT_FEATURE_STATE})
 option(ENABLE_DBENGINE "Enable dbengine metrics storage" True)

@@ -2946,7 +2947,9 @@ endif()
 #

 include(src/web/gui/v1/dashboard_v1.cmake)
-include(src/web/gui/v2/dashboard_v2.cmake)
+if(ENABLE_DASHBOARD_V2)
+        include(src/web/gui/v2/dashboard_v2.cmake)
+endif()
 include(src/web/gui/gui.cmake)

 function(cat IN_FILE OUT_FILE)
 No newline at end of file
+35 −0
Original line number Diff line number Diff line
diff --git a/packaging/cmake/Modules/NetdataDashboard.cmake b/packaging/cmake/Modules/NetdataDashboard.cmake
index 098eaffcf..e52375bd0 100644
--- a/packaging/cmake/Modules/NetdataDashboard.cmake
+++ b/packaging/cmake/Modules/NetdataDashboard.cmake
@@ -26,29 +26,12 @@ function(bundle_dashboard)
   set(dashboard_src_dir "${CMAKE_BINARY_DIR}/dashboard-src")
   set(dashboard_src_prefix "${dashboard_src_dir}/dist/agent")
   set(dashboard_bin_dir "${CMAKE_BINARY_DIR}/dashboard-bin")
-  set(DASHBOARD_URL "https://app.netdata.cloud/agent.tar.gz" CACHE STRING
-      "URL used to fetch the local agent dashboard code")

   message(STATUS "Preparing local agent dashboard code")

-  message(STATUS "  Fetching ${DASHBOARD_URL}")
-  file(DOWNLOAD
-       "${DASHBOARD_URL}"
-       "${CMAKE_BINARY_DIR}/dashboard.tar.gz"
-       TIMEOUT 180
-       STATUS fetch_status)
-
-  list(GET fetch_status 0 result)
-
-  if(result)
-    message(FATAL_ERROR "Failed to fetch dashboard code")
-  else()
-    message(STATUS "  Fetching ${DASHBOARD_URL} -- Done")
-  endif()
-
   message(STATUS "  Extracting dashboard code")
   extract_gzipped_tarball(
-    "${CMAKE_BINARY_DIR}/dashboard.tar.gz"
+    "@dashboardTarball@"
     "${dashboard_src_dir}"
   )
   message(STATUS "  Extracting dashboard code -- Done")
+72 −62
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  bash,
  bison,
  buildGoModule,
  cmake,
  cups,
  curl,
  darwin,
  dlib,
  fetchFromGitHub,
  fetchurl,
  flex,
  freeipmi,
  go,
  google-cloud-cpp,
  grpc,
  jemalloc,
  json_c,
  lib,
  libbacktrace,
  libbpf,
  libcap,
  libelf,
@@ -32,60 +36,55 @@
  overrideSDK,
  pkg-config,
  protobuf,
  replaceVars,
  snappy,
  stdenv,
  systemd,
  withCloud ? false,
  zlib,

  withCloudUi ? false,
  withConnPrometheus ? false,
  withConnPubSub ? false,
  withCups ? false,
  withDBengine ? true,
  withDBengine ? false,
  withDebug ? false,
  withEbpf ? false,
  withIpmi ? (stdenv.hostPlatform.isLinux),
  withLibbacktrace ? true,
  withNdsudo ? false,
  withNetfilter ? (stdenv.hostPlatform.isLinux),
  withNetworkViewer ? (stdenv.hostPlatform.isLinux),
  withSsl ? true,
  withSystemdJournal ? (stdenv.hostPlatform.isLinux),
  zlib,
  withNdsudo ? false,
  withML ? true,
}:
let
  stdenv' = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv;
in
stdenv'.mkDerivation (finalAttrs: {
  version = "1.47.5";
  version = "2.4.0";
  pname = "netdata";

  src = fetchFromGitHub {
    owner = "netdata";
    repo = "netdata";
    rev = "v${finalAttrs.version}";
    hash =
      if withCloudUi then
        "sha256-+cPYwjxg/+A5bNa517zg9xKEjUa8uPM9WD67tToPH5o="
      # we delete the v2 GUI after fetching
      else
        "sha256-0aiBUkDymmdIT/u1y2PG30QYAvb8Zc4i8ZgjOtlzt+A=";
    hash = "sha256-egHsWmhnrl8D59gr7uD5hBnleCOI8gVEBGwdO5GSnOg=";
    fetchSubmodules = true;

    # Remove v2 dashboard distributed under NCUL1. Make sure an empty
    # Makefile.am exists, as autoreconf will get confused otherwise.
    postFetch = lib.optionalString (!withCloudUi) ''
      rm -rf $out/src/web/gui/v2/*
      touch $out/src/web/gui/v2/Makefile.am
    '';
  };

  strictDeps = true;

  nativeBuildInputs = [
    bison
    cmake
    pkg-config
    makeWrapper
    flex
    go
    makeWrapper
    ninja
    pkg-config
  ] ++ lib.optionals withCups [ cups.dev ];

  # bash is only used to rewrite shebangs
  buildInputs =
    [
@@ -94,8 +93,10 @@ stdenv'.mkDerivation (finalAttrs: {
      jemalloc
      json_c
      libuv
      zlib
      libyaml
      lz4
      protobuf
      zlib
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin (
      with darwin.apple_sdk.frameworks;
@@ -110,34 +111,44 @@ stdenv'.mkDerivation (finalAttrs: {
      libuuid
      lm_sensors
    ]
    ++ lib.optionals withCups [ cups ]
    ++ lib.optionals withDBengine [ lz4 ]
    ++ lib.optionals withIpmi [ freeipmi ]
    ++ lib.optionals withNetfilter [
      libmnl
      libnetfilter_acct
    ]
    ++ lib.optionals withConnPrometheus [ snappy ]
    ++ lib.optionals withConnPubSub [
      google-cloud-cpp
      grpc
    ]
    ++ lib.optionals withConnPrometheus [ snappy ]
    ++ lib.optionals withCups [ cups ]
    ++ lib.optionals withEbpf [
      libelf
      libbpf
      libelf
    ]
    ++ lib.optionals (withCloud || withConnPrometheus) [ protobuf ]
    ++ lib.optionals withSystemdJournal [ systemd ]
    ++ lib.optionals withSsl [ openssl ];
    ++ lib.optionals withIpmi [ freeipmi ]
    ++ lib.optionals withLibbacktrace [ libbacktrace ]
    ++ lib.optionals withNetfilter [
      libmnl
      libnetfilter_acct
    ]
    ++ lib.optionals withSsl [ openssl ]
    ++ lib.optionals withSystemdJournal [ systemd ];

  patches = [
  patches =
    [
      # Allow ndsudo to use non-hardcoded `PATH`
      # See https://github.com/netdata/netdata/pull/17377#issuecomment-2183017868
      #     https://github.com/netdata/netdata/security/advisories/GHSA-pmhq-4cxq-wj93
      ./ndsudo-fix-path.patch
    # Allow building without non-free v2 dashboard.
    ./dashboard-v2-removal.patch
  ];

      ./use-local-libbacktrace.patch
    ]
    ++ lib.optional withCloudUi (
      replaceVars ./dashboard-v3-add.patch {
        # FIXME web.archive.org link can be replace once https://github.com/netdata/netdata-cloud/issues/1081 resolved
        # last update 03/16/2025 23:56:24
        dashboardTarball = fetchurl {
          url = "https://web.archive.org/web/20250316235624/https://app.netdata.cloud/agent.tar.gz";
          hash = "sha256-Vtw+CbBgqGRenkis0ZR2/TLsoM83NjNA6mbndb95EK8=";
        };
      }
    );

  # Guard against unused build-time development inputs in closure. Without
  # the ./skip-CONFIGURE_COMMAND.patch patch the closure retains inputs up
@@ -146,7 +157,7 @@ stdenv'.mkDerivation (finalAttrs: {
  # We pick zlib.dev as a simple canary package with pkg-config input.
  disallowedReferences = lib.optional (!withDebug) zlib.dev;

  donStrip = withDebug;
  donStrip = withDebug || withLibbacktrace;
  env.NIX_CFLAGS_COMPILE = lib.optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1";

  postInstall =
@@ -178,10 +189,6 @@ stdenv'.mkDerivation (finalAttrs: {
        mv $out/libexec/netdata/plugins.d/network-viewer.plugin \
           $out/libexec/netdata/plugins.d/network-viewer.plugin.org
      ''}
      ${lib.optionalString (!withCloudUi) ''
        rm -rf $out/share/netdata/web/index.html
        cp $out/share/netdata/web/v1/index.html $out/share/netdata/web/index.html
      ''}
      ${lib.optionalString withNdsudo ''
        mv $out/libexec/netdata/plugins.d/ndsudo \
          $out/libexec/netdata/plugins.d/ndsudo.org
@@ -215,27 +222,29 @@ stdenv'.mkDerivation (finalAttrs: {
      --replace-fail 'set(libconfigdir_POST "''${NETDATA_RUNTIME_PREFIX}/usr/lib/netdata/conf.d")' 'set(libconfigdir_POST "${placeholder "out"}/share/netdata/conf.d")' \
      --replace-fail 'set(cachedir_POST "''${NETDATA_RUNTIME_PREFIX}/var/cache/netdata")' 'set(libconfigdir_POST "/var/cache/netdata")' \
      --replace-fail 'set(registrydir_POST "''${NETDATA_RUNTIME_PREFIX}/var/lib/netdata/registry")' 'set(registrydir_POST "/var/lib/netdata/registry")' \
      --replace-fail 'set(varlibdir_POST "''${NETDATA_RUNTIME_PREFIX}/var/lib/netdata")' 'set(varlibdir_POST "/var/lib/netdata")'
      --replace-fail 'set(varlibdir_POST "''${NETDATA_RUNTIME_PREFIX}/var/lib/netdata")' 'set(varlibdir_POST "/var/lib/netdata")' \
      --replace-fail 'set(BUILD_INFO_CMAKE_CACHE_ARCHIVE_PATH "usr/share/netdata")' 'set(BUILD_INFO_CMAKE_CACHE_ARCHIVE_PATH "${placeholder "out"}/share/netdata")'
  '';

  cmakeFlags = [
    "-DWEB_DIR=share/netdata/web"
    (lib.cmakeBool "ENABLE_CLOUD" withCloud)
    # ACLK is agent cloud link.
    (lib.cmakeBool "ENABLE_ACLK" withCloud)
    (lib.cmakeBool "ENABLE_DASHBOARD_V2" withCloudUi)
    (lib.cmakeBool "ENABLE_DBENGINE" withDBengine)
    (lib.cmakeBool "ENABLE_DASHBOARD" withCloudUi)
    # FIXME uncomment when https://github.com/netdata/netdata/issues/19901#issuecomment-2819701451 resolved
    (lib.cmakeBool "ENABLE_DBENGINE" true)
    # (lib.cmakeBool "ENABLE_DBENGINE" withDBengine)
    (lib.cmakeBool "ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE" withConnPrometheus)
    (lib.cmakeBool "ENABLE_JEMALLOC" true)
    (lib.cmakeBool "ENABLE_LIBBACKTRACE" withLibbacktrace)
    (lib.cmakeBool "ENABLE_PLUGIN_CUPS" withCups)
    (lib.cmakeBool "ENABLE_PLUGIN_EBPF" withEbpf)
    (lib.cmakeBool "ENABLE_PLUGIN_FREEIPMI" withIpmi)
    (lib.cmakeBool "ENABLE_PLUGIN_SYSTEMD_JOURNAL" withSystemdJournal)
    (lib.cmakeBool "ENABLE_PLUGIN_NETWORK_VIEWER" withNetworkViewer)
    (lib.cmakeBool "ENABLE_PLUGIN_EBPF" withEbpf)
    (lib.cmakeBool "ENABLE_PLUGIN_SYSTEMD_JOURNAL" withSystemdJournal)
    (lib.cmakeBool "ENABLE_PLUGIN_XENSTAT" false)
    (lib.cmakeBool "ENABLE_PLUGIN_CUPS" withCups)
    (lib.cmakeBool "ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE" withConnPrometheus)
    (lib.cmakeBool "ENABLE_JEMALLOC" true)
    (lib.cmakeBool "ENABLE_ML" withML)
    # Suggested by upstream.
    "-G Ninja"
  ];
  ] ++ lib.optional withML "-DNETDATA_DLIB_SOURCE_PATH=${dlib.src}";

  postFixup = ''
    wrapProgram $out/bin/netdata-claim.sh --prefix PATH : ${lib.makeBinPath [ openssl ]}
@@ -260,7 +269,7 @@ stdenv'.mkDerivation (finalAttrs: {

        sourceRoot = "${finalAttrs.src.name}/src/go/plugin/go.d";

        vendorHash = "sha256-NZ1tg+lvXNgypqmjjb5f7dHH6DIA9VOa4PMM4eq11n0=";
        vendorHash = "sha256-PgQs3+++iD9Lg8psTBVzF4b+kGJzhV5yNQBkw/+Dqks=";
        doCheck = false;
        proxyVendor = true;

@@ -291,6 +300,7 @@ stdenv'.mkDerivation (finalAttrs: {
    platforms = platforms.unix;
    maintainers = with maintainers; [
      mkg20001
      rhoriguchi
    ];
  };
})
+3 −3
Original line number Diff line number Diff line
# See https://github.com/netdata/netdata/pull/17377#issuecomment-2183017868
#     https://github.com/netdata/netdata/security/advisories/GHSA-pmhq-4cxq-wj93

diff --git a/src/collectors/plugins.d/ndsudo.c b/src/collectors/plugins.d/ndsudo.c
diff --git a/src/collectors/utils/ndsudo.c b/src/collectors/utils/ndsudo.c
index d53ca9f28..b42a121bf 100644
--- a/src/collectors/plugins.d/ndsudo.c
+++ b/src/collectors/plugins.d/ndsudo.c
--- a/src/collectors/utils/ndsudo.c
+++ b/src/collectors/utils/ndsudo.c
@@ -357,9 +357,9 @@ int main(int argc, char *argv[]) {
         return 3;
     }
Loading