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 "%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"
680 |.-. .-. .-. .-. .-. netdata .-. .-. .-. .-
681 | '-' '-' '-' '-' ' is installed now! '-' '-' '-'
682 +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->
684 enjoy real-time performance and health monitoring...
690 # -----------------------------------------------------------------------------
691 # stop a running netdata
694 [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
695 [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
699 stop_netdata_on_pid() {
700 local pid="$1" ret=0 count=0
702 isnetdata $pid || return 0
704 printf >&2 "Stopping netdata on pid $pid ..."
705 while [ ! -z "$pid" -a $ret -eq 0 ]
709 echo >&2 "Cannot stop the running netdata on pid $pid."
713 count=$(( count + 1 ))
715 run kill $pid 2>/dev/null
718 test $ret -eq 0 && printf >&2 "." && sleep 2
724 echo >&2 "SORRY! CANNOT STOP netdata ON PID $pid !"
728 echo >&2 "netdata on pid $pid stopped."
735 echo >&2 "Stopping a (possibly) running netdata..."
737 for p in $(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null) \
738 $(cat /var/run/netdata.pid 2>/dev/null) \
739 $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
740 $(pidof netdata 2>/dev/null)
742 stop_netdata_on_pid $p
746 # -----------------------------------------------------------------------------
747 # check netdata for systemd
750 # if the directory /etc/systemd/system does not exit, it is not systemd
751 [ ! -d /etc/systemd/system ] && return 1
753 # if pid 1 is systemd, it is systemd
754 [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
756 # if systemd is running, it is systemd
757 pidof systemd >/dev/null 2>&1 && return 0
759 # else, it is not systemd
764 if [ "${UID}" -eq 0 ]
769 # systemd is running on this system
771 if [ ! -f /etc/systemd/system/netdata.service ]
773 echo >&2 "Installing systemd service..."
774 run cp system/netdata.service /etc/systemd/system/netdata.service && \
775 run systemctl daemon-reload && \
776 run systemctl enable netdata
782 service netdata restart && started=1
785 if [ ${started} -eq 0 ]
787 # check if we can use the system service
790 service netdata restart && started=1
791 if [ ${started} -eq 0 ]
793 service netdata start && started=1
798 if [ ${started} -eq 0 ]
800 # still not started...
804 echo >&2 "Starting netdata..."
805 run ${NETDATA_PREFIX}/usr/sbin/netdata -P ${NETDATA_RUN_DIR}/netdata.pid "${@}"
809 echo >&2 "SORRY! FAILED TO START NETDATA!"
812 echo >&2 "OK. NetData Started!"
818 # -----------------------------------------------------------------------------
819 # save a config file, if it is not already there
821 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
824 echo >&2 "-------------------------------------------------------------------------------"
826 echo >&2 "Downloading default configuration from netdata..."
829 # remove a possibly obsolete download
830 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
832 # disable a proxy to get data from the local netdata
837 wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
841 if [ $ret -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
843 curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
847 if [ $ret -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
849 mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
850 echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
852 if [ "${UID}" -eq 0 ]
854 chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
856 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
858 echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
859 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
863 # -----------------------------------------------------------------------------
866 ksm_is_available_but_disabled() {
869 -------------------------------------------------------------------------------
870 Memory de-duplication instructions
872 You have kernel memory de-duper (called Kernel Same-page Merging,
873 or KSM) available, but it is not currently enabled.
877 echo 1 >/sys/kernel/mm/ksm/run
878 echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
880 If you enable it, you will save 40-60% of netdata memory.
885 ksm_is_not_available() {
888 -------------------------------------------------------------------------------
889 Memory de-duplication not present in your kernel
891 It seems you do not have kernel memory de-duper (called Kernel Same-page
892 Merging, or KSM) available.
894 To enable it, you need a kernel built with CONFIG_KSM=y
896 If you can have it, you will save 40-60% of netdata memory.
901 if [ -f "/sys/kernel/mm/ksm/run" ]
903 if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
905 ksm_is_available_but_disabled
911 # -----------------------------------------------------------------------------
912 # Check for version.txt
914 if [ ! -s web/version.txt ]
918 -------------------------------------------------------------------------------
919 Version update check warning
921 The way you downloaded netdata, we cannot find its version. This means the
922 Update check on the dashboard, will not work.
924 If you want to have version update check, please re-install it
925 following the procedure in:
927 https://github.com/firehol/netdata/wiki/Installation
932 # -----------------------------------------------------------------------------
933 # apps.plugin warning
935 if [ "${UID}" -ne 0 ]
939 -------------------------------------------------------------------------------
940 apps.plugin needs privileges
942 Since you have installed netdata as a normal user, to have apps.plugin collect
943 all the needed data, you have to give it the access rights it needs, by running
944 either of the following sets of commands:
946 To run apps.plugin with escalated capabilities:
948 sudo chown root:${NETDATA_USER} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
949 sudo chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
950 sudo setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
952 or, to run apps.plugin as root:
954 sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
955 sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
957 apps.plugin is performing a hard-coded function of data collection for all
958 running processes. It cannot be instructed from the netdata daemon to perform
959 any task, so it is pretty safe to do this.
964 # -----------------------------------------------------------------------------
965 # Keep un-install info
967 cat >netdata-uninstaller.sh <<UNINSTALL
970 # this script will uninstall netdata
972 if [ "\$1" != "--force" ]
974 echo >&2 "This script will REMOVE netdata from your system."
975 echo >&2 "Run it again with --force to do it."
979 echo >&2 "Stopping a possibly running netdata..."
980 for p in \$(pidof netdata); do kill \$p; done
984 if [ ! -z "\$1" -a -d "\$1" ]
987 echo "Deleting directory '\$1' ..."
992 if [ ! -z "${NETDATA_PREFIX}" -a -d "${NETDATA_PREFIX}" ]
994 # installation prefix was given
996 deletedir "${NETDATA_PREFIX}"
999 # installation prefix was NOT given
1001 if [ -f "${NETDATA_PREFIX}/usr/sbin/netdata" ]
1003 echo "Deleting ${NETDATA_PREFIX}/usr/sbin/netdata ..."
1004 rm -i "${NETDATA_PREFIX}/usr/sbin/netdata"
1007 deletedir "${NETDATA_PREFIX}/etc/netdata"
1008 deletedir "${NETDATA_PREFIX}/usr/share/netdata"
1009 deletedir "${NETDATA_PREFIX}/usr/libexec/netdata"
1010 deletedir "${NETDATA_PREFIX}/var/lib/netdata"
1011 deletedir "${NETDATA_PREFIX}/var/cache/netdata"
1012 deletedir "${NETDATA_PREFIX}/var/log/netdata"
1015 if [ -f /etc/logrotate.d/netdata ]
1017 echo "Deleting /etc/logrotate.d/netdata ..."
1018 rm -i /etc/logrotate.d/netdata
1021 if [ -f /etc/systemd/system/netdata.service ]
1023 echo "Deleting /etc/systemd/system/netdata.service ..."
1024 rm -i /etc/systemd/system/netdata.service
1027 getent passwd netdata > /dev/null
1031 echo "You may also want to remove the user netdata"
1033 echo " userdel netdata"
1036 getent group netdata > /dev/null
1040 echo "You may also want to remove the group netdata"
1042 echo " groupdel netdata"
1045 getent group docker > /dev/null
1046 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_DOCKER}" = "1" ]
1049 echo "You may also want to remove the netdata user from the docker group"
1051 echo " gpasswd -d netdata docker"
1055 chmod 750 netdata-uninstaller.sh
1057 # -----------------------------------------------------------------------------
1062 -------------------------------------------------------------------------------
1064 OK. NetData is installed and it is running.
1066 -------------------------------------------------------------------------------
1068 By default netdata listens on all IPs on port ${NETDATA_PORT},
1069 so you can access it with:
1071 http://this.machine.ip:${NETDATA_PORT}/
1073 To stop netdata, just kill it, with:
1077 To start it, just run it:
1079 ${NETDATA_PREFIX}/usr/sbin/netdata
1083 echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"
1087 cat >netdata-updater.sh.new <<REINSTALL
1091 [ "\${1}" = "-f" ] && force=1
1093 export PATH="\${PATH}:${PATH}"
1094 export CFLAGS="${CFLAGS}"
1096 INSTALL_UID="${UID}"
1097 if [ "\${INSTALL_UID}" != "\${UID}" ]
1099 echo >&2 "This script should be run as user with uid \${INSTALL_UID} but it now runs with uid \${UID}"
1103 # make sure we cd to the working directory
1104 cd "${REINSTALL_PWD}" || exit 1
1106 # make sure there is .git here
1107 [ \${force} -eq 0 -a ! -d .git ] && echo >&2 "No git structures found at: ${REINSTALL_PWD} (use -f for force re-install)" && exit 1
1109 # signal netdata to start saving its database
1110 # this is handy if your database is big
1111 pids=\$(pidof netdata)
1112 [ ! -z "\${pids}" ] && kill -USR1 \${pids}
1117 # we are running on a terminal
1118 # open fd 3 and send it to stderr
1122 # create a temporary file for the log
1123 tmp=\$(mktemp /tmp/netdata-updater-log-XXXXXX.log)
1124 # open fd 3 and send it to tmp
1129 echo >&3 "\$(date) : INFO: " "\${@}"
1137 echo >&3 "\$(date) : ERROR: " "\${@}"
1140 # this is what we will do if it fails (head-less only)
1142 error "FAILED TO UPDATE NETDATA : \${1}"
1144 if [ ! -z "\${tmp}" ]
1152 get_latest_commit_id() {
1154 grep ^commit 2>&3 |\\
1156 cut -d ' ' -f 2 2>&3
1160 [ -z "\${tmp}" ] && info "Running on a terminal - (this script also supports running headless from crontab)"
1166 info "Updating netdata source from github..."
1168 last_commit="\$(get_latest_commit_id)"
1169 [ \${force} -eq 0 -a -z "\${last_commit}" ] && failed "CANNOT GET LAST COMMIT ID (use -f for force re-install)"
1171 git pull >&3 2>&3 || failed "CANNOT FETCH LATEST SOURCE (use -f for force re-install)"
1173 new_commit="\$(get_latest_commit_id)"
1174 if [ \${force} -eq 0 ]
1176 [ -z "\${new_commit}" ] && failed "CANNOT GET NEW LAST COMMIT ID (use -f for force re-install)"
1177 [ "\${new_commit}" = "\${last_commit}" ] && info "Nothing to be done! (use -f to force re-install)" && exit 0
1179 elif [ \${force} -eq 0 ]
1181 failed "CANNOT FIND GIT STRUCTURES IN \$(pwd) (use -f for force re-install)"
1185 info "Re-installing netdata..."
1186 ${REINSTALL_COMMAND// --dont-wait/} --dont-wait >&3 2>&3 || failed "FAILED TO COMPILE/INSTALL NETDATA"
1188 [ ! -z "\${tmp}" ] && rm "\${tmp}" && tmp=
1192 # the installer updates this script - so we run and exit in a single line
1194 ###############################################################################
1195 ###############################################################################
1197 chmod 755 netdata-updater.sh.new
1198 mv -f netdata-updater.sh.new netdata-updater.sh
1199 echo >&2 "Update script generated : ./netdata-updater.sh"
1200 elif [ -f "netdata-updater.sh" ]
1202 rm "netdata-updater.sh"
1208 |.-. .-. .-. .-. .-. netdata .-. .-
1209 | '-' '-' '-' '-' ' is installed and running now! '-'
1210 +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->
1212 enjoy real-time performance and health monitoring...