aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt
diff options
context:
space:
mode:
authorMahdi Mokhtari <mmokhi@FreeBSD.org>2018-01-18 12:25:10 +0000
committerMahdi Mokhtari <mmokhi@FreeBSD.org>2018-01-18 12:25:10 +0000
commit043e4b4b03ae5de64e5fec82027944c0cf2c3e12 (patch)
treed794fd675ead28d16a5bb1810b77ef735d58b3b1 /net-mgmt
parent42c1216a4eb99942285763811950600a7db19197 (diff)
downloadports-043e4b4b03ae5de64e5fec82027944c0cf2c3e12.tar.gz
ports-043e4b4b03ae5de64e5fec82027944c0cf2c3e12.zip
Notes
Diffstat (limited to 'net-mgmt')
-rw-r--r--net-mgmt/netdata/Makefile3
-rw-r--r--net-mgmt/netdata/files/patch-fixes-issue-3276-upstream295
2 files changed, 298 insertions, 0 deletions
diff --git a/net-mgmt/netdata/Makefile b/net-mgmt/netdata/Makefile
index 064f7fc88c2c..380c651c524c 100644
--- a/net-mgmt/netdata/Makefile
+++ b/net-mgmt/netdata/Makefile
@@ -4,6 +4,7 @@
PORTNAME= netdata
PORTVERSION= 1.9.0
DISTVERSIONPREFIX=v
+PORTREVISION= 1
CATEGORIES= net-mgmt
MAINTAINER= mmokhi@FreeBSD.org
@@ -13,6 +14,8 @@ LICENSE= GPLv3
BUILD_DEPENDS= ${LOCALBASE}/include/uuid/uuid.h:misc/e2fsprogs-libuuid
LIB_DEPENDS= libuuid.so:misc/e2fsprogs-libuuid
+RUN_DEPENDS= bash:shells/bash \
+ curl:ftp/curl
USES= autoreconf pathfix pkgconfig:both python shebangfix
diff --git a/net-mgmt/netdata/files/patch-fixes-issue-3276-upstream b/net-mgmt/netdata/files/patch-fixes-issue-3276-upstream
new file mode 100644
index 000000000000..9ea961605a63
--- /dev/null
+++ b/net-mgmt/netdata/files/patch-fixes-issue-3276-upstream
@@ -0,0 +1,295 @@
+--- installer/functions.sh.orig
++++ installer/functions.sh
+@@ -161,6 +161,22 @@ pidof() {
+
+ # -----------------------------------------------------------------------------
+
++export SYSTEM_CPUS=1
++portable_find_processors() {
++ if [ -f "/proc/cpuinfo" ]
++ then
++ # linux
++ SYSTEM_CPUS=$(grep -c ^processor /proc/cpuinfo)
++ else
++ # freebsd
++ SYSTEM_CPUS=$(sysctl hw.ncpu 2>/dev/null | grep ^hw.ncpu | cut -d ' ' -f 2)
++ fi
++ [ -z "${SYSTEM_CPUS}" -o $(( SYSTEM_CPUS )) -lt 1 ] && SYSTEM_CPUS=1
++}
++portable_find_processors
++
++# -----------------------------------------------------------------------------
++
+ run_ok() {
+ printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
+ }
+--- makeself/functions.sh.orig
++++ makeself/functions.sh
+@@ -8,8 +8,6 @@
+ [ -z "${NETDATA_MAKESELF_PATH}" ] && export NETDATA_MAKESELF_PATH="$(dirname "${0}")/.."
+ [ "${NETDATA_MAKESELF_PATH:0:1}" != "/" ] && export NETDATA_MAKESELF_PATH="$(pwd)/${NETDATA_MAKESELF_PATH}"
+ [ -z "${NETDATA_SOURCE_PATH}" ] && export NETDATA_SOURCE_PATH="${NETDATA_MAKESELF_PATH}/.."
+-[ -z "${PROCESSORS}" ] && export PROCESSORS=$(grep -c ^processor /proc/cpuinfo)
+-[ -z "${PROCESSORS}" -o $((PROCESSORS)) -lt 1 ] && export PROCESSORS=1
+ export NULL=
+
+ # make sure the path does not end with /
+@@ -21,14 +19,7 @@ fi
+ # find the parent directory
+ export NETDATA_INSTALL_PARENT="$(dirname "${NETDATA_INSTALL_PATH}")"
+
+-
+-# debug
+-echo "ME=${0}"
+-echo "NETDATA_INSTALL_PARENT=${NETDATA_INSTALL_PARENT}"
+-echo "NETDATA_INSTALL_PATH=${NETDATA_INSTALL_PATH}"
+-echo "NETDATA_MAKESELF_PATH=${NETDATA_MAKESELF_PATH}"
+-echo "NETDATA_SOURCE_PATH=${NETDATA_SOURCE_PATH}"
+-echo "PROCESSORS=${PROCESSORS}"
++# -----------------------------------------------------------------------------
+
+ # bash strict mode
+ set -euo pipefail
+@@ -58,3 +49,13 @@ fetch() {
+
+ # load the functions of the netdata-installer.sh
+ . "${NETDATA_SOURCE_PATH}/installer/functions.sh"
++
++# -----------------------------------------------------------------------------
++
++# debug
++echo "ME=${0}"
++echo "NETDATA_INSTALL_PARENT=${NETDATA_INSTALL_PARENT}"
++echo "NETDATA_INSTALL_PATH=${NETDATA_INSTALL_PATH}"
++echo "NETDATA_MAKESELF_PATH=${NETDATA_MAKESELF_PATH}"
++echo "NETDATA_SOURCE_PATH=${NETDATA_SOURCE_PATH}"
++echo "PROCESSORS=${SYSTEM_CPUS}"
+--- makeself/jobs/50-bash-4.4.install.sh.orig
++++ makeself/jobs/50-bash-4.4.install.sh
+@@ -34,7 +34,7 @@ run ./configure \
+
+
+ run make clean
+-run make -j${PROCESSORS}
++run make -j${SYSTEM_CPUS}
+
+ cat >examples/loadables/Makefile <<EOF
+ all:
+--- makeself/jobs/50-curl-7.53.1.install.sh.orig
++++ makeself/jobs/50-curl-7.53.1.install.sh
+@@ -24,7 +24,7 @@ run ./configure \
+ run sed -i -e "s/curl_LDFLAGS =/curl_LDFLAGS = -all-static/" src/Makefile
+
+ run make clean
+-run make -j${PROCESSORS}
++run make -j${SYSTEM_CPUS}
+ run make install
+
+ if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
+--- makeself/jobs/50-fping-4.0.install.sh.orig
++++ makeself/jobs/50-fping-4.0.install.sh
+@@ -19,7 +19,7 @@ install:
+ EOF
+
+ run make clean
+-run make -j${PROCESSORS}
++run make -j${SYSTEM_CPUS}
+ run make install
+
+ if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
+--- netdata-installer.sh.orig
++++ netdata-installer.sh
+@@ -63,9 +63,6 @@ umask 002
+ # Be nice on production environments
+ renice 19 $$ >/dev/null 2>/dev/null
+
+-processors=$(grep -c ^processor /proc/cpuinfo)
+-[ $(( processors )) -lt 1 ] && processors=1
+-
+ # you can set CFLAGS before running installer
+ CFLAGS="${CFLAGS--O2}"
+ [ "z${CFLAGS}" = "z-O3" ] && CFLAGS="-O2"
+@@ -495,7 +492,7 @@ progress "Cleanup compilation directory"
+ # -----------------------------------------------------------------------------
+ progress "Compile netdata"
+
+-run make -j${processors} || exit 1
++run make -j${SYSTEM_CPUS} || exit 1
+
+
+ # -----------------------------------------------------------------------------
+--- src/apps_plugin.c.orig
++++ src/apps_plugin.c
+@@ -715,19 +715,35 @@ static inline int managed_log(struct pid_stat *p, uint32_t log, int status) {
+ p->log_thrown |= log;
+ switch(log) {
+ case PID_LOG_IO:
++ #ifdef __FreeBSD__
++ error("Cannot fetch process %d I/O info (command '%s')", p->pid, p->comm);
++ #else
+ error("Cannot process %s/proc/%d/io (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
++ #endif
+ break;
+
+ case PID_LOG_STATM:
++ #ifdef __FreeBSD__
++ error("Cannot fetch process %d memory info (command '%s')", p->pid, p->comm);
++ #else
+ error("Cannot process %s/proc/%d/statm (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
++ #endif
+ break;
+
+ case PID_LOG_CMDLINE:
++ #ifdef __FreeBSD__
++ error("Cannot fetch process %d command line (command '%s')", p->pid, p->comm);
++ #else
+ error("Cannot process %s/proc/%d/cmdline (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
++ #endif
+ break;
+
+ case PID_LOG_FDS:
++ #ifdef __FreeBSD__
++ error("Cannot fetch process %d files (command '%s')", p->pid, p->comm);
++ #else
+ error("Cannot process entries in %s/proc/%d/fd (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
++ #endif
+ break;
+
+ case PID_LOG_STAT:
+@@ -955,7 +971,7 @@ static inline int read_proc_pid_stat(struct pid_stat *p, void *ptr) {
+ pid_incremental_rate(stat, p->utime, (kernel_uint_t)proc_info->ki_rusage.ru_utime.tv_sec * 100 + proc_info->ki_rusage.ru_utime.tv_usec / 10000);
+ pid_incremental_rate(stat, p->stime, (kernel_uint_t)proc_info->ki_rusage.ru_stime.tv_sec * 100 + proc_info->ki_rusage.ru_stime.tv_usec / 10000);
+ pid_incremental_rate(stat, p->cutime, (kernel_uint_t)proc_info->ki_rusage_ch.ru_utime.tv_sec * 100 + proc_info->ki_rusage_ch.ru_utime.tv_usec / 10000);
+- pid_incremental_rate(stat, p->cstime, (kernel_uint_t)proc_info->ki_rusage_ch.ru_stime.tv_sec * 100 + proc_info->ki_rusage_ch.ru_utime.tv_usec / 10000);
++ pid_incremental_rate(stat, p->cstime, (kernel_uint_t)proc_info->ki_rusage_ch.ru_stime.tv_sec * 100 + proc_info->ki_rusage_ch.ru_stime.tv_usec / 10000);
+
+ p->num_threads = proc_info->ki_numthreads;
+
+@@ -2006,8 +2022,8 @@ static int compar_pid(const void *pid1, const void *pid2) {
+ #endif
+
+ static inline int collect_data_for_pid(pid_t pid, void *ptr) {
+- if(unlikely(pid < INIT_PID || pid > pid_max)) {
+- error("Invalid pid %d read (expected %d to %d). Ignoring process.", pid, INIT_PID, pid_max);
++ if(unlikely(pid < 0 || pid > pid_max)) {
++ error("Invalid pid %d read (expected %d to %d). Ignoring process.", pid, 0, pid_max);
+ return 0;
+ }
+
+@@ -2069,28 +2085,46 @@ static int collect_data_for_all_processes(void) {
+
+ #ifdef __FreeBSD__
+ int i, procnum;
+- size_t procbase_size;
+- static struct kinfo_proc *procbase;
+
+- int mib[3];
++ static size_t procbase_size = 0;
++ static struct kinfo_proc *procbase = NULL;
+
+- mib[0] = CTL_KERN;
+- mib[1] = KERN_PROC;
+- mib[2] = KERN_PROC_PROC;
+- if (unlikely(sysctl(mib, 3, NULL, &procbase_size, NULL, 0))) {
++ size_t new_procbase_size;
++
++ int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_PROC };
++ if (unlikely(sysctl(mib, 3, NULL, &new_procbase_size, NULL, 0))) {
+ error("sysctl error: Can't get processes data size");
+ return 0;
+ }
+- procbase = reallocz(procbase, procbase_size);
+- if (unlikely(sysctl(mib, 3, procbase, &procbase_size, NULL, 0))) {
++
++ // give it some air for processes that may be started
++ // during this little time.
++ new_procbase_size += 100 * sizeof(struct kinfo_proc);
++
++ // increase the buffer if needed
++ if(new_procbase_size > procbase_size) {
++ procbase_size = new_procbase_size;
++ procbase = reallocz(procbase, procbase_size);
++ }
++
++ // sysctl() gets from new_procbase_size the buffer size
++ // and also returns to it the amount of data filled in
++ new_procbase_size = procbase_size;
++
++ // get the processes from the system
++ if (unlikely(sysctl(mib, 3, procbase, &new_procbase_size, NULL, 0))) {
+ error("sysctl error: Can't get processes data");
+ return 0;
+ }
+- procnum = procbase_size / sizeof(struct kinfo_proc);
++
++ // based on the amount of data filled in
++ // calculate the number of processes we got
++ procnum = new_procbase_size / sizeof(struct kinfo_proc);
++
+ #endif
+
+ if(all_pids_count) {
+-#ifndef __FreeBSD__
++#if (ALL_PIDS_ARE_READ_INSTANTLY == 0)
+ size_t slc = 0;
+ #endif
+ for(p = root_of_pids; p ; p = p->next) {
+@@ -2107,7 +2141,7 @@ static int collect_data_for_all_processes(void) {
+
+ #if (ALL_PIDS_ARE_READ_INSTANTLY == 0)
+ if(unlikely(slc != all_pids_count)) {
+- error("Internal error: I was thinking I had %zu processes in my arrays, but it seems there are more.", all_pids_count);
++ error("Internal error: I was thinking I had %zu processes in my arrays, but it seems there are %zu.", all_pids_count, slc);
+ all_pids_count = slc;
+ }
+
+@@ -2130,7 +2164,7 @@ static int collect_data_for_all_processes(void) {
+ }
+
+ #ifdef __FreeBSD__
+- for (i = INIT_PID; i < procnum - INIT_PID; ++i) {
++ for (i = 0 ; i < procnum ; ++i) {
+ pid_t pid = procbase[i].ki_pid;
+ collect_data_for_pid(pid, &procbase[i]);
+ }
+@@ -2258,21 +2292,17 @@ static void apply_apps_groups_targets_inheritance(void) {
+ if(unlikely(!p->sortlist && !p->children_count))
+ p->sortlist = sortlist++;
+
+- // if this process does not have any children
+- // and is not already merged
+- // and has a parent
+- // and its parent has children
+- // and the target of this process and its parent is the same, or the parent does not have a target
+- // and its parent is not init
+- // then, mark them as merged.
+ if(unlikely(
+- !p->children_count
+- && !p->merged
+- && p->parent
+- && p->parent->children_count
++ !p->children_count // if this process does not have any children
++ && !p->merged // and is not already merged
++ && p->parent // and has a parent
++ && p->parent->children_count // and its parent has children
++ // and the target of this process and its parent is the same,
++ // or the parent does not have a target
+ && (p->target == p->parent->target || !p->parent->target)
+- && p->ppid != INIT_PID
++ && p->ppid != INIT_PID // and its parent is not init
+ )) {
++ // mark it as merged
+ p->parent->children_count--;
+ p->merged = 1;
+
+@@ -2296,6 +2326,10 @@ static void apply_apps_groups_targets_inheritance(void) {
+ if(all_pids[INIT_PID])
+ all_pids[INIT_PID]->target = apps_groups_default_target;
+
++ // pid 0 goes always to default target
++ if(all_pids[0])
++ all_pids[0]->target = apps_groups_default_target;
++
+ // give a default target on all top level processes
+ if(unlikely(debug)) loops++;
+ for(p = root_of_pids; p ; p = p->next) {