3 # reload the user profile
4 [ -f /etc/profile ] && . /etc/profile
6 # fix PKG_CHECK_MODULES error
7 if [ -d /usr/share/aclocal ]
9 ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
16 # you can set CFLAGS before running installer
17 CFLAGS="${CFLAGS--O3}"
19 # keep a log of this command
20 printf "\n# " >>netdata-installer.log
21 date >>netdata-installer.log
22 printf "CFLAGS=\"%s\" " "${CFLAGS}" >>netdata-installer.log
23 printf "%q " "$0" "${@}" >>netdata-installer.log
24 printf "\n" >>netdata-installer.log
26 service="$(which service 2>/dev/null || command -v service 2>/dev/null)"
27 systemctl="$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)"
29 local cmd="${1}" action="${2}"
31 if [ ! -z "${service}" ]
33 run "${service}" "${cmd}" "${action}"
35 elif [ ! -z "${systemctl}" ]
37 run "${systemctl}" "${action}" "${cmd}"
52 ${ME} <installer options>
54 Valid <installer options> are:
56 --install /PATH/TO/INSTALL
58 If your give: --install /opt
59 netdata will be installed in /opt/netdata
63 Do not (re)start netdata.
68 Do not wait for the user to press ENTER.
69 Start immediately building it.
72 --libs-are-really-here
74 If you get errors about missing zlib,
75 or libuuid but you know it is available,
76 you have a broken pkg-config.
77 Use this option to allow it continue
78 without checking pkg-config.
80 Netdata will by default be compiled with gcc optimization -O3
81 If you need to pass different CFLAGS, use something like this:
83 CFLAGS="<gcc options>" ${ME} <installer options>
85 For the installer to complete successfully, you will need
86 these packages installed:
88 gcc make autoconf automake pkg-config zlib1g-dev (or zlib-devel)
89 uuid-dev (or libuuid-devel)
91 For the plugins, you will at least need:
98 md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null)"
99 get_git_config_signatures() {
102 [ ! -d "conf.d" ] && echo >&2 "Wrong directory." && return 1
103 [ -z "${md5sum}" -o ! -x "${md5sum}" ] && echo >&2 "No md5sum command." && return 1
105 echo >configs.signatures.tmp
107 for x in $(find conf.d -name \*.conf)
111 for c in $(git log --follow "conf.d/${x}" | grep ^commit | cut -d ' ' -f 2)
113 git checkout ${c} "conf.d/${x}" || continue
114 s="$(cat "conf.d/${x}" | md5sum | cut -d ' ' -f 1)"
115 echo >>configs.signatures.tmp "${x}:${s}"
118 git checkout HEAD "conf.d/${x}" || break
121 cat configs.signatures.tmp |\
125 echo "declare -A configs_signatures=("
129 echo " ['${md5}']='${file}'"
132 } >configs.signatures
134 rm configs.signatures.tmp
140 while [ ! -z "${1}" ]
142 if [ "$1" = "--install" ]
144 NETDATA_PREFIX="${2}/netdata"
146 elif [ "$1" = "--zlib-is-really-here" -o "$1" = "--libs-are-really-here" ]
150 elif [ "$1" = "--dont-start-it" ]
154 elif [ "$1" = "--dont-wait" ]
158 elif [ "$1" = "--help" -o "$1" = "-h" ]
162 elif [ "$1" = "get_git_config_signatures" ]
164 get_git_config_signatures && exit 0
169 echo >&2 "I cannot understand option '$1'."
178 Nice to see you are giving it a try!
180 You are about to build and install netdata to your system.
182 It will be installed at these locations:
184 - the daemon at ${NETDATA_PREFIX}/usr/sbin/netdata
185 - config files at ${NETDATA_PREFIX}/etc/netdata
186 - web files at ${NETDATA_PREFIX}/usr/share/netdata
187 - plugins at ${NETDATA_PREFIX}/usr/libexec/netdata
188 - cache files at ${NETDATA_PREFIX}/var/cache/netdata
189 - db files at ${NETDATA_PREFIX}/var/lib/netdata
190 - log files at ${NETDATA_PREFIX}/var/log/netdata
191 - pid file at ${NETDATA_PREFIX}/var/run
193 This installer allows you to change the installation path.
194 Press Control-C and run the same command with --help for help.
198 if [ "${UID}" -ne 0 ]
200 if [ -z "${NETDATA_PREFIX}" ]
202 cat <<-NONROOTNOPREFIX
204 Sorry! This will fail!
206 You are attempting to install netdata as non-root, but you plan to install it
209 Please set an installation prefix, like this:
211 $0 ${@} --install /tmp
213 or, run the installer as root:
217 We suggest to install it as root, or certain data collectors will not be able
218 to work. Netdata drops root privileges when running. So, if you plan to keep
219 it, install it as root to get the full functionality.
228 You are about to install netdata as a non-root user.
229 Netdata will work, but a few data collection modules that
230 require root access will fail.
232 If you installing permanently on your system, run the
242 if [ "$(type autoreconf 2> /dev/null)" ]
250 set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
251 eval $maj=\$1 $min=\$2
253 autoconf_maj_min AMAJ AMIN
258 elif [ "$AMAJ" -eq 2 -a "$AMIN" -ge 60 ]
262 echo "Found autotools $AMAJ.$AMIN"
265 echo "No autotools found"
268 if [ ! "$have_autotools" ]
272 echo "Will skip autoreconf step"
276 -------------------------------------------------------------------------------
277 autotools 2.60 or later is required
279 Sorry, you do not seem to have autotools 2.60 or later, which is
280 required to build from the git sources of netdata.
282 You can either install a suitable version of autotools and automake
283 or download a netdata package which does not have these dependencies.
285 Source packages where autotools have already been run are available
287 https://firehol.org/download/netdata/
289 The unsigned/master folder tracks the head of the git tree and released
290 packages are also available.
296 if [ ${DONOTWAIT} -eq 0 ]
298 if [ ! -z "${NETDATA_PREFIX}" ]
300 read -p "Press ENTER to build and install netdata to '${NETDATA_PREFIX}' > "
302 read -p "Press ENTER to build and install netdata to your system > "
309 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311 Sorry! NetData failed to build...
313 You many need to check these:
315 1. The package uuid-dev (or libuuid-devel) has to be installed.
317 If your system cannot find libuuid, although it is installed
318 run me with the option: --libs-are-really-here
320 2. The package zlib1g-dev (or zlib-devel) has to be installed.
322 If your system cannot find zlib, although it is installed
323 run me with the option: --libs-are-really-here
325 3. You need basic build tools installed, like:
327 gcc make autoconf automake pkg-config
329 Autoconf version 2.60 or higher is required.
331 If you still cannot get it to build, ask for help at github:
333 https://github.com/firehol/netdata/issues
342 printf >>netdata-installer.log "# "
343 printf >>netdata-installer.log "%q " "${@}"
344 printf >>netdata-installer.log " ... "
347 printf >&2 ":-----------------------------------------------------------------------------\n"
348 printf >&2 "Running command:\n"
350 printf >&2 "%q " "${@}"
358 printf >>netdata-installer.log "FAILED!\n"
360 printf >>netdata-installer.log "OK\n"
366 if [ ${LIBS_ARE_HERE} -eq 1 ]
369 echo >&2 "ok, assuming libs are really installed."
370 export ZLIB_CFLAGS=" "
371 export ZLIB_LIBS="-lz"
372 export UUID_CFLAGS=" "
373 export UUID_LIBS="-luuid"
376 trap build_error EXIT
378 if [ "$have_autotools" ]
380 run ./autogen.sh || exit 1
384 --prefix="${NETDATA_PREFIX}/usr" \
385 --sysconfdir="${NETDATA_PREFIX}/etc" \
386 --localstatedir="${NETDATA_PREFIX}/var" \
387 --with-zlib --with-math --with-user=netdata \
388 CFLAGS="${CFLAGS}" || exit 1
390 # remove the build_error hook
393 if [ -f src/netdata ]
395 echo >&2 "Cleaning a possibly old compilation ..."
399 echo >&2 "Compiling netdata ..."
402 if [ "${BASH_VERSINFO[0]}" -ge "4" ]
404 declare -A configs_signatures=()
405 if [ -f "configs.signatures" ]
407 source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !"
411 # migrate existing configuration files
412 # for node.d and charts.d
413 if [ -d "${NETDATA_PREFIX}/etc/netdata" ]
415 # the configuration directory exists
417 if [ ! -d "${NETDATA_PREFIX}/etc/netdata/charts.d" ]
419 run mkdir "${NETDATA_PREFIX}/etc/netdata/charts.d"
422 # move the charts.d config files
423 for x in apache ap cpu_apps cpufreq example exim hddtemp load_average mem_apps mysql nginx nut opensips phpfpm postfix sensors squid tomcat
425 for y in "" ".old" ".orig"
427 if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}" ]
429 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}"
434 if [ ! -d "${NETDATA_PREFIX}/etc/netdata/node.d" ]
436 run mkdir "${NETDATA_PREFIX}/etc/netdata/node.d"
439 # move the node.d config files
440 for x in named sma_webbox snmp
442 for y in "" ".old" ".orig"
444 if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}" ]
446 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}"
452 # backup user configurations
453 installer_backup_suffix="${PID}.${RANDOM}"
454 for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
458 # make a backup of the configuration file
459 cp -p "${x}" "${x}.old"
461 if [ -z "${md5sum}" -o ! -x "${md5sum}" ]
463 # we don't have md5sum - keep it
464 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
466 # find it relative filename
467 f="${x/*\/etc\/netdata\//}"
470 md5="$(cat "${x}" | ${md5sum} | cut -d ' ' -f 1)"
473 if [ -f "conf.d/${f}" ]
475 cp "conf.d/${f}" "${x}.orig"
478 if [ "${BASH_VERSINFO[0]}" -ge "4" ]
480 if [ "${configs_signatures[${md5}]}" = "${f}" ]
482 # it is a stock version - don't keep it
483 echo >&2 "File '${x}' is stock version."
485 # edited by user - keep it
486 echo >&2 "File '${x}' has been edited by user."
487 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
490 echo >&2 "File '${x}' cannot be check for custom edits."
491 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
495 elif [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
497 rm -f "${x}.installer_backup.${installer_backup_suffix}"
501 echo >&2 "Installing netdata ..."
502 run make install || exit 1
504 # restore user configurations
505 for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
507 if [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
509 cp -p "${x}.installer_backup.${installer_backup_suffix}" "${x}"
510 rm -f "${x}.installer_backup.${installer_backup_suffix}"
514 NETDATA_ADDED_TO_DOCKER=0
517 getent group netdata > /dev/null
520 echo >&2 "Adding netdata user group ..."
521 run groupadd -r netdata
524 getent passwd netdata > /dev/null
527 echo >&2 "Adding netdata user account ..."
528 run useradd -r -g netdata -c netdata -s $(which nologin || echo '/bin/false') -d / netdata
531 getent group docker > /dev/null
534 # find the users in the docker group
535 docker=$(getent group docker | cut -d ':' -f 4)
536 if [[ ",${docker}," =~ ,netdata, ]]
538 # netdata is already there
541 # netdata is not in docker group
542 echo >&2 "Adding netdata user to the docker group (needed to get container names) ..."
543 run usermod -a -G docker netdata
545 # let the uninstall script know
546 NETDATA_ADDED_TO_DOCKER=1
549 if [ -d /etc/logrotate.d -a ! -f /etc/logrotate.d/netdata ]
551 echo >&2 "Adding netdata logrotate configuration ..."
552 run cp system/netdata.logrotate /etc/logrotate.d/netdata
557 # -----------------------------------------------------------------------------
558 # load options from the configuration file
560 # create an empty config if it does not exist
561 [ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
563 # function to extract values from the config file
565 local key="${1}" value="${2}" line=
567 if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
569 line="$( grep "^[[:space:]]*${key}[[:space:]]*=[[:space:]]*" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" | head -n 1 )"
570 [ ! -z "${line}" ] && value="$( echo "${line}" | cut -d '=' -f 2 | sed -e "s/^[[:space:]]\+//g" -e "s/[[:space:]]\+$//g" )"
578 [ ! "${UID}" = "0" ] && defuser="${USER}"
579 NETDATA_USER="$( config_option "run as user" "${defuser}" )"
581 NETDATA_WEB_USER="$( config_option "web files owner" "${defuser}" )"
582 NETDATA_WEB_GROUP="$( config_option "web files group" "${NETDATA_WEB_USER}" )"
586 NETDATA_DEBUG="$( config_option "debug flags" ${defdebug} )"
590 NETDATA_PORT="$( config_option "default port" ${defport} )"
591 NETDATA_PORT2="$( config_option "port" ${defport} )"
593 if [ "${NETDATA_PORT}" != "${NETDATA_PORT2}" ]
595 if [ "${NETDATA_PORT2}" != "${defport}" ]
597 NETDATA_PORT="${NETDATA_PORT2}"
602 NETDATA_LIB_DIR="$( config_option "lib directory" "${NETDATA_PREFIX}/var/lib/netdata" )"
603 NETDATA_CACHE_DIR="$( config_option "cache directory" "${NETDATA_PREFIX}/var/cache/netdata" )"
604 NETDATA_WEB_DIR="$( config_option "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )"
605 NETDATA_LOG_DIR="$( config_option "log directory" "${NETDATA_PREFIX}/var/log/netdata" )"
606 NETDATA_CONF_DIR="$( config_option "config directory" "${NETDATA_PREFIX}/etc/netdata" )"
607 NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
610 # -----------------------------------------------------------------------------
611 # prepare the directories
613 # this is needed if NETDATA_PREFIX is not empty
614 if [ ! -d "${NETDATA_RUN_DIR}" ]
616 mkdir -p "${NETDATA_RUN_DIR}" || exit 1
620 echo >&2 "Fixing directories (user: ${NETDATA_USER})..."
621 for x in "${NETDATA_WEB_DIR}" "${NETDATA_CONF_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}" "${NETDATA_LIB_DIR}" "${NETDATA_CONF_DIR}/python.d" "${NETDATA_CONF_DIR}/charts.d" "${NETDATA_CONF_DIR}/node.d"
625 echo >&2 "Creating directory '${x}'"
626 run mkdir -p "${x}" || exit 1
631 if [ "${x}" = "${NETDATA_WEB_DIR}" ]
633 run chown -R "${NETDATA_WEB_USER}:${NETDATA_WEB_GROUP}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_WEB_USER}:${NETDATA_WEB_GROUP}..."
635 run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_USER}..."
639 run chmod 0755 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
644 run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
645 run chmod 0755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
646 run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
649 # fix apps.plugin to be setuid to root
650 run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
651 run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
655 # -----------------------------------------------------------------------------
656 # check if we can re-start netdata
658 if [ ${DONOTSTART} -eq 1 ]
660 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
662 echo >&2 "Generating empty config file in: ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
663 echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
665 if [ "${UID}" -eq 0 ]
667 chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
669 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
671 echo >&2 "OK. It is now installed and ready."
675 # -----------------------------------------------------------------------------
676 # stop a running netdata
679 [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
680 [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
684 stop_netdata_on_pid() {
685 local pid="$1" ret=0 count=0
687 isnetdata $pid || return 0
689 printf >&2 "Stopping netdata on pid $pid ..."
690 while [ ! -z "$pid" -a $ret -eq 0 ]
694 echo >&2 "Cannot stop the running netdata on pid $pid."
698 count=$(( count + 1 ))
700 run kill $pid 2>/dev/null
703 test $ret -eq 0 && printf >&2 "." && sleep 2
709 echo >&2 "SORRY! CANNOT STOP netdata ON PID $pid !"
713 echo >&2 "netdata on pid $pid stopped."
720 echo >&2 "Stopping a (possibly) running netdata..."
722 for p in $(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null) \
723 $(cat /var/run/netdata.pid 2>/dev/null) \
724 $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
725 $(pidof netdata 2>/dev/null)
727 stop_netdata_on_pid $p
731 # -----------------------------------------------------------------------------
732 # check netdata for systemd
735 # if the directory /etc/systemd/system does not exit, it is not systemd
736 [ ! -d /etc/systemd/system ] && return 1
738 # if pid 1 is systemd, it is systemd
739 [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
741 # if systemd is running, it is systemd
742 pidof systemd >/dev/null 2>&1 && return 0
744 # else, it is not systemd
749 if [ "${UID}" -eq 0 ]
754 # systemd is running on this system
756 if [ ! -f /etc/systemd/system/netdata.service ]
758 echo >&2 "Installing systemd service..."
759 run cp system/netdata.service /etc/systemd/system/netdata.service && \
760 run systemctl daemon-reload && \
761 run systemctl enable netdata
767 service netdata restart && started=1
770 if [ ${started} -eq 0 ]
772 # check if we can use the system service
775 service netdata restart && started=1
776 if [ ${started} -eq 0 ]
778 service netdata start && started=1
783 if [ ${started} -eq 0 ]
785 # still not started...
789 echo >&2 "Starting netdata..."
790 run ${NETDATA_PREFIX}/usr/sbin/netdata -P ${NETDATA_RUN_DIR}/netdata.pid "${@}"
794 echo >&2 "SORRY! FAILED TO START NETDATA!"
797 echo >&2 "OK. NetData Started!"
803 # -----------------------------------------------------------------------------
804 # save a config file, if it is not already there
806 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
809 echo >&2 "-------------------------------------------------------------------------------"
811 echo >&2 "Downloading default configuration from netdata..."
814 # remove a possibly obsolete download
815 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
817 # disable a proxy to get data from the local netdata
822 wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
826 if [ $ret -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
828 curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
832 if [ $ret -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
834 mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
835 echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
837 if [ "${UID}" -eq 0 ]
839 chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
841 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
843 echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
844 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
848 # -----------------------------------------------------------------------------
851 ksm_is_available_but_disabled() {
854 -------------------------------------------------------------------------------
855 Memory de-duplication instructions
857 You have kernel memory de-duper (called Kernel Same-page Merging,
858 or KSM) available, but it is not currently enabled.
862 echo 1 >/sys/kernel/mm/ksm/run
863 echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
865 If you enable it, you will save 40-60% of netdata memory.
870 ksm_is_not_available() {
873 -------------------------------------------------------------------------------
874 Memory de-duplication not present in your kernel
876 It seems you do not have kernel memory de-duper (called Kernel Same-page
877 Merging, or KSM) available.
879 To enable it, you need a kernel built with CONFIG_KSM=y
881 If you can have it, you will save 40-60% of netdata memory.
886 if [ -f "/sys/kernel/mm/ksm/run" ]
888 if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
890 ksm_is_available_but_disabled
896 # -----------------------------------------------------------------------------
897 # Check for version.txt
899 if [ ! -s web/version.txt ]
903 -------------------------------------------------------------------------------
904 Version update check warning
906 The way you downloaded netdata, we cannot find its version. This means the
907 Update check on the dashboard, will not work.
909 If you want to have version update check, please re-install it
910 following the procedure in:
912 https://github.com/firehol/netdata/wiki/Installation
917 # -----------------------------------------------------------------------------
918 # apps.plugin warning
920 if [ "${UID}" -ne 0 ]
922 cat <<-SETUID_WARNING
924 -------------------------------------------------------------------------------
925 apps.plugin needs privileges
927 Since you have installed netdata as a normal user, to have apps.plugin collect
928 all the needed data, you have to give it the access rights it needs, by running
929 either of the following sets of commands:
931 To run apps.plugin with escalated capabilities:
933 sudo chown root:${NETDATA_USER} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
934 sudo chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
935 sudo setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
937 or, to run apps.plugin as root:
939 sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
940 sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
942 apps.plugin is performing a hard-coded function of data collection for all
943 running processes. It cannot be instructed from the netdata daemon to perform
944 any task, so it is pretty safe to do this.
949 # -----------------------------------------------------------------------------
950 # Keep un-install info
952 cat >netdata-uninstaller.sh <<-UNINSTALL
955 # this script will uninstall netdata
957 if [ "\$1" != "--force" ]
959 echo >&2 "This script will REMOVE netdata from your system."
960 echo >&2 "Run it again with --force to do it."
964 echo >&2 "Stopping a possibly running netdata..."
965 for p in \$(pidof netdata); do kill \$p; done
969 if [ ! -z "\$1" -a -d "\$1" ]
972 echo "Deleting directory '\$1' ..."
977 if [ ! -z "${NETDATA_PREFIX}" -a -d "${NETDATA_PREFIX}" ]
979 # installation prefix was given
981 deletedir "${NETDATA_PREFIX}"
984 # installation prefix was NOT given
986 if [ -f "${NETDATA_PREFIX}/usr/sbin/netdata" ]
988 echo "Deleting ${NETDATA_PREFIX}/usr/sbin/netdata ..."
989 rm -i "${NETDATA_PREFIX}/usr/sbin/netdata"
992 deletedir "${NETDATA_PREFIX}/etc/netdata"
993 deletedir "${NETDATA_PREFIX}/usr/share/netdata"
994 deletedir "${NETDATA_PREFIX}/usr/libexec/netdata"
995 deletedir "${NETDATA_PREFIX}/var/lib/netdata"
996 deletedir "${NETDATA_PREFIX}/var/cache/netdata"
997 deletedir "${NETDATA_PREFIX}/var/log/netdata"
1000 if [ -f /etc/logrotate.d/netdata ]
1002 echo "Deleting /etc/logrotate.d/netdata ..."
1003 rm -i /etc/logrotate.d/netdata
1006 if [ -f /etc/systemd/system/netdata.service ]
1008 echo "Deleting /etc/systemd/system/netdata.service ..."
1009 rm -i /etc/systemd/system/netdata.service
1012 getent passwd netdata > /dev/null
1016 echo "You may also want to remove the user netdata"
1018 echo " userdel netdata"
1021 getent group netdata > /dev/null
1025 echo "You may also want to remove the group netdata"
1027 echo " groupdel netdata"
1030 getent group docker > /dev/null
1031 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_DOCKER}" = "1" ]
1034 echo "You may also want to remove the netdata user from the docker group"
1036 echo " gpasswd -d netdata docker"
1040 chmod 750 netdata-uninstaller.sh
1042 # -----------------------------------------------------------------------------
1047 -------------------------------------------------------------------------------
1049 OK. NetData is installed and it is running.
1051 -------------------------------------------------------------------------------
1053 By default netdata listens on all IPs on port ${NETDATA_PORT},
1054 so you can access it with:
1056 http://this.machine.ip:${NETDATA_PORT}/
1058 To stop netdata, just kill it, with:
1062 To start it, just run it:
1064 ${NETDATA_PREFIX}/usr/sbin/netdata
1070 echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"