summaryrefslogtreecommitdiffstats
path: root/daemon/anonymous-statistics.sh.in
blob: 7d73f6d618a74eb78f967ac54adb8de586b02a58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env sh

# Valid actions:

# - FATAL       - netdata exited due to a fatal condition
#      ACTION_RESULT  -- program name and thread tag
#      ACTION_DATA    -- fmt, args passed to fatal
# - START       - netdata started
#      ACTION_DATA     -- nan
# - EXIT     - installation action
#      ACTION_DATA    -- ret value of

ACTION="${1}"
ACTION_RESULT="${2}"
ACTION_DATA="${3}"
ACTION_DATA=$(echo "${ACTION_DATA}" | tr '"' "'")

# -------------------------------------------------------------------------------------------------
# check opt-out

if [ -f "@configdir_POST@/.opt-out-from-anonymous-statistics" ]; then
	exit 0
fi

# Shorten version for easier reporting
NETDATA_VERSION=$(echo "${NETDATA_VERSION}" | sed 's/-.*//g' | tr -d 'v')

echo "&av=${NETDATA_VERSION}\
&ec=${ACTION}\
&ea=${ACTION_RESULT}\
&el=${ACTION_DATA}\
&cd1=${NETDATA_SYSTEM_OS_NAME}\
&cd2=${NETDATA_SYSTEM_OS_ID}\
&cd3=${NETDATA_SYSTEM_OS_ID_LIKE}\
&cd4=${NETDATA_SYSTEM_OS_VERSION}\
&cd5=${NETDATA_SYSTEM_OS_VERSION_ID}\
&cd6=${NETDATA_SYSTEM_OS_DETECTION}\
&cd7=${NETDATA_SYSTEM_KERNEL_NAME}\
&cd8=${NETDATA_SYSTEM_KERNEL_VERSION}\
&cd9=${NETDATA_SYSTEM_ARCHITECTURE}\
&cd10=${NETDATA_SYSTEM_VIRTUALIZATION}\
&cd11=${NETDATA_SYSTEM_VIRT_DETECTION}\
&cd12=${NETDATA_SYSTEM_CONTAINER}\
&cd13=${NETDATA_SYSTEM_CONTAINER_DETECTION}" >> /tmp/as.log

# -------------------------------------------------------------------------------------------------
# send the anonymous statistics to GA
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
if [ -n "$(command -v curl 2>/dev/null)" ]; then
	curl -X POST -Ss --max-time 2 \
		--data "v=1" \
		--data "tid=UA-64295674-3" \
		--data "aip=1" \
		--data "ds=shell" \
		--data-urlencode "cid=${NETDATA_REGISTRY_UNIQUE_ID}" \
		--data-urlencode "cs=${NETDATA_REGISTRY_UNIQUE_ID}" \
		--data "t=event" \
		--data "ni=1" \
		--data "an=anonymous-statistics" \
		--data-urlencode "av=${NETDATA_VERSION}" \
		--data-urlencode "ec=${ACTION}" \
		--data-urlencode "ea=${ACTION_RESULT}" \
		--data-urlencode "el=${ACTION_DATA}" \
		--data-urlencode "cd1=${NETDATA_SYSTEM_OS_NAME}" \
		--data-urlencode "cd2=${NETDATA_SYSTEM_OS_ID}" \
		--data-urlencode "cd3=${NETDATA_SYSTEM_OS_ID_LIKE}" \
		--data-urlencode "cd4=${NETDATA_SYSTEM_OS_VERSION}" \
		--data-urlencode "cd5=${NETDATA_SYSTEM_OS_VERSION_ID}" \
		--data-urlencode "cd6=${NETDATA_SYSTEM_OS_DETECTION}" \
		--data-urlencode "cd7=${NETDATA_SYSTEM_KERNEL_NAME}" \
		--data-urlencode "cd8=${NETDATA_SYSTEM_KERNEL_VERSION}" \
		--data-urlencode "cd9=${NETDATA_SYSTEM_ARCHITECTURE}" \
		--data-urlencode "cd10=${NETDATA_SYSTEM_VIRTUALIZATION}" \
		--data-urlencode "cd11=${NETDATA_SYSTEM_VIRT_DETECTION}" \
		--data-urlencode "cd12=${NETDATA_SYSTEM_CONTAINER}" \
		--data-urlencode "cd13=${NETDATA_SYSTEM_CONTAINER_DETECTION}" \
		"https://www.google-analytics.com/collect" >/dev/null 2>&1
else
	wget -q -O - --timeout=1 "https://www.google-analytics.com/collect?\
&v=1\
&tid=UA-64295674-3\
&aip=1\
&ds=shell\
&cid=${NETDATA_REGISTRY_UNIQUE_ID}\
&cs=${NETDATA_REGISTRY_UNIQUE_ID}\
&t=event\
&ni=1\
&an=anonymous-statistics\
&av=${NETDATA_VERSION}\
&ec=${ACTION}\
&ea=${ACTION_RESULT}\
&el=${ACTION_DATA}\
&cd1=${NETDATA_SYSTEM_OS_NAME}\
&cd2=${NETDATA_SYSTEM_OS_ID}\
&cd3=${NETDATA_SYSTEM_OS_ID_LIKE}\
&cd4=${NETDATA_SYSTEM_OS_VERSION}\
&cd5=${NETDATA_SYSTEM_OS_VERSION_ID}\
&cd6=${NETDATA_SYSTEM_OS_DETECTION}\
&cd7=${NETDATA_SYSTEM_KERNEL_NAME}\
&cd8=${NETDATA_SYSTEM_KERNEL_VERSION}\
&cd9=${NETDATA_SYSTEM_ARCHITECTURE}\
&cd10=${NETDATA_SYSTEM_VIRTUALIZATION}\
&cd11=${NETDATA_SYSTEM_VIRT_DETECTION}\
&cd12=${NETDATA_SYSTEM_CONTAINER}\
&cd13=${NETDATA_SYSTEM_CONTAINER_DETECTION}\
" > /dev/null 2>&1
fi