From e582ddedad0e5071c0f7a3a794679ef9fc3987b7 Mon Sep 17 00:00:00 2001 From: bms8197 Date: Tue, 24 Jan 2023 13:04:06 +0200 Subject: [PATCH] committing changes in /etc made by "sh /tmp/netdata-kickstart.sh --claim-token aLhhRAZeOuysZlEP2bXAEarAjyl6z0IlFnLpMtFWsqkdYLI6WmChuWGDFb4yhAopbktpArp9VzOZWVnjNXyjXOeaa3YDjx1-lkEtn8eUVo6tmzvLmla3qos98YymqYnDdQFLpAw --claim-url https://app.netdata.cloud" Package changes: --- .etckeeper | 21 ++ group | 11 +- group- | 10 +- gshadow | 11 +- gshadow- | 10 +- logrotate.d/netdata | 12 + netdata/.install-type | 3 + netdata/edit-config | 309 ++++++++++++++++++ netdata/netdata.conf | 19 ++ passwd | 1 + passwd- | 1 + shadow | 1 + .../multi-user.target.wants/netdata.service | 1 + 13 files changed, 392 insertions(+), 18 deletions(-) create mode 100644 logrotate.d/netdata create mode 100644 netdata/.install-type create mode 100755 netdata/edit-config create mode 100644 netdata/netdata.conf create mode 120000 systemd/system/multi-user.target.wants/netdata.service diff --git a/.etckeeper b/.etckeeper index f6a077e..bc13c34 100755 --- a/.etckeeper +++ b/.etckeeper @@ -54,6 +54,14 @@ mkdir -p './mail/spamassassin/sa-update-keys/private-keys-v1.d' mkdir -p './modulefiles' mkdir -p './modules-load.d' mkdir -p './named' +mkdir -p './netdata/charts.d' +mkdir -p './netdata/custom-plugins.d' +mkdir -p './netdata/ebpf.d' +mkdir -p './netdata/go.d' +mkdir -p './netdata/health.d' +mkdir -p './netdata/python.d' +mkdir -p './netdata/ssl' +mkdir -p './netdata/statsd.d' mkdir -p './newrelic-infra/integrations.d' mkdir -p './nginx/conf.d/ganool/nginx/modules' mkdir -p './nginx/conf.d/ganool/nginx/ngx1/nginx/modules' @@ -3005,6 +3013,7 @@ maybe chmod 0644 'logrotate.d/mysecureshell' maybe chmod 0644 'logrotate.d/mysql' maybe chgrp 'named' 'logrotate.d/named' maybe chmod 0640 'logrotate.d/named' +maybe chmod 0644 'logrotate.d/netdata' maybe chmod 0644 'logrotate.d/nginx' maybe chmod 0644 'logrotate.d/php-fpm' maybe chmod 0644 'logrotate.d/ppp' @@ -3911,6 +3920,18 @@ maybe chmod 0640 'named.rfc1912.zones' maybe chgrp 'named' 'named.root.key' maybe chmod 0644 'named.root.key' maybe chmod 0644 'netconfig' +maybe chmod 0755 'netdata' +maybe chmod 0644 'netdata/.install-type' +maybe chmod 0755 'netdata/charts.d' +maybe chmod 0755 'netdata/custom-plugins.d' +maybe chmod 0755 'netdata/ebpf.d' +maybe chmod 0755 'netdata/edit-config' +maybe chmod 0755 'netdata/go.d' +maybe chmod 0755 'netdata/health.d' +maybe chmod 0644 'netdata/netdata.conf' +maybe chmod 0755 'netdata/python.d' +maybe chmod 0755 'netdata/ssl' +maybe chmod 0755 'netdata/statsd.d' maybe chmod 0644 'networks' maybe chmod 0755 'newrelic-infra' maybe chmod 0644 'newrelic-infra.yml' diff --git a/group b/group index 66fd8ba..bc14d8b 100644 --- a/group +++ b/group @@ -2,7 +2,7 @@ root:x:0: bin:x:1: daemon:x:2: sys:x:3: -adm:x:4: +adm:x:4:netdata tty:x:5: disk:x:6: lp:x:7: @@ -21,7 +21,7 @@ ftp:x:50: lock:x:54: audio:x:63: users:x:100: -nobody:x:65534: +nobody:x:65534:netdata dbus:x:81: utmp:x:22: utempter:x:35: @@ -47,9 +47,9 @@ slocate:x:21: named:x:25: redis:x:987: memcached:x:986: -nginx:x:985:madalin,smiti +nginx:x:985:madalin,smiti,netdata apache:x:48: -docker:x:984:sftp +docker:x:984:sftp,netdata cgred:x:983: dovecot:x:97: dovenull:x:982: @@ -101,9 +101,10 @@ mailcow:x:1017: rundeck:x:1018: litecoin:x:1019: bogdan:x:1020: -squid:x:23: +squid:x:23:netdata laser:x:1021: pydio:x:1022: sftp:x:1023: toranon:x:955: privoxy:x:73: +netdata:x:954: diff --git a/group- b/group- index bea73d6..016466f 100644 --- a/group- +++ b/group- @@ -2,7 +2,7 @@ root:x:0: bin:x:1: daemon:x:2: sys:x:3: -adm:x:4: +adm:x:4:netdata tty:x:5: disk:x:6: lp:x:7: @@ -47,9 +47,9 @@ slocate:x:21: named:x:25: redis:x:987: memcached:x:986: -nginx:x:985:madalin,smiti +nginx:x:985:madalin,smiti,netdata apache:x:48: -docker:x:984:sftp +docker:x:984:sftp,netdata cgred:x:983: dovecot:x:97: dovenull:x:982: @@ -101,8 +101,10 @@ mailcow:x:1017: rundeck:x:1018: litecoin:x:1019: bogdan:x:1020: -squid:x:23: +squid:x:23:netdata laser:x:1021: pydio:x:1022: sftp:x:1023: toranon:x:955: +privoxy:x:73: +netdata:x:954: diff --git a/gshadow b/gshadow index defa16f..0463c85 100644 --- a/gshadow +++ b/gshadow @@ -2,7 +2,7 @@ root::: bin::: daemon::: sys::: -adm::: +adm:::netdata tty::: disk::: lp::: @@ -21,7 +21,7 @@ ftp::: lock::: audio::: users::: -nobody::: +nobody:::netdata dbus:!:: utmp:!:: utempter:!:: @@ -47,9 +47,9 @@ slocate:!:: named:!:: redis:!:: memcached:!:: -nginx:!::madalin,smiti +nginx:!::madalin,smiti,netdata apache:!:: -docker:!::sftp +docker:!::sftp,netdata cgred:!:: dovecot:!:: dovenull:!:: @@ -101,9 +101,10 @@ mailcow:!:: rundeck:!:: litecoin:!:: bogdan:!:: -squid:!:: +squid:!::netdata laser:!:: pydio:!:: sftp:!:: toranon:!:: privoxy:!:: +netdata:!:: diff --git a/gshadow- b/gshadow- index 169db4c..bf9ff7f 100644 --- a/gshadow- +++ b/gshadow- @@ -2,7 +2,7 @@ root::: bin::: daemon::: sys::: -adm::: +adm:::netdata tty::: disk::: lp::: @@ -47,9 +47,9 @@ slocate:!:: named:!:: redis:!:: memcached:!:: -nginx:!::madalin,smiti +nginx:!::madalin,smiti,netdata apache:!:: -docker:!::sftp +docker:!::sftp,netdata cgred:!:: dovecot:!:: dovenull:!:: @@ -101,8 +101,10 @@ mailcow:!:: rundeck:!:: litecoin:!:: bogdan:!:: -squid:!:: +squid:!::netdata laser:!:: pydio:!:: sftp:!:: toranon:!:: +privoxy:!:: +netdata:!:: diff --git a/logrotate.d/netdata b/logrotate.d/netdata new file mode 100644 index 0000000..4836400 --- /dev/null +++ b/logrotate.d/netdata @@ -0,0 +1,12 @@ +/var/log/netdata/*.log { + daily + missingok + rotate 14 + compress + delaycompress + notifempty + sharedscripts + postrotate + /bin/kill -HUP `cat /run/netdata/netdata.pid 2>/dev/null` 2>/dev/null || true + endscript +} diff --git a/netdata/.install-type b/netdata/.install-type new file mode 100644 index 0000000..f7f6c09 --- /dev/null +++ b/netdata/.install-type @@ -0,0 +1,3 @@ +INSTALL_TYPE='binpkg-rpm' +PREBUILT_ARCH='x86_64' +PREBUILT_DISTRO=' ' diff --git a/netdata/edit-config b/netdata/edit-config new file mode 100755 index 0000000..754f937 --- /dev/null +++ b/netdata/edit-config @@ -0,0 +1,309 @@ +#!/usr/bin/env sh + +# shellcheck disable=SC1091 +[ -f /etc/profile ] && . /etc/profile + +set -e + +script_dir="$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd -P)" + +usage() { + check_directories + cat <&2 "ERROR: ${1}" +} + +abspath() { + if [ -d "${1}" ]; then + echo "$(cd "${1}" && /usr/bin/env PWD= pwd -P)/" + else + echo "$(cd "$(dirname "${1}")" && /usr/bin/env PWD= pwd -P)/$(basename "${1}")" + fi +} + +is_prefix() { + echo "${2}" | grep -qE "^${1}" + return $? +} + +check_directories() { + if [ -e "${script_dir}/.environment" ]; then + OLDPATH="${PATH}" + # shellcheck disable=SC1091 + . "${script_dir}/.environment" + PATH="${OLDPATH}" + fi + + if [ -n "${NETDATA_PREFIX}" ] && [ -d "${NETDATA_PREFIX}/usr/lib/netdata/conf.d" ]; then + stock_dir="${NETDATA_PREFIX}/usr/lib/netdata/conf.d" + elif [ -n "${NETDATA_PREFIX}" ] && [ -d "${NETDATA_PREFIX}/lib/netdata/conf.d" ]; then + stock_dir="${NETDATA_PREFIX}/lib/netdata/conf.d" + elif [ -d "${script_dir}/../../usr/lib/netdata/conf.d" ]; then + stock_dir="${script_dir}/../../usr/lib/netdata/conf.d" + elif [ -d "${script_dir}/../../lib/netdata/conf.d" ]; then + stock_dir="${script_dir}/../../lib/netdata/conf.d" + elif [ -d "/usr/lib/netdata/conf.d" ]; then + stock_dir="/usr/lib/netdata/conf.d" + fi + + [ -z "${NETDATA_USER_CONFIG_DIR}" ] && NETDATA_USER_CONFIG_DIR="${script_dir}" + [ -z "${NETDATA_STOCK_CONFIG_DIR}" ] && NETDATA_STOCK_CONFIG_DIR="${stock_dir}" + + if [ -z "${NETDATA_STOCK_CONFIG_DIR}" ]; then + error "Unable to find stock config directory." + exit 1 + fi +} + +check_editor() { + if [ -z "${editor}" ]; then + if [ -n "${EDITOR}" ] && command -v "${EDITOR}" >/dev/null 2>&1; then + editor="${EDITOR}" + elif command -v editor >/dev/null 2>&1; then + editor="editor" + elif command -v vi >/dev/null 2>&1; then + editor="vi" + else + error "Unable to find a usable editor, tried \${EDITOR} (${EDITOR}), editor, and vi." + exit 1 + fi + elif ! command -v "${editor}" >/dev/null 2>&1; then + error "Unable to locate user specified editor ${editor}, is it in your PATH?" + exit 1 + fi +} + +running_in_container() { + [ -e /.dockerenv ] && return 0 + [ -e /.dockerinit ] && return 0 + [ -r /proc/1/environ ] && tr '\000' '\n' /dev/null && return 0 +} + +get_docker_command() { + if [ -x "${docker}" ]; then + return 0 + elif command -v docker >/dev/null 2>&1; then + docker="$(command -v docker)" + elif command -v podman >/dev/null 2>&1; then + docker="$(command -v podman)" + else + error "Unable to find a usable container tool stack. I support Docker and Podman." + exit 1 + fi +} + +run_in_container() { + ${docker} exec "${1}" /bin/sh -c "${2}" || return 1 + return 0 +} + +check_for_container() { + get_docker_command + ${docker} container inspect "${1}" >/dev/null 2>&1 || return 1 + run_in_container "${1}" "[ -d \"${NETDATA_STOCK_CONFIG_DIR}\" ]" >/dev/null 2>&1 || return 1 + return 0 +} + +handle_container() { + if running_in_container; then + return 0 + elif [ -z "${container}" ] && [ -f "${script_dir}/.container-hostname" ]; then + echo >&2 "Autodetected containerized Netdata instance. Attempting to autodetect container ID." + possible_container="$(cat "${script_dir}/.container-hostname")" + if check_for_container "${possible_container}"; then + container="${possible_container}" + elif check_for_container netdata; then + container="netdata" + else + error "Could not autodetect container ID. It must be supplied on the command line with the --container option." + exit 1 + fi + + echo >&2 "Found Netdata container with ID or name ${container}" + elif [ -n "${container}" ]; then + if ! check_for_container "${container}"; then + error "No container with ID or name ${container} exists." + exit 1 + fi + fi +} + +list_files() { + check_directories + handle_container + + if test -t; then + width="$(tput cols)" + fi + + if [ -z "${container}" ]; then + if [ "$(uname -s)" = "Linux" ]; then + # shellcheck disable=SC2046,SC2086 + files="$(cd "${NETDATA_STOCK_CONFIG_DIR}" && ls ${width:+-C} ${width:+-w ${width}} $(find . -type f | cut -d '/' -f 2-))" + elif [ "$(uname -s)" = "FreeBSD" ]; then + if [ -n "${width}" ]; then + export COLUMNS="${width}" + fi + + # shellcheck disable=SC2046 + files="$(cd "${NETDATA_STOCK_CONFIG_DIR}" && ls ${width:+-C} $(find . -type f | cut -d '/' -f 2-))" + else + # shellcheck disable=SC2046 + files="$(cd "${NETDATA_STOCK_CONFIG_DIR}" && ls $(find . -type f | cut -d '/' -f 2-))" + fi + else + files="$(run_in_container "${container}" "cd /usr/lib/netdata/conf.d && ls ${width:+-C} ${width:+-w ${width}} \$(find . -type f | cut -d '/' -f 2-)")" + fi + + if [ -z "${files}" ]; then + error "Failed to find any configuration files." + exit 1 + fi + + cat <&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 + else + echo >&2 "Creating empty '${NETDATA_USER_CONFIG_DIR}/${1}' ... " + touch "${NETDATA_USER_CONFIG_DIR}/${1}" || exit 1 + fi +} + +copy_container() { + if [ ! -w "${NETDATA_USER_CONFIG_DIR}" ]; then + error "Cannot write to ${NETDATA_USER_CONFIG_DIR}!" + exit 1 + fi + + if run_in_container "${container}" "[ -f \"${NETDATA_STOCK_CONFIG_DIR}/${1}\" ]"; then + echo >&2 "Copying '${NETDATA_STOCK_CONFIG_DIR}/${1}' to '${NETDATA_USER_CONFIG_DIR}/${1}' ... " + ${docker} cp -a "${container}:${NETDATA_STOCK_CONFIG_DIR}/${1}" "${NETDATA_USER_CONFIG_DIR}/${1}" || exit 1 + else + echo >&2 "Creating empty '${NETDATA_USER_CONFIG_DIR}/${1}' ... " + touch "${NETDATA_USER_CONFIG_DIR}/${1}" || exit 1 + fi +} + +copy() { + if [ -f "${NETDATA_USER_CONFIG_DIR}/${1}" ]; then + return 0 + elif [ -n "${container}" ]; then + copy_container "${1}" + else + copy_native "${1}" + fi +} + +edit() { + echo >&2 "Editing '${1}' ..." + + # check we can edit + if [ ! -w "${1}" ]; then + error "Cannot write to ${1}!" + exit 1 + fi + + "${editor}" "${1}" + exit $? +} + +main() { + parse_args "${@}" + check_directories + check_editor + handle_container + copy "${file}" + edit "${absfile}" +} + +main "${@}" diff --git a/netdata/netdata.conf b/netdata/netdata.conf new file mode 100644 index 0000000..70edb08 --- /dev/null +++ b/netdata/netdata.conf @@ -0,0 +1,19 @@ +# netdata configuration +# +# You can download the latest version of this file, using: +# +# wget -O /etc/netdata/netdata.conf http://localhost:19999/netdata.conf +# or +# curl -o /etc/netdata/netdata.conf http://localhost:19999/netdata.conf +# +# You can uncomment and change any of the options below. +# The value shown in the commented settings, is the default value. +# + +[global] + run as user = netdata + + # default storage size - increase for longer data retention + page cache size = 32 + dbengine multihost disk space = 256 + diff --git a/passwd b/passwd index d31ae1f..e4fe3e8 100644 --- a/passwd +++ b/passwd @@ -78,3 +78,4 @@ pydio:x:1021:1022::/home/pydio:/bin/bash sftp:x:1023:1023::/home/sftp:/bin/bash toranon:x:959:955:Tor anonymizing user:/var/lib/tor:/sbin/nologin privoxy:x:73:73::/etc/privoxy:/sbin/nologin +netdata:x:958:954:Netdata pseudo user:/usr/share/netdata:/sbin/nologin diff --git a/passwd- b/passwd- index 8948559..d31ae1f 100644 --- a/passwd- +++ b/passwd- @@ -77,3 +77,4 @@ laser:x:1020:1021::/home/laser:/bin/bash pydio:x:1021:1022::/home/pydio:/bin/bash sftp:x:1023:1023::/home/sftp:/bin/bash toranon:x:959:955:Tor anonymizing user:/var/lib/tor:/sbin/nologin +privoxy:x:73:73::/etc/privoxy:/sbin/nologin diff --git a/shadow b/shadow index d0cb711..f0ed75b 100644 --- a/shadow +++ b/shadow @@ -78,3 +78,4 @@ pydio:!!:19102:0:99999:7:30:: sftp:!!:19193:0:99999:7:30:: toranon:!!:19312:::::: privoxy:!!:19312:::::: +netdata:!!:19381:::::: diff --git a/systemd/system/multi-user.target.wants/netdata.service b/systemd/system/multi-user.target.wants/netdata.service new file mode 120000 index 0000000..e7d3c5c --- /dev/null +++ b/systemd/system/multi-user.target.wants/netdata.service @@ -0,0 +1 @@ +/usr/lib/systemd/system/netdata.service \ No newline at end of file