309
310
void web_client_cache_destroy(void);
311
312
-void netdata_cleanup_and_exit(int ret) {
312
+void netdata_cleanup_and_exit(int ret, const char *action, const char *action_result, const char *action_data) {
313
usec_t started_ut = now_monotonic_usec();
314
usec_t last_ut = started_ut;
315
const char *prev_msg = NULL;
318
nd_log_limits_unlimited();
319
netdata_log_info("NETDATA SHUTDOWN: initializing shutdown with code %d...", ret);
320
321
- send_statistics("EXIT", ret?"ERROR":"OK","-");
321
+ // send the stat from our caller
322
+ analytics_statistic_t statistic = { action, action_result, action_data };
323
+ analytics_statistic_send(&statistic);
324
+
325
+ // notify we are exiting
326
+ statistic = (analytics_statistic_t) {"EXIT", ret?"ERROR":"OK","-"};
327
+ analytics_statistic_send(&statistic);
328
329
delta_shutdown_time("create shutdown file");
330
2211
netdata_log_info("NETDATA STARTUP: completed in %llu ms. Enjoy real-time performance monitoring!", (ready_ut - started_ut) / USEC_PER_MS);
2212
netdata_ready = true;
2213
2208
- send_statistics("START", "-", "-");
2209
- if (crash_detected)
2210
- send_statistics("CRASH", "-", "-");
2211
- if (incomplete_shutdown_detected)
2212
- send_statistics("INCOMPLETE_SHUTDOWN", "-", "-");
2214
+ analytics_statistic_t start_statistic = { "START", "-", "-" };
2215
+ analytics_statistic_send(&start_statistic);
2216
+ if (crash_detected) {
2217
+ analytics_statistic_t crash_statistic = { "CRASH", "-", "-" };
2218
+ analytics_statistic_send(&crash_statistic);
2219
+ }
2220
+ if (incomplete_shutdown_detected) {
2221
+ analytics_statistic_t incomplete_shutdown_statistic = { "INCOMPLETE_SHUTDOWN", "-", "-" };
2222
+ analytics_statistic_send(&incomplete_shutdown_statistic);
2223
+ }
2224
2225
//check if ANALYTICS needs to start
2226
if (netdata_anonymous_statistics_enabled == 1) {
2242
char filename[FILENAME_MAX + 1];
2243
snprintfz(filename, FILENAME_MAX, "%s/.aclk_report_sent", netdata_configured_varlib_dir);
2244
if (netdata_anonymous_statistics_enabled > 0 && access(filename, F_OK)) { // -1 -> not initialized
2234
- send_statistics("ACLK_DISABLED", "-", "-");
2245
+ analytics_statistic_t statistic = { "ACLK_DISABLED", "-", "-" };
2246
+ analytics_statistic_send(&statistic);
2247
+
2248
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 444);
2249
if (fd == -1)
2250
netdata_log_error("Cannot create file '%s'. Please fix this.", filename);