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 REINSTALL_PWD="${PWD}"
29 REINSTALL_COMMAND="$(printf "CFLAGS=\"%s\" " "${CFLAGS}"; printf "%q " "$0" "${@}"; printf "\n")"
31 service="$(which service 2>/dev/null || command -v service 2>/dev/null)"
32 systemctl="$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)"
34 local cmd="${1}" action="${2}"
36 if [ ! -z "${service}" ]
38 run "${service}" "${cmd}" "${action}"
40 elif [ ! -z "${systemctl}" ]
42 run "${systemctl}" "${action}" "${cmd}"
57 ${ME} <installer options>
59 Valid <installer options> are:
61 --install /PATH/TO/INSTALL
63 If your give: --install /opt
64 netdata will be installed in /opt/netdata
68 Do not (re)start netdata.
73 Do not wait for the user to press ENTER.
74 Start immediately building it.
77 --libs-are-really-here
79 If you get errors about missing zlib,
80 or libuuid but you know it is available,
81 you have a broken pkg-config.
82 Use this option to allow it continue
83 without checking pkg-config.
85 Netdata will by default be compiled with gcc optimization -O3
86 If you need to pass different CFLAGS, use something like this:
88 CFLAGS="<gcc options>" ${ME} <installer options>
90 For the installer to complete successfully, you will need
91 these packages installed:
93 gcc make autoconf automake pkg-config zlib1g-dev (or zlib-devel)
94 uuid-dev (or libuuid-devel)
96 For the plugins, you will at least need:
103 md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null)"
104 get_git_config_signatures() {
107 [ ! -d "conf.d" ] && echo >&2 "Wrong directory." && return 1
108 [ -z "${md5sum}" -o ! -x "${md5sum}" ] && echo >&2 "No md5sum command." && return 1
110 echo >configs.signatures.tmp
112 for x in $(find conf.d -name \*.conf)
116 for c in $(git log --follow "conf.d/${x}" | grep ^commit | cut -d ' ' -f 2)
118 git checkout ${c} "conf.d/${x}" || continue
119 s="$(cat "conf.d/${x}" | md5sum | cut -d ' ' -f 1)"
120 echo >>configs.signatures.tmp "${x}:${s}"
123 git checkout HEAD "conf.d/${x}" || break
126 cat configs.signatures.tmp |\
130 echo "declare -A configs_signatures=("
134 echo " ['${md5}']='${file}'"
137 } >configs.signatures
139 rm configs.signatures.tmp
145 while [ ! -z "${1}" ]
147 if [ "$1" = "--install" ]
149 NETDATA_PREFIX="${2}/netdata"
151 elif [ "$1" = "--zlib-is-really-here" -o "$1" = "--libs-are-really-here" ]
155 elif [ "$1" = "--dont-start-it" ]
159 elif [ "$1" = "--dont-wait" ]
163 elif [ "$1" = "--help" -o "$1" = "-h" ]
167 elif [ "$1" = "get_git_config_signatures" ]
169 get_git_config_signatures && exit 0
174 echo >&2 "I cannot understand option '$1'."
183 The real-time performance monitoring system.
185 You are about to build and install netdata to your system.
187 It will be installed at these locations:
189 - the daemon at ${NETDATA_PREFIX}/usr/sbin/netdata
190 - config files at ${NETDATA_PREFIX}/etc/netdata
191 - web files at ${NETDATA_PREFIX}/usr/share/netdata
192 - plugins at ${NETDATA_PREFIX}/usr/libexec/netdata
193 - cache files at ${NETDATA_PREFIX}/var/cache/netdata
194 - db files at ${NETDATA_PREFIX}/var/lib/netdata
195 - log files at ${NETDATA_PREFIX}/var/log/netdata
196 - pid file at ${NETDATA_PREFIX}/var/run
198 This installer allows you to change the installation path.
199 Press Control-C and run the same command with --help for help.
203 if [ "${UID}" -ne 0 ]
205 if [ -z "${NETDATA_PREFIX}" ]
207 cat <<NONROOTNOPREFIX
209 Sorry! This will fail!
211 You are attempting to install netdata as non-root, but you plan to install it
214 Please set an installation prefix, like this:
216 $0 ${@} --install /tmp
218 or, run the installer as root:
222 We suggest to install it as root, or certain data collectors will not be able
223 to work. Netdata drops root privileges when running. So, if you plan to keep
224 it, install it as root to get the full functionality.
233 You are about to install netdata as a non-root user.
234 Netdata will work, but a few data collection modules that
235 require root access will fail.
237 If you installing permanently on your system, run the
247 if [ "$(type autoreconf 2> /dev/null)" ]
255 set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
256 eval $maj=\$1 $min=\$2
258 autoconf_maj_min AMAJ AMIN
263 elif [ "$AMAJ" -eq 2 -a "$AMIN" -ge 60 ]
267 echo "Found autotools $AMAJ.$AMIN"
270 echo "No autotools found"
273 if [ ! "$have_autotools" ]
277 echo "Will skip autoreconf step"
281 -------------------------------------------------------------------------------
282 autotools 2.60 or later is required
284 Sorry, you do not seem to have autotools 2.60 or later, which is
285 required to build from the git sources of netdata.
287 You can either install a suitable version of autotools and automake
288 or download a netdata package which does not have these dependencies.
290 Source packages where autotools have already been run are available
292 https://firehol.org/download/netdata/
294 The unsigned/master folder tracks the head of the git tree and released
295 packages are also available.
301 if [ ${DONOTWAIT} -eq 0 ]
303 if [ ! -z "${NETDATA_PREFIX}" ]
305 read -p "Press ENTER to build and install netdata to '${NETDATA_PREFIX}' > "
307 read -p "Press ENTER to build and install netdata to your system > "
314 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
316 Sorry! NetData failed to build...
318 You many need to check these:
320 1. The package uuid-dev (or libuuid-devel) has to be installed.
322 If your system cannot find libuuid, although it is installed
323 run me with the option: --libs-are-really-here
325 2. The package zlib1g-dev (or zlib-devel) has to be installed.
327 If your system cannot find zlib, although it is installed
328 run me with the option: --libs-are-really-here
330 3. You need basic build tools installed, like:
332 gcc make autoconf automake pkg-config
334 Autoconf version 2.60 or higher is required.
336 If you still cannot get it to build, ask for help at github:
338 https://github.com/firehol/netdata/issues
347 printf >>netdata-installer.log "# "
348 printf >>netdata-installer.log "%q " "${@}"
349 printf >>netdata-installer.log " ... "
352 printf >&2 ":-----------------------------------------------------------------------------\n"
353 printf >&2 "Running command:\n"
355 printf >&2 "%q " "${@}"
363 printf >>netdata-installer.log "FAILED!\n"
365 printf >>netdata-installer.log "OK\n"
371 if [ ${LIBS_ARE_HERE} -eq 1 ]
374 echo >&2 "ok, assuming libs are really installed."
375 export ZLIB_CFLAGS=" "
376 export ZLIB_LIBS="-lz"
377 export UUID_CFLAGS=" "
378 export UUID_LIBS="-luuid"
381 trap build_error EXIT
383 if [ "$have_autotools" ]
385 run ./autogen.sh || exit 1
389 --prefix="${NETDATA_PREFIX}/usr" \
390 --sysconfdir="${NETDATA_PREFIX}/etc" \
391 --localstatedir="${NETDATA_PREFIX}/var" \
392 --with-zlib --with-math --with-user=netdata \
393 CFLAGS="${CFLAGS}" || exit 1
395 # remove the build_error hook
398 if [ -f src/netdata ]
400 echo >&2 "Cleaning a possibly old compilation ..."
404 echo >&2 "Compiling netdata ..."
407 if [ "${BASH_VERSINFO[0]}" -ge "4" ]
409 declare -A configs_signatures=()
410 if [ -f "configs.signatures" ]
412 source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !"
416 # migrate existing configuration files
417 # for node.d and charts.d
418 if [ -d "${NETDATA_PREFIX}/etc/netdata" ]
420 # the configuration directory exists
422 if [ ! -d "${NETDATA_PREFIX}/etc/netdata/charts.d" ]
424 run mkdir "${NETDATA_PREFIX}/etc/netdata/charts.d"
427 # move the charts.d config files
428 for x in apache ap cpu_apps cpufreq example exim hddtemp load_average mem_apps mysql nginx nut opensips phpfpm postfix sensors squid tomcat
430 for y in "" ".old" ".orig"
432 if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}" ]
434 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}"
439 if [ ! -d "${NETDATA_PREFIX}/etc/netdata/node.d" ]
441 run mkdir "${NETDATA_PREFIX}/etc/netdata/node.d"
444 # move the node.d config files
445 for x in named sma_webbox snmp
447 for y in "" ".old" ".orig"
449 if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}" ]
451 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}"
457 # backup user configurations
458 installer_backup_suffix="${PID}.${RANDOM}"
459 for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
463 # make a backup of the configuration file
464 cp -p "${x}" "${x}.old"
466 if [ -z "${md5sum}" -o ! -x "${md5sum}" ]
468 # we don't have md5sum - keep it
469 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
471 # find it relative filename
472 f="${x/*\/etc\/netdata\//}"
475 md5="$(cat "${x}" | ${md5sum} | cut -d ' ' -f 1)"
478 if [ -f "conf.d/${f}" ]
480 cp "conf.d/${f}" "${x}.orig"
483 if [ "${BASH_VERSINFO[0]}" -ge "4" ]
485 if [ "${configs_signatures[${md5}]}" = "${f}" ]
487 # it is a stock version - don't keep it
488 echo >&2 "File '${x}' is stock version."
490 # edited by user - keep it
491 echo >&2 "File '${x}' has been edited by user."
492 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
495 echo >&2 "File '${x}' cannot be check for custom edits."
496 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
500 elif [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
502 rm -f "${x}.installer_backup.${installer_backup_suffix}"
506 echo >&2 "Installing netdata ..."
507 run make install || exit 1
509 # restore user configurations
510 for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
512 if [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
514 cp -p "${x}.installer_backup.${installer_backup_suffix}" "${x}"
515 rm -f "${x}.installer_backup.${installer_backup_suffix}"
519 NETDATA_ADDED_TO_DOCKER=0
522 getent group netdata > /dev/null
525 echo >&2 "Adding netdata user group ..."
526 run groupadd -r netdata
529 getent passwd netdata > /dev/null
532 echo >&2 "Adding netdata user account ..."
533 run useradd -r -g netdata -c netdata -s $(which nologin || echo '/bin/false') -d / netdata
536 getent group docker > /dev/null
539 # find the users in the docker group
540 docker=$(getent group docker | cut -d ':' -f 4)
541 if [[ ",${docker}," =~ ,netdata, ]]
543 # netdata is already there
546 # netdata is not in docker group
547 echo >&2 "Adding netdata user to the docker group (needed to get container names) ..."
548 run usermod -a -G docker netdata
550 # let the uninstall script know
551 NETDATA_ADDED_TO_DOCKER=1
554 if [ -d /etc/logrotate.d -a ! -f /etc/logrotate.d/netdata ]
556 echo >&2 "Adding netdata logrotate configuration ..."
557 run cp system/netdata.logrotate /etc/logrotate.d/netdata
562 # -----------------------------------------------------------------------------
563 # load options from the configuration file
565 # create an empty config if it does not exist
566 [ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
568 # function to extract values from the config file
570 local key="${1}" value="${2}" line=
572 if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
574 line="$( grep "^[[:space:]]*${key}[[:space:]]*=[[:space:]]*" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" | head -n 1 )"
575 [ ! -z "${line}" ] && value="$( echo "${line}" | cut -d '=' -f 2 | sed -e "s/^[[:space:]]\+//g" -e "s/[[:space:]]\+$//g" )"
583 [ ! "${UID}" = "0" ] && defuser="${USER}"
584 NETDATA_USER="$( config_option "run as user" "${defuser}" )"
586 NETDATA_WEB_USER="$( config_option "web files owner" "${defuser}" )"
587 NETDATA_WEB_GROUP="$( config_option "web files group" "${NETDATA_WEB_USER}" )"
591 NETDATA_DEBUG="$( config_option "debug flags" ${defdebug} )"
595 NETDATA_PORT="$( config_option "default port" ${defport} )"
596 NETDATA_PORT2="$( config_option "port" ${defport} )"
598 if [ "${NETDATA_PORT}" != "${NETDATA_PORT2}" ]
600 if [ "${NETDATA_PORT2}" != "${defport}" ]
602 NETDATA_PORT="${NETDATA_PORT2}"
607 NETDATA_LIB_DIR="$( config_option "lib directory" "${NETDATA_PREFIX}/var/lib/netdata" )"
608 NETDATA_CACHE_DIR="$( config_option "cache directory" "${NETDATA_PREFIX}/var/cache/netdata" )"
609 NETDATA_WEB_DIR="$( config_option "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )"
610 NETDATA_LOG_DIR="$( config_option "log directory" "${NETDATA_PREFIX}/var/log/netdata" )"
611 NETDATA_CONF_DIR="$( config_option "config directory" "${NETDATA_PREFIX}/etc/netdata" )"
612 NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
615 # -----------------------------------------------------------------------------
616 # prepare the directories
618 # this is needed if NETDATA_PREFIX is not empty
619 if [ ! -d "${NETDATA_RUN_DIR}" ]
621 mkdir -p "${NETDATA_RUN_DIR}" || exit 1
625 echo >&2 "Fixing directories (user: ${NETDATA_USER})..."
626 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"
630 echo >&2 "Creating directory '${x}'"
631 run mkdir -p "${x}" || exit 1
636 if [ "${x}" = "${NETDATA_WEB_DIR}" ]
638 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}..."
640 run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_USER}..."
644 run chmod 0755 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
649 run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
650 run chmod 0755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
651 run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
654 # fix apps.plugin to be setuid to root
655 run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
656 run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
660 # -----------------------------------------------------------------------------
661 # check if we can re-start netdata
663 if [ ${DONOTSTART} -eq 1 ]
665 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
667 echo >&2 "Generating empty config file in: ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
668 echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
670 if [ "${UID}" -eq 0 ]
672 chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
674 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
676 echo >&2 "OK. It is now installed and ready."
680 # -----------------------------------------------------------------------------
681 # stop a running netdata
684 [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
685 [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
689 stop_netdata_on_pid() {
690 local pid="$1" ret=0 count=0
692 isnetdata $pid || return 0
694 printf >&2 "Stopping netdata on pid $pid ..."
695 while [ ! -z "$pid" -a $ret -eq 0 ]
699 echo >&2 "Cannot stop the running netdata on pid $pid."
703 count=$(( count + 1 ))
705 run kill $pid 2>/dev/null
708 test $ret -eq 0 && printf >&2 "." && sleep 2
714 echo >&2 "SORRY! CANNOT STOP netdata ON PID $pid !"
718 echo >&2 "netdata on pid $pid stopped."
725 echo >&2 "Stopping a (possibly) running netdata..."
727 for p in $(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null) \
728 $(cat /var/run/netdata.pid 2>/dev/null) \
729 $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
730 $(pidof netdata 2>/dev/null)
732 stop_netdata_on_pid $p
736 # -----------------------------------------------------------------------------
737 # check netdata for systemd
740 # if the directory /etc/systemd/system does not exit, it is not systemd
741 [ ! -d /etc/systemd/system ] && return 1
743 # if pid 1 is systemd, it is systemd
744 [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
746 # if systemd is running, it is systemd
747 pidof systemd >/dev/null 2>&1 && return 0
749 # else, it is not systemd
754 if [ "${UID}" -eq 0 ]
759 # systemd is running on this system
761 if [ ! -f /etc/systemd/system/netdata.service ]
763 echo >&2 "Installing systemd service..."
764 run cp system/netdata.service /etc/systemd/system/netdata.service && \
765 run systemctl daemon-reload && \
766 run systemctl enable netdata
772 service netdata restart && started=1
775 if [ ${started} -eq 0 ]
777 # check if we can use the system service
780 service netdata restart && started=1
781 if [ ${started} -eq 0 ]
783 service netdata start && started=1
788 if [ ${started} -eq 0 ]
790 # still not started...
794 echo >&2 "Starting netdata..."
795 run ${NETDATA_PREFIX}/usr/sbin/netdata -P ${NETDATA_RUN_DIR}/netdata.pid "${@}"
799 echo >&2 "SORRY! FAILED TO START NETDATA!"
802 echo >&2 "OK. NetData Started!"
808 # -----------------------------------------------------------------------------
809 # save a config file, if it is not already there
811 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
814 echo >&2 "-------------------------------------------------------------------------------"
816 echo >&2 "Downloading default configuration from netdata..."
819 # remove a possibly obsolete download
820 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
822 # disable a proxy to get data from the local netdata
827 wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
831 if [ $ret -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
833 curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
837 if [ $ret -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
839 mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
840 echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
842 if [ "${UID}" -eq 0 ]
844 chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
846 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
848 echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
849 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
853 # -----------------------------------------------------------------------------
856 ksm_is_available_but_disabled() {
859 -------------------------------------------------------------------------------
860 Memory de-duplication instructions
862 You have kernel memory de-duper (called Kernel Same-page Merging,
863 or KSM) available, but it is not currently enabled.
867 echo 1 >/sys/kernel/mm/ksm/run
868 echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
870 If you enable it, you will save 40-60% of netdata memory.
875 ksm_is_not_available() {
878 -------------------------------------------------------------------------------
879 Memory de-duplication not present in your kernel
881 It seems you do not have kernel memory de-duper (called Kernel Same-page
882 Merging, or KSM) available.
884 To enable it, you need a kernel built with CONFIG_KSM=y
886 If you can have it, you will save 40-60% of netdata memory.
891 if [ -f "/sys/kernel/mm/ksm/run" ]
893 if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
895 ksm_is_available_but_disabled
901 # -----------------------------------------------------------------------------
902 # Check for version.txt
904 if [ ! -s web/version.txt ]
908 -------------------------------------------------------------------------------
909 Version update check warning
911 The way you downloaded netdata, we cannot find its version. This means the
912 Update check on the dashboard, will not work.
914 If you want to have version update check, please re-install it
915 following the procedure in:
917 https://github.com/firehol/netdata/wiki/Installation
922 # -----------------------------------------------------------------------------
923 # apps.plugin warning
925 if [ "${UID}" -ne 0 ]
929 -------------------------------------------------------------------------------
930 apps.plugin needs privileges
932 Since you have installed netdata as a normal user, to have apps.plugin collect
933 all the needed data, you have to give it the access rights it needs, by running
934 either of the following sets of commands:
936 To run apps.plugin with escalated capabilities:
938 sudo chown root:${NETDATA_USER} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
939 sudo chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
940 sudo setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
942 or, to run apps.plugin as root:
944 sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
945 sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
947 apps.plugin is performing a hard-coded function of data collection for all
948 running processes. It cannot be instructed from the netdata daemon to perform
949 any task, so it is pretty safe to do this.
954 # -----------------------------------------------------------------------------
955 # Keep un-install info
957 cat >netdata-uninstaller.sh <<UNINSTALL
960 # this script will uninstall netdata
962 if [ "\$1" != "--force" ]
964 echo >&2 "This script will REMOVE netdata from your system."
965 echo >&2 "Run it again with --force to do it."
969 echo >&2 "Stopping a possibly running netdata..."
970 for p in \$(pidof netdata); do kill \$p; done
974 if [ ! -z "\$1" -a -d "\$1" ]
977 echo "Deleting directory '\$1' ..."
982 if [ ! -z "${NETDATA_PREFIX}" -a -d "${NETDATA_PREFIX}" ]
984 # installation prefix was given
986 deletedir "${NETDATA_PREFIX}"
989 # installation prefix was NOT given
991 if [ -f "${NETDATA_PREFIX}/usr/sbin/netdata" ]
993 echo "Deleting ${NETDATA_PREFIX}/usr/sbin/netdata ..."
994 rm -i "${NETDATA_PREFIX}/usr/sbin/netdata"
997 deletedir "${NETDATA_PREFIX}/etc/netdata"
998 deletedir "${NETDATA_PREFIX}/usr/share/netdata"
999 deletedir "${NETDATA_PREFIX}/usr/libexec/netdata"
1000 deletedir "${NETDATA_PREFIX}/var/lib/netdata"
1001 deletedir "${NETDATA_PREFIX}/var/cache/netdata"
1002 deletedir "${NETDATA_PREFIX}/var/log/netdata"
1005 if [ -f /etc/logrotate.d/netdata ]
1007 echo "Deleting /etc/logrotate.d/netdata ..."
1008 rm -i /etc/logrotate.d/netdata
1011 if [ -f /etc/systemd/system/netdata.service ]
1013 echo "Deleting /etc/systemd/system/netdata.service ..."
1014 rm -i /etc/systemd/system/netdata.service
1017 getent passwd netdata > /dev/null
1021 echo "You may also want to remove the user netdata"
1023 echo " userdel netdata"
1026 getent group netdata > /dev/null
1030 echo "You may also want to remove the group netdata"
1032 echo " groupdel netdata"
1035 getent group docker > /dev/null
1036 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_DOCKER}" = "1" ]
1039 echo "You may also want to remove the netdata user from the docker group"
1041 echo " gpasswd -d netdata docker"
1045 chmod 750 netdata-uninstaller.sh
1047 # -----------------------------------------------------------------------------
1052 -------------------------------------------------------------------------------
1054 OK. NetData is installed and it is running.
1056 -------------------------------------------------------------------------------
1058 By default netdata listens on all IPs on port ${NETDATA_PORT},
1059 so you can access it with:
1061 http://this.machine.ip:${NETDATA_PORT}/
1063 To stop netdata, just kill it, with:
1067 To start it, just run it:
1069 ${NETDATA_PREFIX}/usr/sbin/netdata
1075 echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"
1077 cat >netdata-updater.sh.new <<REINSTALL
1081 if [ "\${LAST_UID}" != "\${UID}" ]
1083 echo >&2 "This script should be run as user with uid \${LAST_UID} but it now runs with uid \${UID}"
1087 # make sure we cd to the working directory
1088 cd "${REINSTALL_PWD}" || exit 1
1090 # signal netdata to start saving its database
1091 # this is handy if your database is big
1092 pids=\$(pidof netdata)
1093 [ ! -z "\${pids}" ] && kill -USR1 \${pids}
1095 # this is what we will do if it fails (head-less only)
1097 echo >&2 "\$(date) : FAILED TO UPDATE NETDATA : \${1}"
1103 get_latest_commit_id() {
1104 git log | grep ^commit | head -n 1 | cut -d ' ' -f 2
1107 last_commit="\$(get_latest_commit_id)"
1108 [ -z "\${last_commit}" ] && failed "CANNOT GET LAST COMMIT ID"
1113 # running on a terminal
1114 echo >&2 "Running on a terminal - (this script also supports running headless from crontab)"
1117 echo >&2 "Updating source..."
1119 new_commit="\$(get_latest_commit_id)"
1120 [ -z "\${new_commit}" ] && echo >&2 "CANNOT GET NEW LAST COMMIT ID" && exit 1
1121 [ "\${new_commit}" = "\${last_commit}" ] && echo >&2 "Nothing to be done!" && exit 0
1124 echo >&2 "re-installing..."
1125 ${REINSTALL_COMMAND// --dont-wait/} --dont-wait || exit 1
1129 # do not generate any output, unless we fail
1131 # create a temporary file for the log
1132 tmp=\$(mktemp /tmp/netdata-updater-log-XXXXXX.log)
1134 # update source from git
1135 git pull >>"\${tmp}" 2>&1 || failed "CANNOT FETCH LATEST SOURCE"
1136 new_commit="\$(get_latest_commit_id)"
1137 [ -z "\${new_commit}" ] && failed "CANNOT GET NEW LAST COMMIT ID"
1138 [ "\${new_commit}" = "\${last_commit}" ] && exit 0
1140 # install the latest version
1141 ${REINSTALL_COMMAND// --dont-wait/} --dont-wait >>"\${tmp}" 2>&1 || failed "CANNOT BUILD AND INSTALL NETDATA"
1149 # the installer updates this script - so we run and exit in a single line
1151 ###############################################################################
1152 ###############################################################################
1154 chmod 755 netdata-updater.sh.new
1155 mv -f netdata-updater.sh.new netdata-updater.sh
1156 echo >&2 "Update script generated : ./netdata-updater.sh"