]> arthur.barton.de Git - netdata.git/commitdiff
properly rotate the health log file
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 16 Oct 2016 16:43:40 +0000 (19:43 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 16 Oct 2016 16:43:40 +0000 (19:43 +0300)
src/health.c

index 2309e26c26a9855dbb96fdce4e8e4d68b297e05e..0097d9dfa246b21a9d9a5e7139673aa86920a60f 100644 (file)
@@ -67,15 +67,8 @@ static inline void health_log_rotate(void) {
         if(link(health.log_filename, old_filename) == -1 && errno != ENOENT)
             error("Health: cannot move file '%s' to '%s'.", health.log_filename, old_filename);
 
-        // open it with truncate
-        health.log_fp = fopen(health.log_filename, "w");
-
-        if(health.log_fp)
-            fclose(health.log_fp);
-        else
-            error("Health: cannot truncate health log '%s'", health.log_filename);
-
-        health.log_fp = NULL;
+        if(unlink(health.log_filename) == -1 && errno != ENOENT)
+            error("Health: cannot remove old alarms log file '%s'", health.log_filename);
 
         health_alarm_log_open();
     }