summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorEmmanuel Vasilakis <mrzammler@mm.st>2023-07-24 21:00:26 +0300
committerGitHub <noreply@github.com>2023-07-24 19:00:26 +0100
commitd759ebbb7f65b84eb9874e86985bffac349e7f4b (patch)
treee442a13f06b999867b75a3927d392ccd2f8a2e77 /daemon
parent7a0841f7a3f509daad4418fd19a0ab154c7a2f65 (diff)
Add a machine distinct id to analytics (#15485)
* add a system distinct id to analytics
Diffstat (limited to 'daemon')
-rwxr-xr-xdaemon/anonymous-statistics.sh.in18
1 files changed, 18 insertions, 0 deletions
diff --git a/daemon/anonymous-statistics.sh.in b/daemon/anonymous-statistics.sh.in
index 32cbc71dbd..6b27dfea42 100755
--- a/daemon/anonymous-statistics.sh.in
+++ b/daemon/anonymous-statistics.sh.in
@@ -71,6 +71,23 @@ NETDATA_PREBUILT_DISTRO="${42}"
[ -z "$NETDATA_REGISTRY_UNIQUE_ID" ] && NETDATA_REGISTRY_UNIQUE_ID="00000000-0000-0000-0000-000000000000"
+KERNEL_NAME="$(uname -s)"
+MD5_PATH="$(exec <&- 2>&-; which md5sum || command -v md5sum || type md5sum)"
+
+if [ "${KERNEL_NAME}" = Darwin ] && command -v ioreg >/dev/null 2>&1; then
+ SYSTEM_DISTINCT_ID="macos-$(ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }')"
+elif [ -f /etc/machine-id ] && [ -n "$MD5_PATH" ]; then
+ SYSTEM_DISTINCT_ID="machine-$($MD5_PATH < /etc/machine-id | cut -f1 -d" ")"
+elif [ -f /var/db/dbus/machine-id ] && [ -n "$MD5_PATH" ]; then
+ SYSTEM_DISTINCT_ID="dbus-$($MD5_PATH < /var/db/dbus/machine-id | cut -f1 -d" ")"
+elif [ -f /var/lib/dbus/machine-id ] && [ -n "$MD5_PATH" ]; then
+ SYSTEM_DISTINCT_ID="dbus-$($MD5_PATH < /var/lib/dbus/machine-id | cut -f1 -d" ")"
+elif command -v uuidgen > /dev/null 2>&1; then
+ SYSTEM_DISTINCT_ID="uuid-$(uuidgen | tr '[:upper:]' '[:lower:]')"
+else
+ SYSTEM_DISTINCT_ID="null"
+fi
+
# define body of request to be sent
REQ_BODY="$(cat << EOF
{
@@ -105,6 +122,7 @@ REQ_BODY="$(cat << EOF
"system_virt_detection": "${NETDATA_SYSTEM_VIRT_DETECTION}",
"system_container": "${NETDATA_SYSTEM_CONTAINER}",
"system_container_detection": "${NETDATA_SYSTEM_CONTAINER_DETECTION}",
+ "system_distinct_id": "${SYSTEM_DISTINCT_ID}",
"container_os_name": "${NETDATA_CONTAINER_OS_NAME}",
"container_os_id": "${NETDATA_CONTAINER_OS_ID}",
"container_os_id_like": "${NETDATA_CONTAINER_OS_ID_LIKE}",