summaryrefslogtreecommitdiffstats
path: root/daemon/anonymous-statistics.sh.in
blob: 32cbc71dbdc59aaf6f7d96bf8985266e6a6f2932 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/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" ] ||
  [ ! "${DISABLE_TELEMETRY:-0}" -eq 0 ] ||
  [ -n "$DISABLE_TELEMETRY" ] ||
  [ ! "${DO_NOT_TRACK:-0}" -eq 0 ] ||
  [ -n "$DO_NOT_TRACK" ]; then
  exit 0
fi

# -------------------------------------------------------------------------------------------------
# Get the extra variables

NETDATA_CONFIG_STREAM_ENABLED="${4}"
NETDATA_CONFIG_MEMORY_MODE="${5}"
NETDATA_CONFIG_EXPORTING_ENABLED="${6}"
NETDATA_EXPORTING_CONNECTORS="${7}"
NETDATA_ALLMETRICS_PROMETHEUS_USED="${8}"
NETDATA_ALLMETRICS_SHELL_USED="${9}"
NETDATA_ALLMETRICS_JSON_USED="${10}"
NETDATA_DASHBOARD_USED="${11}"
NETDATA_COLLECTORS="${12}"
NETDATA_COLLECTORS_COUNT="${13}"
NETDATA_BUILDINFO="${14}"
NETDATA_CONFIG_PAGE_CACHE_SIZE="${15}"
NETDATA_CONFIG_MULTIDB_DISK_QUOTA="${16}"
NETDATA_CONFIG_HTTPS_ENABLED="${17}"
NETDATA_CONFIG_WEB_ENABLED="${18}"
NETDATA_CONFIG_RELEASE_CHANNEL="${19}"
NETDATA_MIRRORED_HOST_COUNT="${20}"
NETDATA_MIRRORED_HOSTS_REACHABLE="${21}"
NETDATA_MIRRORED_HOSTS_UNREACHABLE="${22}"
NETDATA_NOTIFICATION_METHODS="${23}"
NETDATA_ALARMS_NORMAL="${24}"
NETDATA_ALARMS_WARNING="${25}"
NETDATA_ALARMS_CRITICAL="${26}"
NETDATA_CHARTS_COUNT="${27}"
NETDATA_METRICS_COUNT="${28}"
NETDATA_CONFIG_IS_PARENT="${29}"
NETDATA_CONFIG_HOSTS_AVAILABLE="${30}"
NETDATA_HOST_CLOUD_AVAILABLE="${31}"
NETDATA_HOST_ACLK_AVAILABLE="${32}"
NETDATA_HOST_ACLK_PROTOCOL="${33}"
NETDATA_HOST_ACLK_IMPLEMENTATION="${34}"
NETDATA_HOST_AGENT_CLAIMED="${35}"
NETDATA_HOST_CLOUD_ENABLED="${36}"
NETDATA_CONFIG_HTTPS_AVAILABLE="${37}"
NETDATA_INSTALL_TYPE="${38}"
NETDATA_IS_PRIVATE_REGISTRY="${39}"
NETDATA_USE_PRIVATE_REGISTRY="${40}"
NETDATA_CONFIG_OOM_SCORE="${41}"
NETDATA_PREBUILT_DISTRO="${42}"

[ -z "$NETDATA_REGISTRY_UNIQUE_ID" ] && NETDATA_REGISTRY_UNIQUE_ID="00000000-0000-0000-0000-000000000000"

