diff options
-rw-r--r-- | .gitignore | 8 | ||||
-rwxr-xr-x | CMakeLists.txt | 2 | ||||
-rw-r--r-- | build/subst.inc | 3 | ||||
-rw-r--r-- | conf.d/Makefile.am | 14 | ||||
-rw-r--r-- | conf.d/python.d/cpuidle.conf | 40 | ||||
-rw-r--r-- | conf.d/statsd.d/example.conf | 18 | ||||
-rw-r--r-- | configs.signatures | 1 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rwxr-xr-x | makeself/install-or-update.sh | 97 | ||||
-rwxr-xr-x | makeself/jobs/70-netdata-git.install.sh | 7 | ||||
-rwxr-xr-x | makeself/jobs/99-makeself.install.sh | 21 | ||||
-rwxr-xr-x | netdata-installer.sh | 181 | ||||
-rw-r--r-- | netdata.spec.in | 24 | ||||
-rw-r--r-- | plugins.d/Makefile.am | 23 | ||||
-rwxr-xr-x | plugins.d/alarm-notify.sh.in (renamed from plugins.d/alarm-notify.sh) | 29 | ||||
-rwxr-xr-x | plugins.d/cgroup-name.sh.in (renamed from plugins.d/cgroup-name.sh) | 26 | ||||
-rwxr-xr-x | plugins.d/charts.d.plugin.in (renamed from plugins.d/charts.d.plugin) | 83 | ||||
-rwxr-xr-x | plugins.d/fping.plugin.in (renamed from plugins.d/fping.plugin) | 33 | ||||
-rwxr-xr-x | plugins.d/node.d.plugin.in (renamed from plugins.d/node.d.plugin) | 93 | ||||
-rwxr-xr-x | plugins.d/python.d.plugin.in (renamed from plugins.d/python.d.plugin) | 58 | ||||
-rwxr-xr-x | plugins.d/tc-qos-helper.sh.in (renamed from plugins.d/tc-qos-helper.sh) | 19 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/apps_plugin.c | 38 | ||||
-rw-r--r-- | src/common.c | 209 | ||||
-rw-r--r-- | src/common.h | 10 | ||||
-rw-r--r-- | src/health.c | 15 | ||||
-rw-r--r-- | src/health.h | 7 | ||||
-rw-r--r-- | src/health_config.c | 243 | ||||
-rw-r--r-- | src/main.c | 79 | ||||
-rw-r--r-- | src/rrdhost.c | 2 | ||||
-rw-r--r-- | src/statsd.c | 110 | ||||
-rw-r--r-- | src/unit_test.c | 42 |
32 files changed, 956 insertions, 581 deletions
diff --git a/.gitignore b/.gitignore index aba1c3d5f0..da1f165ae6 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,14 @@ system/netdata.service system/netdata.plist system/netdata-freebsd +plugins.d/alarm-notify.sh +plugins.d/cgroup-name.sh +plugins.d/charts.d.plugin +plugins.d/fping.plugin +plugins.d/node.d.plugin +plugins.d/python.d.plugin +plugins.d/tc-qos-helper.sh + # installer generated files netdata-uninstaller.sh netdata-updater.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 927495be61..5b91a748bc 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,7 +250,7 @@ set(CGROUP_NETWORK_SOURCE_FILES include_directories(AFTER .) -add_definitions(-DHAVE_CONFIG_H -DCACHE_DIR="/var/cache/netdata" -DCONFIG_DIR="/etc/netdata" -DLOG_DIR="/var/log/netdata" -DPLUGINS_DIR="/usr/libexec/netdata" -DWEB_DIR="/usr/share/netdata" -DVARLIB_DIR="/var/lib/netdata") +add_definitions(-DHAVE_CONFIG_H -DCACHE_DIR="/var/cache/netdata" -DCONFIG_DIR="/etc/netdata" -DLIBCONFIG_DIR="/usr/lib/netdata/conf.d" -DLOG_DIR="/var/log/netdata" -DPLUGINS_DIR="/usr/libexec/netdata" -DWEB_DIR="/usr/share/netdata" -DVARLIB_DIR="/var/lib/netdata") add_executable(netdata ${NETDATA_COMMON_FILES} ${NETDATA_LINUX_FILES}) target_link_libraries (netdata m z uuid mnl netfilter_acct ${CMAKE_THREAD_LIBS_INIT}) diff --git a/build/subst.inc b/build/subst.inc index 9682cf882f..8f9ac05518 100644 --- a/build/subst.inc +++ b/build/subst.inc @@ -4,6 +4,9 @@ -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/conf.d/Makefile.am b/conf.d/Makefile.am index cc60ff1dd9..817d366d27 100644 --- a/conf.d/Makefile.am +++ b/conf.d/Makefile.am @@ -4,7 +4,7 @@ # MAINTAINERCLEANFILES= $(srcdir)/Makefile.in -dist_config_DATA = \ +dist_libconfig_DATA = \ apps_groups.conf \ charts.d.conf \ fping.conf \ @@ -15,7 +15,7 @@ dist_config_DATA = \ stream.conf \ $(NULL) -nodeconfigdir=$(configdir)/node.d +nodeconfigdir=$(libconfigdir)/node.d dist_nodeconfig_DATA = \ node.d/README.md \ node.d/fronius.conf.md \ @@ -25,7 +25,7 @@ dist_nodeconfig_DATA = \ node.d/stiebeleltron.conf.md \ $(NULL) -pythonconfigdir=$(configdir)/python.d +pythonconfigdir=$(libconfigdir)/python.d dist_pythonconfig_DATA = \ python.d/apache.conf \ python.d/beanstalk.conf \ @@ -34,6 +34,7 @@ dist_pythonconfig_DATA = \ python.d/ceph.conf \ python.d/chrony.conf \ python.d/couchdb.conf \ + python.d/cpuidle.conf \ python.d/cpufreq.conf \ python.d/dns_query_time.conf \ python.d/dnsdist.conf \ @@ -88,8 +89,7 @@ dist_pythonconfig_DATA = \ python.d/web_log.conf \ $(NULL) -healthconfigdir=$(configdir)/health.d - +healthconfigdir=$(libconfigdir)/health.d dist_healthconfig_DATA = \ health.d/apache.conf \ health.d/apcupsd.conf \ @@ -148,7 +148,7 @@ dist_healthconfig_DATA = \ health.d/zfs.conf \ $(NULL) -chartsconfigdir=$(configdir)/charts.d +chartsconfigdir=$(libconfigdir)/charts.d dist_chartsconfig_DATA = \ charts.d/apache.conf \ charts.d/apcupsd.conf \ @@ -172,7 +172,7 @@ dist_chartsconfig_DATA = \ charts.d/squid.conf \ $(NULL) -statsdconfigdir=$(configdir)/statsd.d +statsdconfigdir=$(libconfigdir)/statsd.d dist_statsdconfig_DATA = \ statsd.d/example.conf \ $(NULL) diff --git a/conf.d/python.d/cpuidle.conf b/conf.d/python.d/cpuidle.conf new file mode 100644 index 0000000000..bc276fcd2a --- /dev/null +++ b/conf.d/python.d/cpuidle.conf @@ -0,0 +1,40 @@ +# netdata python.d.plugin configuration for cpuidle +# +# This file is in YaML format. Generally the format is: +# +# name: value +# +# There are 2 sections: +# - global variables +# - one or more JOBS +# +# JOBS allow you to collect values from multiple sources. +# Each source will have its own set of charts. +# +# JOB parameters have to be indented (using spaces only, example below). + +# ---------------------------------------------------------------------- +# Global Variables +# These variables set the defaults for all JOBs, however each JOB +# may define its own, overriding the defaults. + +# update_every sets the default data collection frequency. +# If unset, the python.d.plugin default is used. +# update_every: 1 + +# priority controls the order of charts at the netdata dashboard. +# Lower numbers move the charts towards the top of the page. +# If unset, the default for python.d.plugin is used. +# priority: 60000 + +# retries sets the number of retries to be made in case of failures. +# If unset, the default for python.d.plugin is used. +# Attempts to restore the service are made once every update_every +# and only if the module has collected values in the past. +# retries: 60 + +# autodetection_retry sets the job re-check interval in seconds. +# The job is not deleted if check fails. +# Attempts to start the job are made once every autodetection_retry. +# This feature is disabled by default. +# autodetection_retry: 0 diff --git a/conf.d/statsd.d/example.conf b/conf.d/statsd.d/example.conf index 0af9dd27dd..f7c12b4ab3 100644 --- a/conf.d/statsd.d/example.conf +++ b/conf.d/statsd.d/example.conf @@ -7,10 +7,10 @@ # give a name for this app # this controls the main menu on the dashboard # and will be the prefix for all charts of the app - name = myapp + name = myexampleapp # match all the metrics of the app - metrics = myapp.* + metrics = myexampleapp.* # shall private charts of these metrics be created? private charts = no @@ -29,10 +29,10 @@ # create a chart -# this is its id - the chart will be named myapp.mychart -[mychart] +# this is its id - the chart will be named myexampleapp.myexamplechart +[myexamplechart] # a name for the chart, similar to the id (2 names for each chart) - name = mychart + name = myexamplechart # the chart title title = my chart title @@ -57,9 +57,9 @@ # events = the number of events for this metric # last = the last value collected # all the others are only valid for histograms and timers - dimension = myapp.metric1 avg average 1 1 - dimension = myapp.metric1 lower min 1 1 - dimension = myapp.metric1 upper max 1 1 - dimension = myapp.metric2 other last 1 1 + dimension = myexampleapp.metric1 avg average 1 1 + dimension = myexampleapp.metric1 lower min 1 1 + dimension = myexampleapp.metric1 upper max 1 1 + dimension = myexampleapp.metric2 other last 1 1 # You can add as many charts as needed diff --git a/configs.signatures b/configs.signatures index 3e546a953f..c084de8cff 100644 --- a/configs.signatures +++ b/configs.signatures @@ -65,6 +65,7 @@ declare -A configs_signatures=( ['111ead4b350593dd69b6f7ac0307b49b']='python.d/httpcheck.conf' ['12a4c7803ae79506a14ea784fea60dce']='health.d/net.conf' ['12d27b9f4d1696c2d49a77ed71d68e6f']='python.d/w1sensor.conf' + ['12e57bea1127933a4fe49ce2e9674f4d']='statsd.d/example.conf' ['13141998a5d71308d9c119834c27bfd3']='python.d.conf' ['13ccf65fd879795f0fcea89ade27c2d0']='health.d/swap.conf' ['13e861a3d2f3075de883994ab54df658']='health.d/megacli.conf' diff --git a/configure.ac b/configure.ac index 9c98adfd67..b60419da01 100644 --- a/configure.ac +++ b/configure.ac @@ -493,6 +493,7 @@ AC_SUBST([chartsdir], ["\$(libexecdir)/netdata/charts.d"]) AC_SUBST([nodedir], ["\$(libexecdir)/netdata/node.d"]) AC_SUBST([pythondir], ["\$(libexecdir)/netdata/python.d"]) AC_SUBST([configdir], ["\$(sysconfdir)/netdata"]) +AC_SUBST([libconfigdir], ["\$(libdir)/netdata/conf.d"]) AC_SUBST([logdir], ["\$(localstatedir)/log/netdata"]) AC_SUBST([pluginsdir], ["\$(libexecdir)/netdata/plugins.d"]) AC_SUBST([webdir]) diff --git a/makeself/install-or-update.sh b/makeself/install-or-update.sh index 6ff03acc09..ce9ca62023 100755 --- a/makeself/install-or-update.sh +++ b/makeself/install-or-update.sh @@ -24,62 +24,49 @@ do shift done +deleted_stock_configs=0 +if [ ! -f "etc/netdata/.installer-cleanup-of-stock-configs-done" ] +then -# ----------------------------------------------------------------------------- -progress "Checking new configuration files" - -declare -A configs_signatures=() -. system/configs.signatures - -if [ ! -d etc/netdata ] - then - run mkdir -p etc/netdata -fi - -md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null || command -v md5 2>/dev/null)" -for x in $(find etc.new -type f) -do - # find it relative filename - f="${x/etc.new\/netdata\//}" - t="${x/etc.new\//etc\/}" - d=$(dirname "${t}") + # ----------------------------------------------------------------------------- + progress "Deleting stock configuration files from user configuration directory" - #echo >&2 "x: ${x}" - #echo >&2 "t: ${t}" - #echo >&2 "d: ${d}" + declare -A configs_signatures=() + source "system/configs.signatures" - if [ ! -d "${d}" ] + if [ ! -d etc/netdata ] then - run mkdir -p "${d}" + run mkdir -p etc/netdata fi - if [ ! -f "${t}" ] - then - run cp "${x}" "${t}" - continue - fi + md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null || command -v md5 2>/dev/null)" + for x in $(find etc -type f) + do + # find it relative filename + f="${x/etc\/netdata\//}" - if [ ! -z "${md5sum}" ] - then - # find the checksum of the existing file - md5="$(cat "${t}" | ${md5sum} | cut -d ' ' -f 1)" - #echo >&2 "md5: ${md5}" + # find the stock filename + t="${f/.conf.old/.conf}" + t="${t/.conf.orig/.conf}" - # check if it matches - if [ "${configs_signatures[${md5}]}" = "${f}" ] + if [ ! -z "${md5sum}" ] then - run cp "${x}" "${t}" + # find the checksum of the existing file + md5="$( ${md5sum} <"${x}" | cut -d ' ' -f 1)" + #echo >&2 "md5: ${md5}" + + # check if it matches + if [ "${configs_signatures[${md5}]}" = "${t}" ] + then + # it matches the default + run rm -f "${x}" + deleted_stock_configs=$(( deleted_stock_configs + 1 )) + fi fi - fi - - if ! [[ "${x}" =~ .*\.orig ]] - then - run mv "${x}" "${t}.orig" - fi -done - -run rm -rf etc.new + done + touch "etc/netdata/.installer-cleanup-of-stock-configs-done" +fi # ----------------------------------------------------------------------------- progress "Add user netdata to required user groups" @@ -166,6 +153,26 @@ dir_should_be_link . var/lib/netdata netdata-dbs dir_should_be_link . var/cache/netdata netdata-metrics dir_should_be_link . var/log/netdata netdata-logs +dir_should_be_link etc/netdata ../../usr/lib/netdata/conf.d orig + +if [ ${deleted_stock_configs} -gt 0 ] +then + dir_should_be_link etc/netdata ../../usr/lib/netdata/conf.d "000.-.USE.THE.orig.LINK.TO.COPY.AND.EDIT.STOCK.CONFIG.FILES" +fi + + +# ----------------------------------------------------------------------------- + +progress "create user config directories" + +for x in "python.d" "charts.d" "node.d" "health.d" "statsd.d" +do + if [ ! -d "etc/netdata/${x}" ] + then + run mkdir -p "etc/netdata/${x}" || exit 1 + fi +done + # ----------------------------------------------------------------------------- progress "fix permissions" diff --git a/makeself/jobs/70-netdata-git.install.sh b/makeself/jobs/70-netdata-git.install.sh index ca1143045e..cb28dd080f 100755 --- a/makeself/jobs/70-netdata-git.install.sh +++ b/makeself/jobs/70-netdata-git.install.sh @@ -13,13 +13,6 @@ else # export CFLAGS="-static -O1 -ggdb -Wall -Wextra -Wformat-signedness" fi -if [ ! -z "${NETDATA_INSTALL_PATH}" -a -d "${NETDATA_INSTALL_PATH}/etc" ] - then - # make sure we don't have an old etc path, so that the installer - # will install all files without examining changes - run mv "${NETDATA_INSTALL_PATH}/etc" "${NETDATA_INSTALL_PATH}/etc.new" -fi - run ./netdata-installer.sh --install "${NETDATA_INSTALL_PARENT}" \ --dont-wait \ --dont-start-it \ diff --git a/makeself/jobs/99-makeself.install.sh b/makeself/jobs/99-makeself.install.sh index ba1c46fb5d..0b828257d5 100755 --- a/makeself/jobs/99-makeself.install.sh +++ b/makeself/jobs/99-makeself.install.sh @@ -73,27 +73,6 @@ run chmod 755 "${NETDATA_INSTALL_PATH}/bin/netdata" # ----------------------------------------------------------------------------- -# move etc to protect the destination when unpacked - -if [ ! -z "${NETDATA_INSTALL_PATH}" -a -d "${NETDATA_INSTALL_PATH}/etc" ] - then - if [ -d "${NETDATA_INSTALL_PATH}/etc.new" ] - then - run rm -rf "${NETDATA_INSTALL_PATH}/etc.new" || exit 1 - fi - - run mv "${NETDATA_INSTALL_PATH}/etc" \ - "${NETDATA_INSTALL_PATH}/etc.new" || exit 1 - - if [ -f "${NETDATA_INSTALL_PATH}/etc.new/netdata/netdata.conf" ] - then - # delete the generated netdata.conf, so that the static installer will generate a new one - run rm "${NETDATA_INSTALL_PATH}/etc.new/netdata/netdata.conf" - fi -fi - - -# ----------------------------------------------------------------------------- # remove the links to allow untaring the archive run rm "${NETDATA_INSTALL_PATH}/sbin" \ diff --git a/netdata-installer.sh b/netdata-installer.sh index 738463ee00..0484cb35b6 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -492,6 +492,7 @@ progress "Cleanup compilation directory" [ -f src/netdata ] && run make clean + # ----------------------------------------------------------------------------- progress "Compile netdata" @@ -543,79 +544,76 @@ if [ -d "${NETDATA_PREFIX}/etc/netdata" ] fi # ----------------------------------------------------------------------------- -progress "Backup existing netdata configuration before installing it" - -if [ "${BASH_VERSINFO[0]}" -ge "4" ] +deleted_stock_configs=0 +if [ ! -f "${NETDATA_PREFIX}/etc/netdata/.installer-cleanup-of-stock-configs-done" ] then - declare -A configs_signatures=() - if [ -f "configs.signatures" ] - then - source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !" - fi -fi -config_signature_matches() { - local md5="${1}" file="${2}" + progress "Backup existing netdata configuration before installing it" if [ "${BASH_VERSINFO[0]}" -ge "4" ] - then - [ "${configs_signatures[${md5}]}" = "${file}" ] && return 0 - return 1 + then + declare -A configs_signatures=() + if [ -f "configs.signatures" ] + then + source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !" + fi fi - if [ -f "configs.signatures" ] - then - grep "\['${md5}'\]='${file}'" "configs.signatures" >/dev/null - return $? - fi + config_signature_matches() { + local md5="${1}" file="${2}" - return 1 -} + if [ "${BASH_VERSINFO[0]}" -ge "4" ] + then + [ "${configs_signatures[${md5}]}" = "${file}" ] && return 0 + return 1 + fi -# backup user configurations -installer_backup_suffix="${PID}.${RANDOM}" -for x in $(find -L "${NETDATA_PREFIX}/etc/netdata" -name '*.conf' -type f) -do - if [ -f "${x}" ] - then - # make a backup of the configuration file - cp -p "${x}" "${x}.old" + if [ -f "configs.signatures" ] + then + grep "\['${md5}'\]='${file}'" "configs.signatures" >/dev/null + return $? + fi - if [ -z "${md5sum}" -o ! -x "${md5sum}" ] + return 1 + } + + # clean up stock config files from the user configuration directory + for x in $(find -L "${NETDATA_PREFIX}/etc/netdata" -type f) + do + if [ -f "${x}" ] then - # we don't have md5sum - keep it - echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RET}is not known to distribution${TPUT_RESET}. Keeping it." - run cp -a "${x}" "${x}.installer_backup.${installer_backup_suffix}" - else # find it relative filename - f="${x/*\/etc\/netdata\//}" - - # find its checksum - md5="$(cat "${x}" | ${md5sum} | cut -d ' ' -f 1)" + f="${x/${NETDATA_PREFIX}\/etc\/netdata\//}" - # copy the original - if [ -f "conf.d/${f}" ] - then - cp "conf.d/${f}" "${x}.orig" - fi + # find the stock filename + t="${f/.conf.installer_backup.*/.conf}" + t="${t/.conf.old/.conf}" + t="${t/.conf.orig/.conf}" - if config_signature_matches "${md5}" "${f}" + if [ -z "${md5sum}" -o ! -x "${md5sum}" ] then - # it is a stock version - don't keep it - echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' is stock version." + # we don't have md5sum - keep it + echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RET}is not known to distribution${TPUT_RESET}. Keeping it." else - # edited by user - keep it - echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED} has been edited by user${TPUT_RESET}. Keeping it." - run cp -a "${x}" "${x}.installer_backup.${installer_backup_suffix}" + # find its checksum + md5="$(${md5sum} <"${x}" | cut -d ' ' -f 1)" + + if config_signature_matches "${md5}" "${t}" + then + # it is a stock version - remove it + echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' is stock version of '${t}'." + run rm -f "${x}" + deleted_stock_configs=$(( deleted_stock_configs + 1 )) + else + # edited by user - keep it + echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED} does not match stock of '${t}'${TPUT_RESET}. Keeping it." + fi fi fi + done - elif [ -f "${x}.installer_backup.${installer_backup_suffix}" ] - then - rm -f "${x}.installer_backup.${installer_backup_suffix}" - fi -done - + touch "${NETDATA_PREFIX}/etc/netdata/.installer-cleanup-of-stock-configs-done" +fi # ----------------------------------------------------------------------------- progress "Install netdata" @@ -624,19 +622,6 @@ run make install || exit 1 # ----------------------------------------------------------------------------- -progress "Restore user edited netdata configuration files" - -for x in $(find -L "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f) -do - if [ -f "${x}.installer_backup.${installer_backup_suffix}" ] - then - run cp -a "${x}.installer_backup.${installer_backup_suffix}" "${x}" && \ - run rm -f "${x}.installer_backup.${installer_backup_suffix}" - fi -done - - -# ----------------------------------------------------------------------------- progress "Fix generated files permissions" run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.logrotate -exec chmod 755 {} \; @@ -709,28 +694,30 @@ NETDATA_LIB_DIR="$( config_option "global" "lib directory" "${NETDATA_PREFIX}/va NETDATA_CACHE_DIR="$( config_option "global" "cache directory" "${NETDATA_PREFIX}/var/cache/netdata" )" NETDATA_WEB_DIR="$( config_option "global" "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )" NETDATA_LOG_DIR="$( config_option "global" "log directory" "${NETDATA_PREFIX}/var/log/netdata" )" -NETDATA_CONF_DIR="$( config_option "global" "config directory" "${NETDATA_PREFIX}/etc/netdata" )" +NETDATA_USER_CONFIG_DIR="$( config_option "global" "config directory" "${NETDATA_PREFIX}/etc/netdata" )" +NETDATA_STOCK_CONFIG_DIR="$( config_option "global" "stock config directory" "${NETDATA_PREFIX}/usr/lib/netdata/conf.d" )" NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run" cat <<OPTIONSEOF Permissions - - netdata user : ${NETDATA_USER} - - netdata group : ${NETDATA_GROUP} - - web files user : ${NETDATA_WEB_USER} - - web files group : ${NETDATA_WEB_GROUP} - - root user : ${ROOT_USER} + - netdata user : ${NETDATA_USER} + - netdata group : ${NETDATA_GROUP} + - web files user : ${NETDATA_WEB_USER} + - web files group : ${NETDATA_WEB_GROUP} + - root user : ${ROOT_USER} Directories - - netdata conf dir : ${NETDATA_CONF_DIR} - - netdata log dir : ${NETDATA_LOG_DIR} - - netdata run dir : ${NETDATA_RUN_DIR} - - netdata lib dir : ${NETDATA_LIB_DIR} - - netdata web dir : ${NETDATA_WEB_DIR} - - netdata cache dir: ${NETDATA_CACHE_DIR} + - netdata user config dir : ${NETDATA_USER_CONFIG_DIR} + - netdata stock config dir : ${NETDATA_STOCK_CONFIG_DIR} + - netdata log dir : ${NETDATA_LOG_DIR} + - netdata run dir : ${NETDATA_RUN_DIR} + - netdata lib dir : ${NETDATA_LIB_DIR} + - netdata web dir : ${NETDATA_WEB_DIR} + - netdata cache dir : ${NETDATA_CACHE_DIR} Other - - netdata port : ${NETDATA_PORT} + - netdata port : ${NETDATA_PORT} OPTIONSEOF @@ -745,17 +732,35 @@ fi # --- conf dir ---- -for x in "python.d" "charts.d" "node.d" +for x in "python.d" "charts.d" "node.d" "health.d" "statsd.d" do - if [ ! -d "${NETDATA_CONF_DIR}/${x}" ] + if [ ! -d "${NETDATA_USER_CONFIG_DIR}/${x}" ] then - echo >&2 "Creating directory '${NETDATA_CONF_DIR}/${x}'" - run mkdir -p "${NETDATA_CONF_DIR}/${x}" || exit 1 + echo >&2 "Creating directory '${NETDATA_USER_CONFIG_DIR}/${x}'" + run mkdir -p "${NETDATA_USER_CONFIG_DIR}/${x}" || exit 1 + fi +done +run chown -R "${ROOT_USER}:${NETDATA_GROUP}" "${NETDATA_USER_CONFIG_DIR}" +run find "${NETDATA_USER_CONFIG_DIR}" -type f -exec chmod 0640 {} \; +run find "${NETDATA_USER_CONFIG_DIR}" -type d -exec chmod 0755 {} \; + +# --- stock conf dir ---- + +[ ! -d "${NETDATA_STOCK_CONFIG_DIR}" ] && mkdir -p "${NETDATA_STOCK_CONFIG_DIR}" + +helplink="000.-.USE.THE.orig.LINK.TO.COPY.AND.EDIT.STOCK.CONFIG.FILES" +[ ${deleted_stock_configs} -eq 0 ] && helplink="" +for link in "orig" "${helplink}" +do + if [ ! -z "${link}" ] + then + [ -L "${NETDATA_USER_CONFIG_DIR}/${link}" ] && run rm -f "${NETDATA_USER_CONFIG_DIR}/${link}" + run ln -s "${NETDATA_STOCK_CONFIG_DIR}" "${NETDATA_USER_CONFIG_DIR}/${link}" fi done -run chown -R "${ROOT_USER}:${NETDATA_GROUP}" "${NETDATA_CONF_DIR}" -run find "${NETDATA_CONF_DIR}" -type f -exec chmod 0640 {} \; -run find "${NETDATA_CONF_DIR}" -type d -exec chmod 0755 {} \; +run chown -R "${ROOT_USER}:${NETDATA_GROUP}" "${NETDATA_STOCK_CONFIG_DIR}" +run find "${NETDATA_STOCK_CONFIG_DIR}" -type f -exec chmod 0640 {} \; +run find "${NETDATA_STOCK_CONFIG_DIR}" -type d -exec chmod 0755 {} \; # --- web dir ---- diff --git a/netdata.spec.in b/netdata.spec.in index f948e495ff..379088fa11 100644 --- a/netdata.spec.in +++ b/netdata.spec.in @@ -181,17 +181,18 @@ rm -rf "${RPM_BUILD_ROOT}" %defattr(-,root,root) %dir %{_sysconfdir}/%{name} +%dir %{_libdir}/%{name} -%config(noreplace) %{_sysconfdir}/%{name}/*.conf -%config(noreplace) %{_sysconfdir}/%{name}/charts.d/*.conf -%config(noreplace) %{_sysconfdir}/%{name}/health.d/*.conf -#%%config(noreplace) %{_sysconfdir}/%{name}/node.d/*.conf -%config(noreplace) %{_sysconfdir}/%{name}/python.d/*.conf -%config(noreplace) %{_sysconfdir}/%{name}/statsd.d/*.conf -%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%config %{_libdir}/%{name}/*.conf +%config %{_libdir}/%{name}/charts.d/*.conf +%config %{_libdir}/%{name}/health.d/*.conf +%config %{_libdir}/%{name}/node.d/*.conf +%config %{_libdir}/%{name}/python.d/*.conf +%config %{_libdir}/%{name}/statsd.d/*.conf +%config %{_sysconfdir}/logrotate.d/%{name} # To be eventually moved to %%_defaultdocdir -%{_sysconfdir}/%{name}/node.d/*.md +%{_libdir}/%{name}/node.d/*.md %{_libexecdir}/%{name} %{_sbindir}/%{name} @@ -215,9 +216,16 @@ rm -rf "${RPM_BUILD_ROOT}" %dir %{_datadir}/%{name} %dir %{_sysconfdir}/%{name}/health.d +%dir %{_libdir}/%{name}/health.d %dir %{_sysconfdir}/%{name}/python.d +%dir %{_libdir}/%{name}/python.d %dir %{_sysconfdir}/%{name}/charts.d +%dir %{_libdir}/%{name}/charts.d %dir %{_sysconfdir}/%{name}/node.d +%dir %{_libdir}/%{name}/node.d +%dir %{_sysconfdir}/%{name}/statsd.d +%dir %{_libdir}/%{name}/statsd.d + %if %{with systemd} %{_unitdir}/netdata.service diff --git a/plugins.d/Makefile.am b/plugins.d/Makefile.am index 1085d053af..904a3fdef8 100644 --- a/plugins.d/Makefile.am +++ b/plugins.d/Makefile.am @@ -3,6 +3,19 @@ # SPDX-License-Identifier: GPL-3.0+ # MAINTAINERCLEANFILES= $(srcdir)/Makefile.in +CLEANFILES = \ + alarm-notify.sh \ + cgroup-name.sh \ + charts.d.plugin \ + fping.plugin \ + node.d.plugin \ + python.d.plugin \ + tc-qos-helper.sh \ + $(NULL) + +include $(top_srcdir)/build/subst.inc + +SUFFIXES = .in dist_plugins_DATA = \ README.md \ @@ -22,3 +35,13 @@ dist_plugins_SCRIPTS = \ tc-qos-helper.sh \ loopsleepms.sh.inc \ $(NULL) + +dist_noinst_DATA = \ + alarm-notify.sh.in \ + cgroup-name.sh.in \ + charts.d.plugin.in \ + fping.plugin.in \ + node.d.plugin.in \ + python.d.plugin.in \ + tc-qos-helper.sh.in \ + $(NULL) diff --git a/plugins.d/alarm-notify.sh b/plugins.d/alarm-notify.sh.in index b37e9bfbd9..dc481ad0a7 100755 --- a/plugins.d/alarm-notify.sh +++ b/plugins.d/alarm-notify.sh.in @@ -159,9 +159,10 @@ custom_sender() { # ----------------------------------------------------------------------------- # defaults to allow running this script by hand -[ -z "${NETDATA_CONFIG_DIR}" ] && NETDATA_CONFIG_DIR="$(dirname "${0}")/../../../../etc/netdata" -[ -z "${NETDATA_CACHE_DIR}" ] && NETDATA_CACHE_DIR="$(dirname "${0}")/../../../../va |