summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2018-09-27 20:37:52 +0300
committerGitHub <noreply@github.com>2018-09-27 20:37:52 +0300
commit73608f86b4c10f72fff991fbf9bfa1a802c2d95c (patch)
tree56001d6001f5e388ff2eea8cd41a35f9e7d1b598
parenta440a24688f2258bba3ac2e7bbd57c112581893d (diff)
stock configs in /usr/lib/netdata (#4283)
* makefiles install configs in /usr/lib/netdata/conf.d; #4182 * stock health config in /usr/lib/netdata/conf.d/health.d * unit test path concatenation * simplified health file management * use stream.conf from stock config if it does not exist in /etc/netdata * indicate loading of user config in function call * load netdata.conf from stock dir if not found in /etc/netdata * added NETDATA_USER_CONFIG_DIR * provide defaults before loading config * charts.d uses stock files * fping now uses the stock config files * tc-qos-helper.sh now uses stock configs * cgroup-name.sh now uses stock configs too * simplified cgroup-name.sh for user and stock config * alarm-notify.sh uses stock configs too * simplified fping plugin configs loading * simplified tc-qos-helper.sh configs loading * added error handling to charts.d.plugin * apps.plugin used stock configs * generalized recursive double-directory configs loading * statsd uses stock configs * node.d.plugin uses stock configs * compile-time decision of netdata default paths for all files * makeself cleans up old stock config files from user configuration directories * fixed makeself typo * netdata-installer.sh removes stock files from user configuration directories * python.d.plugin user/stock configs update * cleanup stock config files from /etc/netdata, only once * python.d.plugin log loaded files * fix permissions of stock config files and provide an "orig" link for quick access * create help link on stock configs migration for static installations * create user config directories * example statsd synthetic charts now state they are examples * updated configs.signatures * spec file * fixes in spec file * fix typo * install netdata after cleaning up stock configs from /etc/netdata * python.d: add cpuidle stock conf
-rw-r--r--.gitignore8
-rwxr-xr-xCMakeLists.txt2
-rw-r--r--build/subst.inc3
-rw-r--r--conf.d/Makefile.am14
-rw-r--r--conf.d/python.d/cpuidle.conf40
-rw-r--r--conf.d/statsd.d/example.conf18
-rw-r--r--configs.signatures1
-rw-r--r--configure.ac1
-rwxr-xr-xmakeself/install-or-update.sh97
-rwxr-xr-xmakeself/jobs/70-netdata-git.install.sh7
-rwxr-xr-xmakeself/jobs/99-makeself.install.sh21
-rwxr-xr-xnetdata-installer.sh181
-rw-r--r--netdata.spec.in24
-rw-r--r--plugins.d/Makefile.am23
-rwxr-xr-xplugins.d/alarm-notify.sh.in (renamed from plugins.d/alarm-notify.sh)29
-rwxr-xr-xplugins.d/cgroup-name.sh.in (renamed from plugins.d/cgroup-name.sh)26
-rwxr-xr-xplugins.d/charts.d.plugin.in (renamed from plugins.d/charts.d.plugin)83
-rwxr-xr-xplugins.d/fping.plugin.in (renamed from plugins.d/fping.plugin)33
-rwxr-xr-xplugins.d/node.d.plugin.in (renamed from plugins.d/node.d.plugin)93
-rwxr-xr-xplugins.d/python.d.plugin.in (renamed from plugins.d/python.d.plugin)58
-rwxr-xr-xplugins.d/tc-qos-helper.sh.in (renamed from plugins.d/tc-qos-helper.sh)19
-rw-r--r--src/Makefile.am1
-rw-r--r--src/apps_plugin.c38
-rw-r--r--src/common.c209
-rw-r--r--src/common.h10
-rw-r--r--src/health.c15
-rw-r--r--src/health.h7
-rw-r--r--src/health_config.c243
-rw-r--r--src/main.c79
-rw-r--r--src/rrdhost.c2
-rw-r--r--src/statsd.c110
-rw-r--r--src/unit_test.c42
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<