# define body of request to be sent
REQ_BODY="$(cat << EOF
{
    "event": "${ACTION} ${ACTION_RESULT}",
    "properties": {
        "distinct_id": "${NETDATA_REGISTRY_UNIQUE_ID}",
        "\$current_url": "agent backend",
        "\$pathname": "netdata-backend",
        "\$host": "backend.netdata.io",
        "\$ip": "127.0.0.1",
        "event_source": "agent backend",
        "action": "${ACTION}",
        "action_result": "${ACTION_RESULT}",
        "action_data": "${ACTION_DATA}",
        "netdata_machine_guid": "${NETDATA_REGISTRY_UNIQUE_ID}",
        "netdata_version": "${NETDATA_VERSION}",
        "netdata_buildinfo": ${NETDATA_BUILDINFO},
        "netdata_release_channel": ${NETDATA_CONFIG_RELEASE_CHANNEL},
        "netdata_install_type": ${NETDATA_INSTALL_TYPE},
        "netdata_prebuilt_distro": ${NETDATA_PREBUILT_DISTRO},
        "host_os_name": "${NETDATA_HOST_OS_NAME}",
        "host_os_id": "${NETDATA_HOST_OS_ID}",
        "host_os_id_like": "${NETDATA_HOST_OS_ID_LIKE}",
        "host_os_version": "${NETDATA_HOST_OS_VERSION}",
        "host_os_version_id": "${NETDATA_HOST_OS_VERSION_ID}",
        "host_os_detection": "${NETDATA_HOST_OS_DETECTION}",
        "host_is_k8s_node": "${NETDATA_HOST_IS_K8S_NODE}",
        "system_kernel_name": "${NETDATA_SYSTEM_KERNEL_NAME}",
        "system_kernel_version": "${NETDATA_SYSTEM_KERNEL_VERSION}",
        "system_architecture": "${NETDATA_SYSTEM_ARCHITECTURE}",
        "system_virtualization": "${NETDATA_SYSTEM_VIRTUALIZATION}",
        "system_virt_detection": "${NETDATA_SYSTEM_VIRT_DETECTION}",
        "system_container": "${NETDATA_SYSTEM_CONTAINER}",
        "system_container_detection": "${NETDATA_SYSTEM_CONTAINER_DETECTION}",
        "container_os_name": "${NETDATA_CONTAINER_OS_NAME}",
        "container_os_id": "${NETDATA_CONTAINER_OS_ID}",
        "container_os_id_like": "${NETDATA_CONTAINER_OS_ID_LIKE}",
        "container_os_version": "${NETDATA_CONTAINER_OS_VERSION}",
        "container_os_version_id": "${NETDATA_CONTAINER_OS_VERSION_ID}",
        "container_os_detection": "${NETDATA_CONTAINER_OS_DETECTION}",
        "container_is_official_image": ${NETDATA_CONTAINER_IS_OFFICIAL_IMAGE},
        "system_cpu_detection": "${NETDATA_SYSTEM_CPU_DETECTION}",
        "system_cpu_freq": "${NETDATA_SYSTEM_CPU_FREQ}",
        "system_cpu_logical_cpu_count": "${NETDATA_SYSTEM_CPU_LOGICAL_CPU_COUNT}",
        "system_cpu_model": "${NETDATA_SYSTEM_CPU_MODEL}",
        "system_cpu_vendor": "${NETDATA_SYSTEM_CPU_VENDOR}",
        "system_disk_detection": "${NETDATA_SYSTEM_DISK_DETECTION}",
        "system_ram_detection": "${NETDATA_SYSTEM_RAM_DETECTION}",
        "system_total_disk_size": "${NETDATA_SYSTEM_TOTAL_DISK_SIZE}",
        "system_total_ram": "${NETDATA_SYSTEM_TOTAL_RAM}",
        "config_stream_enabled": ${NETDATA_CONFIG_STREAM_ENABLED},
        "config_memory_mode": ${NETDATA_CONFIG_MEMORY_MODE},
        "config_page_cache_size": ${NETDATA_CONFIG_PAGE_CACHE_SIZE},
        "config_multidb_disk_quota": ${NETDATA_CONFIG_MULTIDB_DISK_QUOTA},
        "config_https_enabled": ${NETDATA_CONFIG_HTTPS_ENABLED},
        "config_https_available": ${NETDATA_CONFIG_HTTPS_AVAILABLE},
        "config_web_enabled": ${NETDATA_CONFIG_WEB_ENABLED},
        "config_exporting_enabled": ${NETDATA_CONFIG_EXPORTING_ENABLED},
        "config_is_parent": ${NETDATA_CONFIG_IS_PARENT},
        "config_is_private_registry": ${NETDATA_IS_PRIVATE_REGISTRY},
        "config_private_registry_used": ${NETDATA_USE_PRIVATE_REGISTRY},
        "config_hosts_available": ${NETDATA_CONFIG_HOSTS_AVAILABLE},
        "config_oom_score": ${NETDATA_CONFIG_OOM_SCORE},
        "alarms_normal": ${NETDATA_ALARMS_NORMAL},
        "alarms_warning": ${NETDATA_ALARMS_WARNING},
        "alarms_critical": ${NETDATA_ALARMS_CRITICAL},
        "host_charts_count": ${NETDATA_CHARTS_COUNT},
        "host_metrics_count": ${NETDATA_METRICS_COUNT},
        "host_collectors":[
            ${NETDATA_COLLECTORS}
        ],
        "host_collectors_count": ${NETDATA_COLLECTORS_COUNT},
        "host_notification_methods": ${NETDATA_NOTIFICATION_METHODS},
        "host_allmetrics_prometheus_used": ${NETDATA_ALLMETRICS_PROMETHEUS_USED},
        "host_allmetrics_shell_used": ${NETDATA_ALLMETRICS_SHELL_USED},
        "host_allmetrics_json_used": ${NETDATA_ALLMETRICS_JSON_USED},
        "host_dashboard_used": ${NETDATA_DASHBOARD_USED},
        "host_cloud_available": ${NETDATA_HOST_CLOUD_AVAILABLE},
        "host_cloud_enabled": ${NETDATA_HOST_CLOUD_ENABLED},
        "host_agent_claimed": ${NETDATA_HOST_AGENT_CLAIMED},
        "host_aclk_available": ${NETDATA_HOST_ACLK_AVAILABLE},
        "host_aclk_protocol": ${NETDATA_HOST_ACLK_PROTOCOL},
        "host_aclk_implementation": ${NETDATA_HOST_ACLK_IMPLEMENTATION},
        "mirrored_host_count": ${NETDATA_MIRRORED_HOST_COUNT},
        "mirrored_hosts_reachable": ${NETDATA_MIRRORED_HOSTS_REACHABLE},
        "mirrored_hosts_unreachable": ${NETDATA_MIRRORED_HOSTS_UNREACHABLE},
        "exporting_connectors": ${NETDATA_EXPORTING_CONNECTORS}
  }
}
EOF
)"

# send the anonymous statistics to Netdata
if [ -n "$(command -v curl 2> /dev/null)" ]; then
  curl --silent -o /dev/null --write-out '%{http_code}' -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" https://us-east1-netdata-analytics-bi.cloudfunctions.net/ingest_agent_events
else
  wget -q -O - --no-check-certificate \
  --server-response \
  --method POST \
  --timeout=1 \
  --header 'Content-Type: application/json' \
  --body-data "${REQ_BODY}" \
   'https://us-east1-netdata-analytics-bi.cloudfunctions.net/ingest_agent_events' 2>&1 | awk '/^  HTTP/{print $2}'
fi