summaryrefslogtreecommitdiffstats
path: root/daemon/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/main.c')
-rw-r--r--daemon/main.c14
1 files changed, 14 insertions, 0 deletions
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