From 105ad30a29266eafedd8ef79bc21218b92415907 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 12 Apr 2021 18:30:45 +0200 Subject: Merging upstream version 1.30.1. Signed-off-by: Daniel Baumann --- daemon/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'daemon') diff --git a/daemon/main.c b/daemon/main.c index 346486a84..93ec78b6a 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -29,6 +29,10 @@ void netdata_cleanup_and_exit(int ret) { send_statistics("EXIT", ret?"ERROR":"OK","-"); + char agent_crash_file[FILENAME_MAX + 1]; + snprintfz(agent_crash_file, FILENAME_MAX, "%s/.agent_crash", netdata_configured_varlib_dir); + (void) unlink(agent_crash_file); + // cleanup/save the database and exit info("EXIT: cleaning up the database..."); rrdhost_cleanup_all(); @@ -1456,6 +1460,14 @@ int main(int argc, char **argv) { if(rrd_init(netdata_configured_hostname, system_info)) fatal("Cannot initialize localhost instance with name '%s'.", netdata_configured_hostname); + char agent_crash_file[FILENAME_MAX + 1]; + snprintfz(agent_crash_file, FILENAME_MAX, "%s/.agent_crash", netdata_configured_varlib_dir); + int crash_detected = (unlink(agent_crash_file) == 0); + int fd = open(agent_crash_file, O_WRONLY | O_CREAT | O_TRUNC, 444); + if (fd >= 0) + close(fd); + + // ------------------------------------------------------------------------ // Claim netdata agent to a cloud endpoint @@ -1498,6 +1510,8 @@ int main(int argc, char **argv) { netdata_ready = 1; send_statistics("START", "-", "-"); + if (crash_detected) + send_statistics("CRASH", "-", "-"); // ------------------------------------------------------------------------ // Report ACLK build failure -- cgit v1.2.3