diff options
author | Chris Akritidis <43294513+cakrit@users.noreply.github.com> | 2019-01-30 13:08:17 +0200 |
---|---|---|
committer | Costa Tsaousis <costa@tsaousis.gr> | 2019-01-30 13:08:17 +0200 |
commit | 43628db5e954e0376e5cf8c27573e83c1cd702f4 (patch) | |
tree | 66cc1d5d33ed9b2fcac8346218e0dbd64c8d3850 /daemon | |
parent | ec90b63ffddf04289d340bacbb39865fffec9ac4 (diff) |
Minor updates to anonymous statistics (#5295)
Diffstat (limited to 'daemon')
-rwxr-xr-x | daemon/anonymous-statistics.sh.in | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/daemon/anonymous-statistics.sh.in b/daemon/anonymous-statistics.sh.in index 81f2b00627..f4375b1015 100755 --- a/daemon/anonymous-statistics.sh.in +++ b/daemon/anonymous-statistics.sh.in @@ -67,10 +67,14 @@ ARCHITECTURE="$(uname -m)" VIRTUALIZATION="unknown" VIRT_DETECTION="none" +CONTAINER="unknown" +CONT_DETECTION="none" if [ -n "$(command -v systemd-detect-virt 2>/dev/null)" ]; then - VIRTUALIZATION="$(systemd-detect-virt)" + VIRTUALIZATION="$(systemd-detect-virt -v)" VIRT_DETECTION="systemd-detect-virt" + CONTAINER="$(systemd-detect-virt -c)" + CONT_DETECTION="systemd-detect-virt" else if grep -q "^flags.*hypervisor" /proc/cpuinfo 2>/dev/null; then VIRTUALIZATION="hypervisor" @@ -79,36 +83,35 @@ else fi # ------------------------------------------------------------------------------------------------- -# detect containers - -CONTAINER="none" -CONT_DETECTION="none" +# detect containers with heuristics -IFS='(, ' read -r process _ </proc/1/sched -if [ "${process}" = "netdata" ]; then - CONTAINER="container" - CONT_DETECTION="process" -fi +if [ "${CONTAINER}" = "unknown" ] ; then + IFS='(, ' read -r process _ </proc/1/sched + if [ "${process}" = "netdata" ]; then + CONTAINER="container" + CONT_DETECTION="process" + fi -# ubuntu and debian supply /bin/running-in-container -# https://www.apt-browse.org/browse/ubuntu/trusty/main/i386/upstart/1.12.1-0ubuntu4/file/bin/running-in-container -if /bin/running-in-container >/dev/null 2>&1; then - CONTAINER="container" - CONT_DETECTION="/bin/running-in-container" -fi + # ubuntu and debian supply /bin/running-in-container + # https://www.apt-browse.org/browse/ubuntu/trusty/main/i386/upstart/1.12.1-0ubuntu4/file/bin/running-in-container + if /bin/running-in-container >/dev/null 2>&1; then + CONTAINER="container" + CONT_DETECTION="/bin/running-in-container" + fi -# lxc sets environment variable 'container' -#shellcheck disable=SC2154 -if [ -n "${container}" ]; then - CONTAINER="lxc" - CONT_DETECTION="containerenv" -fi + # lxc sets environment variable 'container' + #shellcheck disable=SC2154 + if [ -n "${container}" ]; then + CONTAINER="lxc" + CONT_DETECTION="containerenv" + fi -# docker creates /.dockerenv -# http://stackoverflow.com/a/25518345 -if [ -f "/.dockerenv" ]; then - CONTAINER="docker" - CONT_DETECTION="dockerenv" + # docker creates /.dockerenv + # http://stackoverflow.com/a/25518345 + if [ -f "/.dockerenv" ]; then + CONTAINER="docker" + CONT_DETECTION="dockerenv" + fi fi # ------------------------------------------------------------------------------------------------- |