3 # reload the user profile
4 [ -f /etc/profile ] && . /etc/profile
6 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
8 # fix PKG_CHECK_MODULES error
9 if [ -d /usr/share/aclocal ]
11 ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
18 # you can set CFLAGS before running installer
19 CFLAGS="${CFLAGS--O3}"
21 # keep a log of this command
22 printf "\n# " >>netdata-installer.log
23 date >>netdata-installer.log
24 printf "CFLAGS=\"%s\" " "${CFLAGS}" >>netdata-installer.log
25 printf "%q " "$0" "${@}" >>netdata-installer.log
26 printf "\n" >>netdata-installer.log
28 service="$(which service 2>/dev/null || command -v service 2>/dev/null)"
29 systemctl="$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)"
31 local cmd="${1}" action="${2}"
33 if [ ! -z "${service}" ]
35 run "${service}" "${cmd}" "${action}"
37 elif [ ! -z "${systemctl}" ]
39 run "${systemctl}" "${action}" "${cmd}"
54 ${ME} <installer options>
56 Valid <installer options> are:
58 --install /PATH/TO/INSTALL
60 If your give: --install /opt
61 netdata will be installed in /opt/netdata
65 Do not (re)start netdata.
70 Do not wait for the user to press ENTER.
71 Start immediately building it.
74 --libs-are-really-here
76 If you get errors about missing zlib,
77 or libuuid but you know it is available,
78 you have a broken pkg-config.
79 Use this option to allow it continue
80 without checking pkg-config.
82 Netdata will by default be compiled with gcc optimization -O3
83 If you need to pass different CFLAGS, use something like this:
85 CFLAGS="<gcc options>" ${ME} <installer options>
87 For the installer to complete successfully, you will need
88 these packages installed:
90 gcc make autoconf automake pkg-config zlib1g-dev (or zlib-devel)
91 uuid-dev (or libuuid-devel)
93 For the plugins, you will at least need:
100 md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null)"
101 get_git_config_signatures() {
104 [ ! -d "conf.d" ] && echo >&2 "Wrong directory." && return 1
105 [ -z "${md5sum}" -o ! -x "${md5sum}" ] && echo >&2 "No md5sum command." && return 1
107 echo >configs.signatures.tmp
109 for x in $(find conf.d -name \*.conf)
113 for c in $(git log --follow "conf.d/${x}" | grep ^commit | cut -d ' ' -f 2)
115 git checkout ${c} "conf.d/${x}" || continue
116 s="$(cat "conf.d/${x}" | md5sum | cut -d ' ' -f 1)"
117 echo >>configs.signatures.tmp "${x}:${s}"
120 git checkout HEAD "conf.d/${x}" || break
123 cat configs.signatures.tmp |\
127 echo "declare -A configs_signatures=("
131 echo " ['${md5}']='${file}'"
134 } >configs.signatures
136 rm configs.signatures.tmp
142 while [ ! -z "${1}" ]
144 if [ "$1" = "--install" ]
146 NETDATA_PREFIX="${2}/netdata"
148 elif [ "$1" = "--zlib-is-really-here" -o "$1" = "--libs-are-really-here" ]
152 elif [ "$1" = "--dont-start-it" ]
156 elif [ "$1" = "--dont-wait" ]
160 elif [ "$1" = "--help" -o "$1" = "-h" ]
164 elif [ "$1" = "get_git_config_signatures" ]
166 get_git_config_signatures && exit 0
171 echo >&2 "I cannot understand option '$1'."
180 The real-time performance monitoring system.
182 You are about to build and install netdata to your system.
184 It will be installed at these locations:
186 - the daemon at ${NETDATA_PREFIX}/usr/sbin/netdata
187 - config files at ${NETDATA_PREFIX}/etc/netdata
188 - web files at ${NETDATA_PREFIX}/usr/share/netdata
189 - plugins at ${NETDATA_PREFIX}/usr/libexec/netdata
190 - cache files at ${NETDATA_PREFIX}/var/cache/netdata
191 - db files at ${NETDATA_PREFIX}/var/lib/netdata
192 - log files at ${NETDATA_PREFIX}/var/log/netdata
193 - pid file at ${NETDATA_PREFIX}/var/run
195 This installer allows you to change the installation path.
196 Press Control-C and run the same command with --help for help.
200 if [ "${UID}" -ne 0 ]
202 if [ -z "${NETDATA_PREFIX}" ]
204 cat <<NONROOTNOPREFIX
206 Sorry! This will fail!
208 You are attempting to install netdata as non-root, but you plan to install it
211 Please set an installation prefix, like this:
213 $0 ${@} --install /tmp
215 or, run the installer as root:
219 We suggest to install it as root, or certain data collectors will not be able
220 to work. Netdata drops root privileges when running. So, if you plan to keep
221 it, install it as root to get the full functionality.
230 You are about to install netdata as a non-root user.
231 Netdata will work, but a few data collection modules that
232 require root access will fail.
234 If you installing permanently on your system, run the
244 if [ "$(type autoreconf 2> /dev/null)" ]
252 set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
253 eval $maj=\$1 $min=\$2
255 autoconf_maj_min AMAJ AMIN
260 elif [ "$AMAJ" -eq 2 -a "$AMIN" -ge 60 ]
264 echo "Found autotools $AMAJ.$AMIN"
267 echo "No autotools found"
270 if [ ! "$have_autotools" ]
274 echo "Will skip autoreconf step"
278 -------------------------------------------------------------------------------
279 autotools 2.60 or later is required
281 Sorry, you do not seem to have autotools 2.60 or later, which is
282 required to build from the git sources of netdata.
284 You can either install a suitable version of autotools and automake
285 or download a netdata package which does not have these dependencies.
287 Source packages where autotools have already been run are available
289 https://firehol.org/download/netdata/
291 The unsigned/master folder tracks the head of the git tree and released
292 packages are also available.
298 if [ ${DONOTWAIT} -eq 0 ]
300 if [ ! -z "${NETDATA_PREFIX}" ]
302 read -p "Press ENTER to build and install netdata to '${NETDATA_PREFIX}' > "
304 read -p "Press ENTER to build and install netdata to your system > "
311 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
313 Sorry! NetData failed to build...
315 You many need to check these:
317 1. The package uuid-dev (or libuuid-devel) has to be installed.
319 If your system cannot find libuuid, although it is installed
320 run me with the option: --libs-are-really-here
322 2. The package zlib1g-dev (or zlib-devel) has to be installed.
324 If your system cannot find zlib, although it is installed
325 run me with the option: --libs-are-really-here
327 3. You need basic build tools installed, like:
329 gcc make autoconf automake pkg-config
331 Autoconf version 2.60 or higher is required.
333 If you still cannot get it to build, ask for help at github:
335 https://github.com/firehol/netdata/issues
344 printf >>netdata-installer.log "# "
345 printf >>netdata-installer.log "%q " "${@}"
346 printf >>netdata-installer.log " ... "
349 printf >&2 ":-----------------------------------------------------------------------------\n"
350 printf >&2 "Running command:\n"
352 printf >&2 "%q " "${@}"
360 printf >>netdata-installer.log "FAILED!\n"
362 printf >>netdata-installer.log "OK\n"
368 if [ ${LIBS_ARE_HERE} -eq 1 ]
371 echo >&2 "ok, assuming libs are really installed."
372 export ZLIB_CFLAGS=" "
373 export ZLIB_LIBS="-lz"
374 export UUID_CFLAGS=" "
375 export UUID_LIBS="-luuid"
378 trap build_error EXIT
380 if [ "$have_autotools" ]
382 run ./autogen.sh || exit 1
386 --prefix="${NETDATA_PREFIX}/usr" \
387 --sysconfdir="${NETDATA_PREFIX}/etc" \
388 --localstatedir="${NETDATA_PREFIX}/var" \
389 --with-zlib --with-math --with-user=netdata \
390 CFLAGS="${CFLAGS}" || exit 1
392 # remove the build_error hook
395 if [ -f src/netdata ]
397 echo >&2 "Cleaning a possibly old compilation ..."
401 echo >&2 "Compiling netdata ..."
404 if [ "${BASH_VERSINFO[0]}" -ge "4" ]
406 declare -A configs_signatures=()
407 if [ -f "configs.signatures" ]
409 source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !"
413 # migrate existing configuration files
414 # for node.d and charts.d
415 if [ -d "${NETDATA_PREFIX}/etc/netdata" ]
417 # the configuration directory exists
419 if [ ! -d "${NETDATA_PREFIX}/etc/netdata/charts.d" ]
421 run mkdir "${NETDATA_PREFIX}/etc/netdata/charts.d"
424 # move the charts.d config files
425 for x in apache ap cpu_apps cpufreq example exim hddtemp load_average mem_apps mysql nginx nut opensips phpfpm postfix sensors squid tomcat
427 for y in "" ".old" ".orig"
429 if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}" ]
431 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}"
436 if [ ! -d "${NETDATA_PREFIX}/etc/netdata/node.d" ]
438 run mkdir "${NETDATA_PREFIX}/etc/netdata/node.d"
441 # move the node.d config files
442 for x in named sma_webbox snmp
444 for y in "" ".old" ".orig"
446 if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}" ]
448 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}"
454 # backup user configurations
455 installer_backup_suffix="${PID}.${RANDOM}"
456 for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
460 # make a backup of the configuration file
461 cp -p "${x}" "${x}.old"
463 if [ -z "${md5sum}" -o ! -x "${md5sum}" ]
465 # we don't have md5sum - keep it
466 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
468 # find it relative filename
469 f="${x/*\/etc\/netdata\//}"
472 md5="$(cat "${x}" | ${md5sum} | cut -d ' ' -f 1)"
475 if [ -f "conf.d/${f}" ]
477 cp "conf.d/${f}" "${x}.orig"
480 if [ "${BASH_VERSINFO[0]}" -ge "4" ]
482 if [ "${configs_signatures[${md5}]}" = "${f}" ]
484 # it is a stock version - don't keep it
485 echo >&2 "File '${x}' is stock version."
487 # edited by user - keep it
488 echo >&2 "File '${x}' has been edited by user."
489 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
492 echo >&2 "File '${x}' cannot be check for custom edits."
493 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
497 elif [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
499 rm -f "${x}.installer_backup.${installer_backup_suffix}"
503 echo >&2 "Installing netdata ..."
504 run make install || exit 1
506 # restore user configurations
507 for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
509 if [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
511 cp -p "${x}.installer_backup.${installer_backup_suffix}" "${x}"
512 rm -f "${x}.installer_backup.${installer_backup_suffix}"
516 NETDATA_ADDED_TO_DOCKER=0
519 getent group netdata > /dev/null
522 echo >&2 "Adding netdata user group ..."
523 run groupadd -r netdata
526 getent passwd netdata > /dev/null
529 echo >&2 "Adding netdata user account ..."
530 run useradd -r -g netdata -c netdata -s $(which nologin || echo '/bin/false') -d / netdata
533 getent group docker > /dev/null
536 # find the users in the docker group
537 docker=$(getent group docker | cut -d ':' -f 4)
538 if [[ ",${docker}," =~ ,netdata, ]]
540 # netdata is already there
543 # netdata is not in docker group
544 echo >&2 "Adding netdata user to the docker group (needed to get container names) ..."
545 run usermod -a -G docker netdata
547 # let the uninstall script know
548 NETDATA_ADDED_TO_DOCKER=1
551 if [ -d /etc/logrotate.d -a ! -f /etc/logrotate.d/netdata ]
553 echo >&2 "Adding netdata logrotate configuration ..."
554 run cp system/netdata.logrotate /etc/logrotate.d/netdata
559 # -----------------------------------------------------------------------------
560 # load options from the configuration file
562 # create an empty config if it does not exist
563 [ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
565 # function to extract values from the config file
567 local key="${1}" value="${2}" line=
569 if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
571 line="$( grep "^[[:space:]]*${key}[[:space:]]*=[[:space:]]*" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" | head -n 1 )"
572 [ ! -z "${line}" ] && value="$( echo "${line}" | cut -d '=' -f 2 | sed -e "s/^[[:space:]]\+//g" -e "s/[[:space:]]\+$//g" )"
580 [ ! "${UID}" = "0" ] && defuser="${USER}"
581 NETDATA_USER="$( config_option "run as user" "${defuser}" )"
583 NETDATA_WEB_USER="$( config_option "web files owner" "${defuser}" )"
584 NETDATA_WEB_GROUP="$( config_option "web files group" "${NETDATA_WEB_USER}" )"
588 NETDATA_DEBUG="$( config_option "debug flags" ${defdebug} )"
592 NETDATA_PORT="$( config_option "default port" ${defport} )"
593 NETDATA_PORT2="$( config_option "port" ${defport} )"
595 if [ "${NETDATA_PORT}" != "${NETDATA_PORT2}" ]
597 if [ "${NETDATA_PORT2}" != "${defport}" ]
599 NETDATA_PORT="${NETDATA_PORT2}"
604 NETDATA_LIB_DIR="$( config_option "lib directory" "${NETDATA_PREFIX}/var/lib/netdata" )"
605 NETDATA_CACHE_DIR="$( config_option "cache directory" "${NETDATA_PREFIX}/var/cache/netdata" )"
606 NETDATA_WEB_DIR="$( config_option "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )"
607 NETDATA_LOG_DIR="$( config_option "log directory" "${NETDATA_PREFIX}/var/log/netdata" )"
608 NETDATA_CONF_DIR="$( config_option "config directory" "${NETDATA_PREFIX}/etc/netdata" )"
609 NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
612 # -----------------------------------------------------------------------------
613 # prepare the directories
615 # this is needed if NETDATA_PREFIX is not empty
616 if [ ! -d "${NETDATA_RUN_DIR}" ]
618 mkdir -p "${NETDATA_RUN_DIR}" || exit 1
622 echo >&2 "Fixing directories (user: ${NETDATA_USER})..."
623 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"
627 echo >&2 "Creating directory '${x}'"
628 run mkdir -p "${x}" || exit 1
633 if [ "${x}" = "${NETDATA_WEB_DIR}" ]
635 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}..."
637 run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_USER}..."
641 run chmod 0755 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
646 run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
647 run chmod 0755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
648 run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
651 # fix apps.plugin to be setuid to root
652 run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
653 run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
657 # -----------------------------------------------------------------------------
658 # check if we can re-start netdata
660 if [ ${DONOTSTART} -eq 1 ]
662 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
664 echo >&2 "Generating empty config file in: ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
665 echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
667 if [ "${UID}" -eq 0 ]
669 chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
671 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
673 echo >&2 "OK. It is now installed and ready."
677 # -----------------------------------------------------------------------------
678 # stop a running netdata
681 [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
682 [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
686 stop_netdata_on_pid() {
687 local pid="$1" ret=0 count=0
689 isnetdata $pid || return 0
691 printf >&2 "Stopping netdata on pid $pid ..."
692 while [ ! -z "$pid" -a $ret -eq 0 ]
696 echo >&2 "Cannot stop the running netdata on pid $pid."
700 count=$(( count + 1 ))
702 run kill $pid 2>/dev/null
705 test $ret -eq 0 && printf >&2 "." && sleep 2
711 echo >&2 "SORRY! CANNOT STOP netdata ON PID $pid !"
715 echo >&2 "netdata on pid $pid stopped."
722 echo >&2 "Stopping a (possibly) running netdata..."
724 for p in $(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null) \
725 $(cat /var/run/netdata.pid 2>/dev/null) \
726 $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
727 $(pidof netdata 2>/dev/null)
729 stop_netdata_on_pid $p
733 # -----------------------------------------------------------------------------
734 # check netdata for systemd
737 # if the directory /etc/systemd/system does not exit, it is not systemd
738 [ ! -d /etc/systemd/system ] && return 1
740 # if pid 1 is systemd, it is systemd
741 [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
743 # if systemd is running, it is systemd
744 pidof systemd >/dev/null 2>&1 && return 0
746 # else, it is not systemd
751 if [ "${UID}" -eq 0 ]
756 # systemd is running on this system
758 if [ ! -f /etc/systemd/system/netdata.service ]
760 echo >&2 "Installing systemd service..."
761 run cp system/netdata.service /etc/systemd/system/netdata.service && \
762 run systemctl daemon-reload && \
763 run systemctl enable netdata
769 service netdata restart && started=1
772 if [ ${started} -eq 0 ]
774 # check if we can use the system service
777 service netdata restart && started=1
778 if [ ${started} -eq 0 ]
780 service netdata start && started=1
785 if [ ${started} -eq 0 ]
787 # still not started...
791 echo >&2 "Starting netdata..."
792 run ${NETDATA_PREFIX}/usr/sbin/netdata -P ${NETDATA_RUN_DIR}/netdata.pid "${@}"
796 echo >&2 "SORRY! FAILED TO START NETDATA!"
799 echo >&2 "OK. NetData Started!"
805 # -----------------------------------------------------------------------------
806 # save a config file, if it is not already there
808 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
811 echo >&2 "-------------------------------------------------------------------------------"
813 echo >&2 "Downloading default configuration from netdata..."
816 # remove a possibly obsolete download
817 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
819 # disable a proxy to get data from the local netdata
824 wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
828 if [ $ret -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
830 curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
834 if [ $ret -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
836 mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
837 echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
839 if [ "${UID}" -eq 0 ]
841 chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
843 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
845 echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
846 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
850 # -----------------------------------------------------------------------------
853 ksm_is_available_but_disabled() {
856 -------------------------------------------------------------------------------
857 Memory de-duplication instructions
859 You have kernel memory de-duper (called Kernel Same-page Merging,
860 or KSM) available, but it is not currently enabled.
864 echo 1 >/sys/kernel/mm/ksm/run
865 echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
867 If you enable it, you will save 40-60% of netdata memory.
872 ksm_is_not_available() {
875 -------------------------------------------------------------------------------
876 Memory de-duplication not present in your kernel
878 It seems you do not have kernel memory de-duper (called Kernel Same-page
879 Merging, or KSM) available.
881 To enable it, you need a kernel built with CONFIG_KSM=y
883 If you can have it, you will save 40-60% of netdata memory.
888 if [ -f "/sys/kernel/mm/ksm/run" ]
890 if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
892 ksm_is_available_but_disabled
898 # -----------------------------------------------------------------------------
899 # Check for version.txt
901 if [ ! -s web/version.txt ]
905 -------------------------------------------------------------------------------
906 Version update check warning
908 The way you downloaded netdata, we cannot find its version. This means the
909 Update check on the dashboard, will not work.
911 If you want to have version update check, please re-install it
912 following the procedure in:
914 https://github.com/firehol/netdata/wiki/Installation
919 # -----------------------------------------------------------------------------
920 # apps.plugin warning
922 if [ "${UID}" -ne 0 ]
926 -------------------------------------------------------------------------------
927 apps.plugin needs privileges
929 Since you have installed netdata as a normal user, to have apps.plugin collect
930 all the needed data, you have to give it the access rights it needs, by running
931 either of the following sets of commands:
933 To run apps.plugin with escalated capabilities:
935 sudo chown root:${NETDATA_USER} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
936 sudo chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
937 sudo setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
939 or, to run apps.plugin as root:
941 sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
942 sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
944 apps.plugin is performing a hard-coded function of data collection for all
945 running processes. It cannot be instructed from the netdata daemon to perform
946 any task, so it is pretty safe to do this.
951 # -----------------------------------------------------------------------------
952 # Keep un-install info
954 cat >netdata-uninstaller.sh <<UNINSTALL
957 # this script will uninstall netdata
959 if [ "\$1" != "--force" ]
961 echo >&2 "This script will REMOVE netdata from your system."
962 echo >&2 "Run it again with --force to do it."
966 echo >&2 "Stopping a possibly running netdata..."
967 for p in \$(pidof netdata); do kill \$p; done
971 if [ ! -z "\$1" -a -d "\$1" ]
974 echo "Deleting directory '\$1' ..."
979 if [ ! -z "${NETDATA_PREFIX}" -a -d "${NETDATA_PREFIX}" ]
981 # installation prefix was given
983 deletedir "${NETDATA_PREFIX}"
986 # installation prefix was NOT given
988 if [ -f "${NETDATA_PREFIX}/usr/sbin/netdata" ]
990 echo "Deleting ${NETDATA_PREFIX}/usr/sbin/netdata ..."
991 rm -i "${NETDATA_PREFIX}/usr/sbin/netdata"
994 deletedir "${NETDATA_PREFIX}/etc/netdata"
995 deletedir "${NETDATA_PREFIX}/usr/share/netdata"
996 deletedir "${NETDATA_PREFIX}/usr/libexec/netdata"
997 deletedir "${NETDATA_PREFIX}/var/lib/netdata"
998 deletedir "${NETDATA_PREFIX}/var/cache/netdata"
999 deletedir "${NETDATA_PREFIX}/var/log/netdata"
1002 if [ -f /etc/logrotate.d/netdata ]
1004 echo "Deleting /etc/logrotate.d/netdata ..."
1005 rm -i /etc/logrotate.d/netdata
1008 if [ -f /etc/systemd/system/netdata.service ]
1010 echo "Deleting /etc/systemd/system/netdata.service ..."
1011 rm -i /etc/systemd/system/netdata.service
1014 getent passwd netdata > /dev/null
1018 echo "You may also want to remove the user netdata"
1020 echo " userdel netdata"
1023 getent group netdata > /dev/null
1027 echo "You may also want to remove the group netdata"
1029 echo " groupdel netdata"
1032 getent group docker > /dev/null
1033 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_DOCKER}" = "1" ]
1036 echo "You may also want to remove the netdata user from the docker group"
1038 echo " gpasswd -d netdata docker"
1042 chmod 750 netdata-uninstaller.sh
1044 # -----------------------------------------------------------------------------
1049 -------------------------------------------------------------------------------
1051 OK. NetData is installed and it is running.
1053 -------------------------------------------------------------------------------
1055 By default netdata listens on all IPs on port ${NETDATA_PORT},
1056 so you can access it with:
1058 http://this.machine.ip:${NETDATA_PORT}/
1060 To stop netdata, just kill it, with:
1064 To start it, just run it:
1066 ${NETDATA_PREFIX}/usr/sbin/netdata
1072 echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"