create health directory for each host
Costa Tsaousis (ktsaou) committed
Feb 21, 2017 at 20:33 UTC
16cb55cb76cb6ef4d8540b62fe51ae6d11f80795
3 files changed
+13
-13
src/health.c
-5
@@ -26,11 +26,6 @@ void health_init(void) {
26
config_set_boolean("health", "enabled", 0);
27
default_health_enabled = 0;
28
}
29
-
30
- char pathname[FILENAME_MAX + 1];
31
- snprintfz(pathname, FILENAME_MAX, "%s/health", netdata_configured_varlib_dir);
32
- if(mkdir(pathname, 0770) == -1 && errno != EEXIST)
33
- fatal("Cannot create directory '%s'.", pathname);
29
}
30
31
// ----------------------------------------------------------------------------
src/log.c
+2
-2
@@ -257,8 +257,8 @@ void info_int( const char *file, const char *function, const unsigned long line,
257
log_date(stderr);
258
259
va_start( args, fmt );
260
- if(debug_flags) fprintf(stderr, "%s: INFO: (%04lu@%-10.10s:%-15.15s): ", program_name, line, file, function);
261
- else fprintf(stderr, "%s: INFO: ", program_name);
260
+ if(debug_flags) fprintf(stderr, "%s: INFO : (%04lu@%-10.10s:%-15.15s): ", program_name, line, file, function);
261
+ else fprintf(stderr, "%s: INFO : ", program_name);
262
vfprintf( stderr, fmt, args );
263
va_end( args );
264
src/rrdhost.c
+11
-6
@@ -60,7 +60,7 @@ RRDHOST *rrdhost_create(const char *hostname,
60
RRD_MEMORY_MODE memory_mode,
61
int health_enabled) {
62
63
- debug(D_RRDHOST, "Adding host '%s' with guid '%s'", hostname, guid);
63
+ debug(D_RRDHOST, "Host '%s': adding with guid '%s'", hostname, guid);
64
65
RRDHOST *host = callocz(1, sizeof(RRDHOST));
66
@@ -90,7 +90,7 @@ RRDHOST *rrdhost_create(const char *hostname,
90
91
long n = config_get_number("health", "in memory max health log entries", host->health_log.max);
92
if(n < 10) {
93
- error("Health configuration has invalid max log entries %ld. Using default %u", n, host->health_log.max);
93
+ error("Host '%s': health configuration has invalid max log entries %ld. Using default %u", host->hostname, n, host->health_log.max);
94
config_set_number("health", "in memory max health log entries", (long)host->health_log.max);
95
}
96
else
@@ -119,7 +119,7 @@ RRDHOST *rrdhost_create(const char *hostname,
119
if(host->rrd_memory_mode == RRD_MEMORY_MODE_MAP || host->rrd_memory_mode == RRD_MEMORY_MODE_SAVE) {
120
int r = mkdir(host->cache_dir, 0775);
121
if(r != 0 && errno != EEXIST)
122
- error("Cannot create directory '%s'", host->cache_dir);
122
+ error("Host '%s': cannot create directory '%s'", host->hostname, host->cache_dir);
123
}
124
125
snprintfz(filename, FILENAME_MAX, "%s/%s", netdata_configured_varlib_dir, host->machine_guid);
@@ -128,9 +128,14 @@ RRDHOST *rrdhost_create(const char *hostname,
128
if(host->health_enabled) {
129
int r = mkdir(host->varlib_dir, 0775);
130
if(r != 0 && errno != EEXIST)
131
- error("Cannot create directory '%s'", host->varlib_dir);
131
+ error("Host '%s': cannot create directory '%s'", host->hostname, host->varlib_dir);
132
}
133
134
+ snprintfz(filename, FILENAME_MAX, "%s/health", host->varlib_dir);
135
+ int r = mkdir(filename, 0775);
136
+ if(r != 0 && errno != EEXIST)
137
+ error("Host '%s': cannot create directory '%s'", host->hostname, filename);
138
+
139
snprintfz(filename, FILENAME_MAX, "%s/health/health-log.db", host->varlib_dir);
140
host->health_log_filename = strdupz(filename);
141
@@ -163,11 +168,11 @@ RRDHOST *rrdhost_create(const char *hostname,
168
}
169
170
if(rrdhost_index_add(host) != host)
166
- fatal("Cannot add host '%s' to index. It already exists.", hostname);
171
+ fatal("Host '%s': cannot add host to index. It already exists.", hostname);
172
173
rrd_unlock();
174
170
- debug(D_RRDHOST, "Added host '%s' with guid '%s'", host->hostname, host->machine_guid);
175
+ debug(D_RRDHOST, "Host '%s', added with guid '%s'", host->hostname, host->machine_guid);
176
return host;
177
}
178