]> arthur.barton.de Git - netdata.git/commitdiff
create health directory for each host
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 21 Feb 2017 18:33:55 +0000 (20:33 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 21 Feb 2017 23:00:27 +0000 (01:00 +0200)
src/health.c
src/log.c
src/rrdhost.c

index 83390e95a6e7eb01203f920aa7f77f5833577623..494904c097434dbd821b55641e4c797b75402222 100644 (file)
@@ -26,11 +26,6 @@ void health_init(void) {
         config_set_boolean("health", "enabled", 0);
         default_health_enabled = 0;
     }
-
-    char pathname[FILENAME_MAX + 1];
-    snprintfz(pathname, FILENAME_MAX, "%s/health", netdata_configured_varlib_dir);
-    if(mkdir(pathname, 0770) == -1 && errno != EEXIST)
-        fatal("Cannot create directory '%s'.", pathname);
 }
 
 // ----------------------------------------------------------------------------
index 01beaf7ec4876e5ece8e343c79768b3c80530ac8..855ecaee6ee71920c132792823ee783a28b7f015 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -257,8 +257,8 @@ void info_int( const char *file, const char *function, const unsigned long line,
     log_date(stderr);
 
     va_start( args, fmt );
-    if(debug_flags) fprintf(stderr, "%s: INFO: (%04lu@%-10.10s:%-15.15s): ", program_name, line, file, function);
-    else            fprintf(stderr, "%s: INFO: ", program_name);
+    if(debug_flags) fprintf(stderr, "%s: INFO : (%04lu@%-10.10s:%-15.15s): ", program_name, line, file, function);
+    else            fprintf(stderr, "%s: INFO : ", program_name);
     vfprintf( stderr, fmt, args );
     va_end( args );
 
index 7fed5f617f7387e40983eb6d84bc94009d01fbcb..02ccf6bfe4ae6138ef866964cb56388c53d136b5 100644 (file)
@@ -60,7 +60,7 @@ RRDHOST *rrdhost_create(const char *hostname,
         RRD_MEMORY_MODE memory_mode,
         int health_enabled) {
 
-    debug(D_RRDHOST, "Adding host '%s' with guid '%s'", hostname, guid);
+    debug(D_RRDHOST, "Host '%s': adding with guid '%s'", hostname, guid);
 
     RRDHOST *host = callocz(1, sizeof(RRDHOST));
 
@@ -90,7 +90,7 @@ RRDHOST *rrdhost_create(const char *hostname,
 
     long n = config_get_number("health", "in memory max health log entries", host->health_log.max);
     if(n < 10) {
-        error("Health configuration has invalid max log entries %ld. Using default %u", n, host->health_log.max);
+        error("Host '%s': health configuration has invalid max log entries %ld. Using default %u", host->hostname, n, host->health_log.max);
         config_set_number("health", "in memory max health log entries", (long)host->health_log.max);
     }
     else
@@ -119,7 +119,7 @@ RRDHOST *rrdhost_create(const char *hostname,
         if(host->rrd_memory_mode == RRD_MEMORY_MODE_MAP || host->rrd_memory_mode == RRD_MEMORY_MODE_SAVE) {
             int r = mkdir(host->cache_dir, 0775);
             if(r != 0 && errno != EEXIST)
-                error("Cannot create directory '%s'", host->cache_dir);
+                error("Host '%s': cannot create directory '%s'", host->hostname, host->cache_dir);
         }
 
         snprintfz(filename, FILENAME_MAX, "%s/%s", netdata_configured_varlib_dir, host->machine_guid);
@@ -128,9 +128,14 @@ RRDHOST *rrdhost_create(const char *hostname,
         if(host->health_enabled) {
             int r = mkdir(host->varlib_dir, 0775);
             if(r != 0 && errno != EEXIST)
-                error("Cannot create directory '%s'", host->varlib_dir);
+                error("Host '%s': cannot create directory '%s'", host->hostname, host->varlib_dir);
         }
 
+        snprintfz(filename, FILENAME_MAX, "%s/health", host->varlib_dir);
+        int r = mkdir(filename, 0775);
+        if(r != 0 && errno != EEXIST)
+            error("Host '%s': cannot create directory '%s'", host->hostname, filename);
+
         snprintfz(filename, FILENAME_MAX, "%s/health/health-log.db", host->varlib_dir);
         host->health_log_filename = strdupz(filename);
 
@@ -163,11 +168,11 @@ RRDHOST *rrdhost_create(const char *hostname,
     }
 
     if(rrdhost_index_add(host) != host)
-        fatal("Cannot add host '%s' to index. It already exists.", hostname);
+        fatal("Host '%s': cannot add host to index. It already exists.", hostname);
 
     rrd_unlock();
 
-    debug(D_RRDHOST, "Added host '%s' with guid '%s'", host->hostname, host->machine_guid);
+    debug(D_RRDHOST, "Host '%s', added with guid '%s'", host->hostname, host->machine_guid);
     return host;
 }