]> arthur.barton.de Git - netdata.git/blobdiff - netdata-installer.sh
build: revert pid to live within /var/run/netdata
[netdata.git] / netdata-installer.sh
index fc87347e0785c18cbbfbe4142c89da13dbc29310..88333478d9ba08108cde8890ba4f93ce414770bb 100755 (executable)
@@ -96,29 +96,17 @@ Nice to see you are giving it a try!
 
 You are about to build and install netdata to your system.
 
-By default netdata will be installed as any other package:
+It will be installed at these locations:
 
-  - the daemon    at /usr/sbin/netdata
-  - config files  at /etc/netdata
-  - web files     at /usr/share/web/netdata
-  - plugins       at /usr/libexec/netdata
-  - cache files   at /var/cache/netdata
-  - log files     at /var/log/netdata
+  - the daemon    at ${NETDATA_PREFIX}/usr/sbin/netdata
+  - config files  at ${NETDATA_PREFIX}/etc/netdata
+  - web files     at ${NETDATA_PREFIX}/usr/share/netdata
+  - plugins       at ${NETDATA_PREFIX}/usr/libexec/netdata
+  - cache files   at ${NETDATA_PREFIX}/var/cache/netdata
+  - log files     at ${NETDATA_PREFIX}/var/log/netdata
 
-If you want to install it to another directory, run the
-installer like this:
-
-  $ME --install /path/to/install
-
-A new directory called netdata will be created as
-
-  /path/to/install/netdata
-
-and all of netdata will be installed into it.
-Nothing will be touched on your system.
-
-This installer accepts more options.
-Run it with --help for help.
+This installer allows you to change the installation path.
+Press Control-C and run the same command with --help for help.
 
 BANNER
 
@@ -306,6 +294,13 @@ fi
 # -----------------------------------------------------------------------------
 # stop a running netdata
 
+isnetdata() {
+       [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
+       [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
+       return 1
+}
+
+
 printf >&2 "Stopping a (possibly) running netdata..."
 ret=0
 count=0
@@ -318,8 +313,18 @@ do
        fi
 
        count=$((count + 1))
-       run killall netdata 2>/dev/null
-       ret=$?
+
+       pid=$(cat /var/run/netdata/netdata.pid 2>/dev/null)
+       isnetdata $pid || pid=
+       if [ ! -z "${pid}" ]
+               then
+               run kill $pid 2>/dev/null
+               ret=$?
+       else
+               run killall netdata 2>/dev/null
+               ret=$?
+       fi
+
        test $ret -eq 0 && printf >&2 "." && sleep 2
 done
 echo >&2
@@ -352,6 +357,10 @@ if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
        # remove a possibly obsolete download
        [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
 
+       # disable a proxy to get data from the local netdata
+       export http_proxy=
+       export https_proxy=
+
        # try wget
        wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
        ret=$?
@@ -396,3 +405,46 @@ To start it, just run it:
 Enjoy!
 
 END
+
+ksm_is_available_but_disabled() {
+       cat <<KSM1
+
+INFORMATION:
+
+I see you have kernel memory de-duper (called Kernel Same-page Merging,
+or KSM) available, but it is not currently enabled.
+
+To enable it run:
+
+echo 1 >/sys/kernel/mm/ksm/run
+echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
+
+If you enable it, you will save 20-60% of netdata memory.
+
+KSM1
+}
+
+ksm_is_not_available() {
+       cat <<KSM2
+
+INFORMATION:
+
+I see you do not have kernel memory de-duper (called Kernel Same-page
+Merging, or KSM) available.
+
+To enable it, you need a kernel built with CONFIG_KSM=y
+
+If you can have it, you will save 20-60% of netdata memory.
+
+KSM2
+}
+
+if [ -f "/sys/kernel/mm/ksm/run" ]
+       then
+       if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
+               then
+               ksm_is_available_but_disabled
+       fi
+else
+       ksm_is_not_available
+fi