summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:22:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:22:44 +0000
commit1e6c93250172946eeb38e94a92a1fd12c9d3011e (patch)
tree8ca5e16dfc7ad6b3bf2738ca0a48408a950f8f7e /system
parentUpdate watch file (diff)
downloadnetdata-1e6c93250172946eeb38e94a92a1fd12c9d3011e.tar.xz
netdata-1e6c93250172946eeb38e94a92a1fd12c9d3011e.zip
Merging upstream version 1.11.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'system')
-rw-r--r--system/Makefile.am11
-rw-r--r--system/Makefile.in125
-rw-r--r--system/edit-config96
-rwxr-xr-xsystem/edit-config.in96
-rw-r--r--system/netdata-freebsd.in6
-rw-r--r--system/netdata-init-d.in5
-rw-r--r--system/netdata-lsb.in8
-rw-r--r--system/netdata-openrc.in86
-rw-r--r--system/netdata.logrotate.in2
-rw-r--r--system/netdata.plist.in15
-rw-r--r--system/netdata.service.in22
11 files changed, 383 insertions, 89 deletions
diff --git a/system/Makefile.am b/system/Makefile.am
index 255147ba..b085dca8 100644
--- a/system/Makefile.am
+++ b/system/Makefile.am
@@ -1,20 +1,26 @@
#
# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
+# SPDX-License-Identifier: GPL-3.0-or-later
#
MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
CLEANFILES = \
+ edit-config \
netdata-openrc \
netdata.logrotate \
netdata.service \
netdata-init-d \
netdata-lsb \
netdata-freebsd \
+ netdata.plist \
$(NULL)
include $(top_srcdir)/build/subst.inc
-
SUFFIXES = .in
+dist_config_SCRIPTS = \
+ edit-config \
+ $(NULL)
+
nodist_noinst_DATA = \
netdata-openrc \
netdata.logrotate \
@@ -22,14 +28,17 @@ nodist_noinst_DATA = \
netdata-init-d \
netdata-lsb \
netdata-freebsd \
+ netdata.plist \
$(NULL)
dist_noinst_DATA = \
+ edit-config.in \
netdata-openrc.in \
netdata.logrotate.in \
netdata.service.in \
netdata-init-d.in \
netdata-lsb.in \
netdata-freebsd.in \
+ netdata.plist.in \
netdata.conf \
$(NULL)
diff --git a/system/Makefile.in b/system/Makefile.in
index a9843de4..3598ebde 100644
--- a/system/Makefile.in
+++ b/system/Makefile.in
@@ -14,6 +14,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
@@ -79,23 +80,55 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
DIST_COMMON = $(top_srcdir)/build/subst.inc $(srcdir)/Makefile.in \
- $(srcdir)/Makefile.am $(dist_noinst_DATA)
+ $(srcdir)/Makefile.am $(dist_config_SCRIPTS) \
+ $(dist_noinst_DATA)
subdir = system
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___atomic.m4 \
- $(top_srcdir)/m4/ax_c__generic.m4 $(top_srcdir)/m4/ax_c_lto.m4 \
- $(top_srcdir)/m4/ax_c_mallinfo.m4 \
- $(top_srcdir)/m4/ax_c_mallopt.m4 \
- $(top_srcdir)/m4/ax_check_compile_flag.m4 \
- $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
- $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/jemalloc.m4 \
- $(top_srcdir)/m4/tcmalloc.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/build/m4/ax_c___atomic.m4 \
+ $(top_srcdir)/build/m4/ax_c__generic.m4 \
+ $(top_srcdir)/build/m4/ax_c_lto.m4 \
+ $(top_srcdir)/build/m4/ax_c_mallinfo.m4 \
+ $(top_srcdir)/build/m4/ax_c_mallopt.m4 \
+ $(top_srcdir)/build/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/build/m4/ax_gcc_func_attribute.m4 \
+ $(top_srcdir)/build/m4/ax_pthread.m4 \
+ $(top_srcdir)/build/m4/jemalloc.m4 \
+ $(top_srcdir)/build/m4/tcmalloc.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(configdir)"
+SCRIPTS = $(dist_config_SCRIPTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -215,6 +248,7 @@ build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
+build_target = @build_target@
build_vendor = @build_vendor@
builddir = @builddir@
cachedir = @cachedir@
@@ -236,6 +270,7 @@ htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+libconfigdir = @libconfigdir@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
@@ -265,18 +300,25 @@ webdir = @webdir@
#
# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
+# SPDX-License-Identifier: GPL-3.0-or-later
#
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
CLEANFILES = \
+ edit-config \
netdata-openrc \
netdata.logrotate \
netdata.service \
netdata-init-d \
netdata-lsb \
netdata-freebsd \
+ netdata.plist \
$(NULL)
SUFFIXES = .in
+dist_config_SCRIPTS = \
+ edit-config \
+ $(NULL)
+
nodist_noinst_DATA = \
netdata-openrc \
netdata.logrotate \
@@ -284,15 +326,18 @@ nodist_noinst_DATA = \
netdata-init-d \
netdata-lsb \
netdata-freebsd \
+ netdata.plist \
$(NULL)
dist_noinst_DATA = \
+ edit-config.in \
netdata-openrc.in \
netdata.logrotate.in \
netdata.service.in \
netdata-init-d.in \
netdata-lsb.in \
netdata-freebsd.in \
+ netdata.plist.in \
netdata.conf \
$(NULL)
@@ -331,6 +376,41 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
+install-dist_configSCRIPTS: $(dist_config_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_config_SCRIPTS)'; test -n "$(configdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(configdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(configdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(configdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(configdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-dist_configSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_config_SCRIPTS)'; test -n "$(configdir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ dir='$(DESTDIR)$(configdir)'; $(am__uninstall_files_from_dir)
tags TAGS:
ctags CTAGS:
@@ -370,8 +450,11 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(DATA)
+all-am: Makefile $(SCRIPTS) $(DATA)
installdirs:
+ for dir in "$(DESTDIR)$(configdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
@@ -424,7 +507,7 @@ info: info-am
info-am:
-install-data-am:
+install-data-am: install-dist_configSCRIPTS
install-dvi: install-dvi-am
@@ -468,20 +551,21 @@ ps: ps-am
ps-am:
-uninstall-am:
+uninstall-am: uninstall-dist_configSCRIPTS
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic cscopelist-am \
ctags-am distclean distclean-generic distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
- pdf-am ps ps-am tags-am uninstall uninstall-am
+ install-data-am install-dist_configSCRIPTS install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \
+ uninstall-am uninstall-dist_configSCRIPTS
.in:
if sed \
@@ -489,6 +573,9 @@ uninstall-am:
-e 's#[@]sbindir_POST@#$(sbindir)#g' \
-e 's#[@]sysconfdir_POST@#$(sysconfdir)#g' \
-e 's#[@]pythondir_POST@#$(pythondir)#g' \
+ -e 's#[@]configdir_POST@#$(configdir)#g' \
+ -e 's#[@]libconfigdir_POST@#$(libconfigdir)#g' \
+ -e 's#[@]cachedir_POST@#$(cachedir)#g' \
$< > $@.tmp; then \
mv "$@.tmp" "$@"; \
else \
diff --git a/system/edit-config b/system/edit-config
new file mode 100644
index 00000000..1696f9f3
--- /dev/null
+++ b/system/edit-config
@@ -0,0 +1,96 @@
+#!/usr/bin/env sh
+
+[ -f /etc/profile ] && . /etc/profile
+
+file="${1}"
+
+EDITOR="${EDITOR-vi}"
+[ -z "${NETDATA_USER_CONFIG_DIR}" ] && NETDATA_USER_CONFIG_DIR="/usr/local/etc/netdata"
+[ -z "${NETDATA_STOCK_CONFIG_DIR}" ] && NETDATA_STOCK_CONFIG_DIR="/usr/local/lib/netdata/conf.d"
+
+if [ -z "${file}" ]
+then
+ cat <<USAGE
+
+USAGE:
+ ${0} FILENAME
+
+ Copy and edit the stock config file named: FILENAME
+ if FILENAME is already copied, it will be edited as-is.
+
+ The EDITOR shell variable is used to define the editor to be used.
+
+ Stock config files at: '${NETDATA_STOCK_CONFIG_DIR}'
+ User config files at: '${NETDATA_USER_CONFIG_DIR}'
+
+ Available files in '${NETDATA_STOCK_CONFIG_DIR}' to copy and edit:
+
+USAGE
+
+ cd "${NETDATA_STOCK_CONFIG_DIR}" || exit 1
+ ls >&2 -R *.conf */*.conf
+ exit 1
+
+fi
+
+file_is_in_path() {
+ local file path real
+ file="${1}"
+ path="${2}"
+
+ real="$(readlink -f "${file}")"
+
+ # we don't have working readlink
+ [ -z "${real}" ] && return 0
+
+ if [ ! -z "${real}" ] && [ -z "$(echo "${real}" | grep -E "^${path}.*$")" ]
+ then
+ echo >&2 "File '${file}' is physically at '${real}', which is not in '${path}'. Aborting."
+ exit 1
+ fi
+
+ return 0
+}
+
+edit() {
+ echo >&2 "Editing '${1}' ..."
+
+ # check we can edit
+ file_is_in_path "${1}" "${NETDATA_USER_CONFIG_DIR}" || exit 1
+
+ "${EDITOR}" "${1}"
+ exit $?
+}
+
+copy_and_edit() {
+ # check we can copy
+ file_is_in_path "${NETDATA_STOCK_CONFIG_DIR}/${1}" "${NETDATA_STOCK_CONFIG_DIR}" || exit 1
+
+ if [ ! -f "${NETDATA_USER_CONFIG_DIR}/${1}" ]
+ then
+ echo >&2 "Copying '${NETDATA_STOCK_CONFIG_DIR}/${1}' to '${NETDATA_USER_CONFIG_DIR}/${1}' ... "
+ cp -p "${NETDATA_STOCK_CONFIG_DIR}/${1}" "${NETDATA_USER_CONFIG_DIR}/${1}" || exit 1
+ fi
+
+ edit "${NETDATA_USER_CONFIG_DIR}/${1}"
+}
+
+# make sure it is not absolute filename
+c1="$(echo "${file}" | cut -b 1)"
+if [ "${c1}" = "/" ] || [ "${c1}" = "." ]
+then
+ echo >&2 "Please don't use filenames starting with '/' or '.'"
+ exit 1
+fi
+
+# already exists
+if [ -f "${NETDATA_USER_CONFIG_DIR}/${file}" ]
+then
+ edit "${NETDATA_USER_CONFIG_DIR}/${file}"
+fi
+
+[ -f "${NETDATA_USER_CONFIG_DIR}/${file}" ] && edit "${NETDATA_USER_CONFIG_DIR}/${file}"
+[ -f "${NETDATA_STOCK_CONFIG_DIR}/${file}" ] && copy_and_edit "${file}"
+
+echo >&2 "File '${file}' is not found in '${NETDATA_STOCK_CONFIG_DIR}'"
+exit 1
diff --git a/system/edit-config.in b/system/edit-config.in
new file mode 100755
index 00000000..1b86549f
--- /dev/null
+++ b/system/edit-config.in
@@ -0,0 +1,96 @@
+#!/usr/bin/env sh
+
+[ -f /etc/profile ] && . /etc/profile
+
+file="${1}"
+
+EDITOR="${EDITOR-vi}"
+[ -z "${NETDATA_USER_CONFIG_DIR}" ] && NETDATA_USER_CONFIG_DIR="@configdir_POST@"
+[ -z "${NETDATA_STOCK_CONFIG_DIR}" ] && NETDATA_STOCK_CONFIG_DIR="@libconfigdir_POST@"
+
+if [ -z "${file}" ]
+then
+ cat <<USAGE
+
+USAGE:
+ ${0} FILENAME
+
+ Copy and edit the stock config file named: FILENAME
+ if FILENAME is already copied, it will be edited as-is.
+
+ The EDITOR shell variable is used to define the editor to be used.
+
+ Stock config files at: '${NETDATA_STOCK_CONFIG_DIR}'
+ User config files at: '${NETDATA_USER_CONFIG_DIR}'
+
+ Available files in '${NETDATA_STOCK_CONFIG_DIR}' to copy and edit:
+
+USAGE
+
+ cd "${NETDATA_STOCK_CONFIG_DIR}" || exit 1
+ ls >&2 -R *.conf */*.conf
+ exit 1
+
+fi
+
+file_is_in_path() {
+ local file path real
+ file="${1}"
+ path="${2}"
+
+ real="$(readlink -f "${file}")"
+
+ # we don't have working readlink
+ [ -z "${real}" ] && return 0
+
+ if [ ! -z "${real}" ] && [ -z "$(echo "${real}" | grep -E "^${path}.*$")" ]
+ then
+ echo >&2 "File '${file}' is physically at '${real}', which is not in '${path}'. Aborting."
+ exit 1
+ fi
+
+ return 0
+}
+
+edit() {
+ echo >&2 "Editing '${1}' ..."
+
+ # check we can edit
+ file_is_in_path "${1}" "${NETDATA_USER_CONFIG_DIR}" || exit 1
+
+ "${EDITOR}" "${1}"
+ exit $?
+}
+
+copy_and_edit() {
+ # check we can copy
+ file_is_in_path "${NETDATA_STOCK_CONFIG_DIR}/${1}" "${NETDATA_STOCK_CONFIG_DIR}" || exit 1
+
+ if [ ! -f "${NETDATA_USER_CONFIG_DIR}/${1}" ]
+ then
+ echo >&2 "Copying '${NETDATA_STOCK_CONFIG_DIR}/${1}' to '${NETDATA_USER_CONFIG_DIR}/${1}' ... "
+ cp -p "${NETDATA_STOCK_CONFIG_DIR}/${1}" "${NETDATA_USER_CONFIG_DIR}/${1}" || exit 1
+ fi
+
+ edit "${NETDATA_USER_CONFIG_DIR}/${1}"
+}
+
+# make sure it is not absolute filename
+c1="$(echo "${file}" | cut -b 1)"
+if [ "${c1}" = "/" ] || [ "${c1}" = "." ]
+then
+ echo >&2 "Please don't use filenames starting with '/' or '.'"
+ exit 1
+fi
+
+# already exists
+if [ -f "${NETDATA_USER_CONFIG_DIR}/${file}" ]
+then
+ edit "${NETDATA_USER_CONFIG_DIR}/${file}"
+fi
+
+[ -f "${NETDATA_USER_CONFIG_DIR}/${file}" ] && edit "${NETDATA_USER_CONFIG_DIR}/${file}"
+[ -f "${NETDATA_STOCK_CONFIG_DIR}/${file}" ] && copy_and_edit "${file}"
+
+echo >&2 "File '${file}' is not found in '${NETDATA_STOCK_CONFIG_DIR}'"
+exit 1
diff --git a/system/netdata-freebsd.in b/system/netdata-freebsd.in
index fac2e82c..300ddc9e 100644
--- a/system/netdata-freebsd.in
+++ b/system/netdata-freebsd.in
@@ -1,11 +1,13 @@
#!/bin/sh
+# SPDX-License-Identifier: GPL-3.0-or-later
. /etc/rc.subr
name=netdata
rcvar=netdata_enable
-pidfile="@localstatedir_POST@/run/netdata.pid"
+piddir="@localstatedir_POST@/run/netdata"
+pidfile="${pidfile}/netdata.pid"
command="@sbindir_POST@/netdata"
command_args="-P ${pidfile}"
@@ -22,11 +24,13 @@ savedb_cmd="netdata_savedb"
netdata_prestart()
{
+ [ ! -d "${piddir}" ] && mkdir -p "${piddir}"
return 0
}
netdata_poststop()
{
+ [ -f "${pidfile}" ] && rm "${pidfile}"
return 0
}
diff --git a/system/netdata-init-d.in b/system/netdata-init-d.in
index 90a4b95b..9ac51019 100644
--- a/system/netdata-init-d.in
+++ b/system/netdata-init-d.in
@@ -1,4 +1,5 @@
#!/bin/sh
+# SPDX-License-Identifier: GPL-3.0-or-later
#
# netdata Real-time performance monitoring, done right
# chkconfig: 345 99 01
@@ -13,7 +14,8 @@
DAEMON="netdata"
DAEMON_PATH=@sbindir_POST@
-PIDFILE=@localstatedir_POST@/run/$DAEMON.pid
+PIDFILE_PATH=@localstatedir_POST@/run/netdata
+PIDFILE=$PIDFILE_PATH/$DAEMON.pid
DAEMONOPTS="-P $PIDFILE"
STOP_TIMEOUT="60"
@@ -24,6 +26,7 @@ LOCKFILE=/var/lock/subsys/$DAEMON
service_start()
{
[ -x $DAEMON_PATH ] || exit 5
+ [ ! -d $PIDFILE_PATH ] && mkdir -p $PIDFILE_PATH
echo -n "Starting $DAEMON..."
daemon $DAEMON_PATH/$DAEMON $DAEMONOPTS
RETVAL=$?
diff --git a/system/netdata-lsb.in b/system/netdata-lsb.in
index 3bbde1a4..e623f1e0 100644
--- a/system/netdata-lsb.in
+++ b/system/netdata-lsb.in
@@ -1,4 +1,5 @@
#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0-or-later
#
### BEGIN INIT INFO
# Provides: netdata
@@ -19,7 +20,8 @@ ${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
DAEMON="netdata"
DAEMON_PATH=@sbindir_POST@
-PIDFILE=@localstatedir_POST@/run/$DAEMON.pid
+PIDFILE_PATH=@localstatedir_POST@/run/netdata
+PIDFILE=$PIDFILE_PATH/$DAEMON.pid
DAEMONOPTS="-P $PIDFILE"
test -x $DAEMON_PATH/$DAEMON || exit 0
@@ -31,6 +33,10 @@ cd /
umask 022
service_start() {
+ if [ ! -d $PIDFILE_PATH ]; then
+ mkdir -p $PIDFILE_PATH
+ fi
+
log_daemon_msg "Starting real-time performance monitoring" "netdata"
start_daemon -p $PIDFILE $DAEMON_PATH/$DAEMON $DAEMONOPTS
RETVAL=$?
diff --git a/system/netdata-openrc.in b/system/netdata-openrc.in
index ce76f7e6..e0070526 100644
--- a/system/netdata-openrc.in
+++ b/system/netdata-openrc.in
@@ -1,84 +1,58 @@
#!/sbin/openrc-run
+# SPDX-License-Identifier: GPL-3.0-or-later
# The user netdata is configured to run as.
# If you edit its configuration file to set a different
# user, set it here too, to have its files switch ownership
-: ${NETDATA_OWNER:=netdata:netdata}
-
-# The URL to download netdata config.
-: ${NETDATA_CONFIG_URL:=http://localhost:19999/netdata.conf}
+: "${NETDATA_OWNER:=netdata:netdata}"
# The timeout in seconds to wait for netdata
# to save its database on disk and exit.
-: ${NETDATA_WAIT_EXIT_TIMEOUT:=60}
+: "${NETDATA_WAIT_EXIT_TIMEOUT:=60}"
# When set to 1, if netdata does not exit in
# NETDATA_WAIT_EXIT_TIMEOUT, we will force it
# to exit.
-: ${NETDATA_FORCE_EXIT:=0}
+: "${NETDATA_FORCE_EXIT:=0}"
# Netdata will use these services, only if they
# are enabled to start.
-: ${NETDATA_START_AFTER_SERVICES:=apache2 squid nginx mysql named opensips upsd hostapd postfix lm_sensors}
+: "${NETDATA_START_AFTER_SERVICES:=apache2 squid nginx mysql named opensips upsd hostapd postfix lm_sensors}"
-extra_started_commands="getconf"
-pidfile="/run/netdata.pid"
+extra_started_commands="reload rotate save"
+pidfile="@localstatedir_POST@/run/netdata/netdata.pid"
command="@sbindir_POST@/netdata"
-command_background="yes"
command_args="-P ${pidfile} ${NETDATA_EXTRA_ARGS}"
-# start_stop_daemon_args="-u ${NETDATA_OWNER}"
-start_stop_daemon_args=""
+start_stop_daemon_args="-u ${NETDATA_OWNER}"
+required_files="/etc/netdata/netdata.conf"
+if [ "${NETDATA_FORCE_EXIT}" -eq 1 ]; then
+ retry="TERM/${NETDATA_WAIT_EXIT_TIMEOUT}/KILL/1"
+else
+ retry="TERM/${NETDATA_WAIT_EXIT_TIMEOUT}"
+fi
depend() {
- use logger
- need net
- after ${NETDATA_START_AFTER_SERVICES}
+ use logger
+ need net
+ after ${NETDATA_START_AFTER_SERVICES}
- checkpath -o ${NETDATA_OWNER} -d @localstatedir_POST@/cache/netdata /run/netdata
+ checkpath -o ${NETDATA_OWNER} -d @localstatedir_POST@/cache/netdata @localstatedir_POST@/run/netdata
}
-start_post() {
- if [ ! -f @sysconfdir_POST@/netdata/netdata.conf ]; then
- ebegin "Downloading default configuration to @sysconfdir_POST@/netdata/netdata.conf"
- sleep 2
- curl -s -o @sysconfdir_POST@/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
- ret=$?
- if [ $ret -eq 0 && -s @sysconfdir_POST@/netdata/netdata.conf.new ]; then
- mv @sysconfdir_POST@/netdata/netdata.conf.new @sysconfdir_POST@/netdata/netdata.conf
- else
- ret=1
- rm @sysconfdir_POST@/netdata/netdata.conf.new 2>/dev/null
- fi
- eend $ret
- fi
+reload() {
+ ebegin "Reloading Netdata"
+ start-stop-daemon --signal SIGUSR2 --pidfile "${pidfile}"
+ eend $? "Failed to reload Netdata"
}
-stop_post() {
- local result ret=0 count=0 sigkill=0
-
- ebegin "Waiting for netdata to save its database"
- while [ -f "${pidfile}" ]; do
- if [ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]; then
- sigkill=1
- break
- fi
-
- count=$((count + 1))
- kill -0 $(cat ${pidfile}) 2>/dev/null
- ret=$?
- test $ret -eq 0 && sleep 1
- done
- eend $sigkill
-
- if [ $sigkill -eq 1 -a -f "${pidfile}" ]; then
- ebegin "Netdata is taking too long to exit, forcing it to quit"
- kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
- eend $?
- fi
+rotate() {
+ ebegin "Logrotating Netdata"
+ start-stop-daemon --signal SIGHUP --pidfile "${pidfile}"
+ eend $? "Failed to logrotate Netdata"
}
-getconf() {
- ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
- curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"
- eend $?
+save() {
+ ebegin "Saving Netdata database"
+ start-stop-daemon --signal SIGUSR1 --pidfile "${pidfile}"
+ eend $? "Failed to save Netdata database"
}
diff --git a/system/netdata.logrotate.in b/system/netdata.logrotate.in
index ae1ac50a..a766b6cc 100644
--- a/system/netdata.logrotate.in
+++ b/system/netdata.logrotate.in
@@ -7,6 +7,6 @@
notifempty
sharedscripts
postrotate
- /bin/kill -HUP `pidof netdata 2>/dev/null` 2>/dev/null || true
+ /bin/kill -HUP `cat @localstatedir_POST@/run/netdata/netdata.pid 2>/dev/null` 2>/dev/null || true
endscript
}
diff --git a/system/netdata.plist.in b/system/netdata.plist.in
new file mode 100644
index 00000000..a969b317
--- /dev/null
+++ b/system/netdata.plist.in
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>com.github.netdata</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>@sbindir_POST@/netdata</string>
+ </array>
+ <key>RunAtLoad</key>
+ <true/>
+</dict>
+</plist>
diff --git a/system/netdata.service.in b/system/netdata.service.in
index 58cdff22..dd0ee3cc 100644
--- a/system/netdata.service.in
+++ b/system/netdata.service.in
@@ -1,5 +1,8 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
[Unit]
Description=Real time performance monitoring
+
+# append here other services you want netdata to wait for them to start
After=network.target httpd.service squid.service nfs-server.service mysqld.service mysql.service named.service postfix.service chronyd.service
[Service]
@@ -8,9 +11,13 @@ User=netdata
Group=netdata
RuntimeDirectory=netdata
RuntimeDirectoryMode=0775
-ExecStart=@sbindir_POST@/netdata -P /run/netdata/netdata.pid -D
+PIDFile=@localstatedir_POST@/run/netdata/netdata.pid
+ExecStart=@sbindir_POST@/netdata -P @localstatedir_POST@/run/netdata/netdata.pid -D -W set global 'process scheduling policy' 'keep' -W set global 'OOM score' 'keep'
ExecStartPre=/bin/mkdir -p @localstatedir_POST@/cache/netdata
ExecStartPre=/bin/chown -R netdata:netdata @localstatedir_POST@/cache/netdata
+ExecStartPre=/bin/mkdir -p @localstatedir_POST@/run/netdata
+ExecStartPre=/bin/chown -R netdata:netdata @localstatedir_POST@/run/netdata
+#ExecStopPost=/bin/rm @localstatedir_POST@/run/netdata/netdata.pid
PermissionsStartOnly=true
# saving a big db on slow disks may need some time
@@ -24,20 +31,17 @@ RestartSec=30
# netdata (via [global].OOM score in netdata.conf) can only increase the value set here.
# To decrease it, set the minimum here and set the same or a higher value in netdata.conf.
# Valid values: -1000 (never kill netdata) to 1000 (always kill netdata).
-#OOMScoreAdjust=0
+OOMScoreAdjust=1000
-# By default netdata switches to scheduling policy idle, which makes it use CPU, only
-# when there is spare available.
# Valid policies: other (the system default) | batch | idle | fifo | rr
-#CPUSchedulingPolicy=other
+# To give netdata the max priority, set CPUSchedulingPolicy=rr and CPUSchedulingPriority=99
+CPUSchedulingPolicy=idle
-# This sets the maximum scheduling priority netdata can set (for policies: rr and fifo).
-# netdata (via [global].process scheduling priority in netdata.conf) can only lower this value.
+# This sets the scheduling priority (for policies: rr and fifo).
# Priority gets values 1 (lowest) to 99 (highest).
#CPUSchedulingPriority=1
-# For scheduling policy 'other' and 'batch', this sets the lowest niceness of netdata.
-# netdata (via [global].process nice level in netdata.conf) can only increase the value set here.
+# For scheduling policy 'other' and 'batch', this sets the lowest niceness of netdata (-20 highest to 19 lowest).
#Nice=0
[Install]