Fix time_t format (#11897)
Vladimir Kobal committed
Jan 11, 2022 at 13:12 UTC
4919103c4b715a83ebcc677431dab6ecbacabc9c
12 files changed
+498
-436
collectors/proc.plugin/sys_class_infiniband.c
+5
-2
@@ -481,8 +481,11 @@ int do_sys_class_infiniband(int update_every, usec_t dt)
481
482
if (!p->discovered)
483
info(
484
- "Infiniband card %s port %s at speed %lu width %lu", dev_dent->d_name, port_dent->d_name,
485
- p->speed, p->width);
484
+ "Infiniband card %s port %s at speed %" PRIu64 " width %" PRIu64 "",
485
+ dev_dent->d_name,
486
+ port_dent->d_name,
487
+ p->speed,
488
+ p->width);
489
490
p->discovered = 1;
491
}
daemon/unit_test.c
+4
-4
@@ -1181,9 +1181,9 @@ int run_test(struct test *test)
1181
calculated_number v = unpack_storage_number(rd->values[c]);
1182
calculated_number n = unpack_storage_number(pack_storage_number(test->results[c], SN_DEFAULT_FLAGS));
1183
int same = (calculated_number_round(v * 10000000.0) == calculated_number_round(n * 10000000.0))?1:0;
1184
- fprintf(stderr, " %s/%s: checking position %lu (at %lu secs), expecting value " CALCULATED_NUMBER_FORMAT ", found " CALCULATED_NUMBER_FORMAT ", %s\n",
1184
+ fprintf(stderr, " %s/%s: checking position %lu (at %"PRId64" secs), expecting value " CALCULATED_NUMBER_FORMAT ", found " CALCULATED_NUMBER_FORMAT ", %s\n",
1185
test->name, rd->name, c+1,
1186
- (rrdset_first_entry_t(st) + c * st->update_every) - time_start,
1186
+ (int64_t)((rrdset_first_entry_t(st) + c * st->update_every) - time_start),
1187
n, v, (same)?"OK":"### E R R O R ###");
1188
1189
if(!same) errors++;
@@ -1192,9 +1192,9 @@ int run_test(struct test *test)
1192
v = unpack_storage_number(rd2->values[c]);
1193
n = test->results2[c];
1194
same = (calculated_number_round(v * 10000000.0) == calculated_number_round(n * 10000000.0))?1:0;
1195
- fprintf(stderr, " %s/%s: checking position %lu (at %lu secs), expecting value " CALCULATED_NUMBER_FORMAT ", found " CALCULATED_NUMBER_FORMAT ", %s\n",
1195
+ fprintf(stderr, " %s/%s: checking position %lu (at %"PRId64" secs), expecting value " CALCULATED_NUMBER_FORMAT ", found " CALCULATED_NUMBER_FORMAT ", %s\n",
1196
test->name, rd2->name, c+1,
1197
- (rrdset_first_entry_t(st) + c * st->update_every) - time_start,
1197
+ (int64_t)((rrdset_first_entry_t(st) + c * st->update_every) - time_start),
1198
n, v, (same)?"OK":"### E R R O R ###");
1199
if(!same) errors++;
1200
}
database/rrdset.c
+8
-1
@@ -1453,7 +1453,14 @@ void rrdset_done(RRDSET *st) {
1453
// check if we will re-write the entire data set
1454
if(unlikely(dt_usec(&st->last_collected_time, &st->last_updated) > st->entries * update_every_ut &&
1455
st->rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE)) {
1456
- info("%s: too old data (last updated at %ld.%ld, last collected at %ld.%ld). Resetting it. Will not store the next entry.", st->name, st->last_updated.tv_sec, st->last_updated.tv_usec, st->last_collected_time.tv_sec, st->last_collected_time.tv_usec);
1456
+ info(
1457
+ "%s: too old data (last updated at %"PRId64".%"PRId64", last collected at %"PRId64".%"PRId64"). "
1458
+ "Resetting it. Will not store the next entry.",
1459
+ st->name,
1460
+ (int64_t)st->last_updated.tv_sec,
1461
+ (int64_t)st->last_updated.tv_usec,
1462
+ (int64_t)st->last_collected_time.tv_sec,
1463
+ (int64_t)st->last_collected_time.tv_usec);
1464
rrdset_reset(st);
1465
rrdset_init_last_updated_time(st);
1466
health/health.c
+15
-9
@@ -101,7 +101,11 @@ static void health_silencers_init(void) {
101
freez(str);
102
}
103
} else {
104
- error("Health silencers file %s has the size %ld that is out of range[ 1 , %d ]. Aborting read.", silencers_filename, length, HEALTH_SILENCERS_MAX_FILE_LEN);
104
+ error(
105
+ "Health silencers file %s has the size %" PRId64 " that is out of range[ 1 , %d ]. Aborting read.",
106
+ silencers_filename,
107
+ (int64_t)length,
108
+ HEALTH_SILENCERS_MAX_FILE_LEN);
109
}
110
fclose(fd);
111
} else {
@@ -326,7 +330,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
330
buffer_strcat(warn_alarms, ",");
331
buffer_strcat(warn_alarms, rc->name);
332
buffer_strcat(warn_alarms, "=");
329
- buffer_snprintf(warn_alarms, 11, "%ld", rc->last_status_change);
333
+ buffer_snprintf(warn_alarms, 11, "%"PRId64"", (int64_t)rc->last_status_change);
334
n_warn++;
335
} else if (ae->alarm_id == rc->id)
336
expr = rc->warning;
@@ -336,7 +340,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
340
buffer_strcat(crit_alarms, ",");
341
buffer_strcat(crit_alarms, rc->name);
342
buffer_strcat(crit_alarms, "=");
339
- buffer_snprintf(crit_alarms, 11, "%ld", rc->last_status_change);
343
+ buffer_snprintf(crit_alarms, 11, "%"PRId64"", (int64_t)rc->last_status_change);
344
n_crit++;
345
} else if (ae->alarm_id == rc->id)
346
expr = rc->critical;
@@ -684,9 +688,10 @@ void *health_main(void *ptr) {
688
if (unlikely(check_if_resumed_from_suspension())) {
689
apply_hibernation_delay = 1;
690
687
- info("Postponing alarm checks for %ld seconds, because it seems that the system was just resumed from suspension.",
688
- hibernation_delay
689
- );
691
+ info(
692
+ "Postponing alarm checks for %"PRId64" seconds, "
693
+ "because it seems that the system was just resumed from suspension.",
694
+ (int64_t)hibernation_delay);
695
}
696
697
if (unlikely(silencers->all_alarms && silencers->stype == STYPE_DISABLE_ALARMS)) {
@@ -706,9 +711,10 @@ void *health_main(void *ptr) {
711
continue;
712
713
if (unlikely(apply_hibernation_delay)) {
709
-
710
- info("Postponing health checks for %ld seconds, on host '%s'.", hibernation_delay, host->hostname
711
- );
714
+ info(
715
+ "Postponing health checks for %"PRId64" seconds, on host '%s'.",
716
+ (int64_t)hibernation_delay,
717
+ host->hostname);
718
719
host->health_delay_up_to = now + hibernation_delay;
720
}
health/health_log.c
+1
-1
@@ -112,7 +112,7 @@ inline void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae) {
112
"\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s"
113
"\t%d\t%d\t%d\t%d"
114
"\t" CALCULATED_NUMBER_FORMAT_AUTO "\t" CALCULATED_NUMBER_FORMAT_AUTO
115
- "\t%016lx"
115
+ "\t%016"PRIx64""
116
"\t%s\t%s\t%s"
117
"\n"
118
, (ae->flags & HEALTH_ENTRY_FLAG_SAVED)?'U':'A'
libnetdata/log/log.c
+342
-335
@@ -24,10 +24,10 @@ const char *facility_log = NULL;
24
// Log facility(https://tools.ietf.org/html/rfc5424)
25
//
26
// The facilities accepted in the Netdata are in according with the following
27
-// header files for their respective operate system:
28
-// sys/syslog.h (Linux )
29
-// sys/sys/syslog.h (FreeBSD)
30
-// bsd/sys/syslog.h (darwin-xnu)
27
+// header files for their respective operating system:
28
+// sys/syslog.h (Linux )
29
+// sys/sys/syslog.h (FreeBSD)
30
+// bsd/sys/syslog.h (darwin-xnu)
31
32
#define LOG_AUTH_KEY "auth"
33
#define LOG_AUTHPRIV_KEY "authpriv"
@@ -71,229 +71,229 @@ const char *facility_log = NULL;
71
72
static int log_facility_id(const char *facility_name)
73
{
74
- static int
75
- hash_auth = 0,
76
- hash_authpriv = 0,
74
+ static int
75
+ hash_auth = 0,
76
+ hash_authpriv = 0,
77
#ifdef __FreeBSD__
78
- hash_console = 0,
78
+ hash_console = 0,
79
#endif
80
- hash_cron = 0,
81
- hash_daemon = 0,
82
- hash_ftp = 0,
80
+ hash_cron = 0,
81
+ hash_daemon = 0,
82
+ hash_ftp = 0,
83
#ifdef __APPLE__
84
- hash_install = 0,
84
+ hash_install = 0,
85
#endif
86
- hash_kern = 0,
87
- hash_lpr = 0,
88
- hash_mail = 0,
89
-// hash_mark = 0,
86
+ hash_kern = 0,
87
+ hash_lpr = 0,
88
+ hash_mail = 0,
89
+// hash_mark = 0,
90
#ifdef __APPLE__
91
- hash_netinfo = 0,
92
- hash_ras = 0,
93
- hash_remoteauth = 0,
91
+ hash_netinfo = 0,
92
+ hash_ras = 0,
93
+ hash_remoteauth = 0,
94
#endif
95
- hash_news = 0,
95
+ hash_news = 0,
96
#ifdef __FreeBSD__
97
- hash_ntp = 0,
97
+ hash_ntp = 0,
98
#endif
99
- hash_security = 0,
100
- hash_syslog = 0,
101
- hash_user = 0,
102
- hash_uucp = 0,
99
+ hash_security = 0,
100
+ hash_syslog = 0,
101
+ hash_user = 0,
102
+ hash_uucp = 0,
103
#ifdef __APPLE__
104
- hash_launchd = 0,
104
+ hash_launchd = 0,
105
#endif
106
- hash_local0 = 0,
107
- hash_local1 = 0,
108
- hash_local2 = 0,
109
- hash_local3 = 0,
110
- hash_local4 = 0,
111
- hash_local5 = 0,
112
- hash_local6 = 0,
113
- hash_local7 = 0;
114
-
115
- if(unlikely(!hash_auth))
116
- {
117
- hash_auth = simple_hash(LOG_AUTH_KEY);
118
- hash_authpriv = simple_hash(LOG_AUTHPRIV_KEY);
106
+ hash_local0 = 0,
107
+ hash_local1 = 0,
108
+ hash_local2 = 0,
109
+ hash_local3 = 0,
110
+ hash_local4 = 0,
111
+ hash_local5 = 0,
112
+ hash_local6 = 0,
113
+ hash_local7 = 0;
114
+
115
+ if(unlikely(!hash_auth))
116
+ {
117
+ hash_auth = simple_hash(LOG_AUTH_KEY);
118
+ hash_authpriv = simple_hash(LOG_AUTHPRIV_KEY);
119
#ifdef __FreeBSD__
120
- hash_console = simple_hash(LOG_CONSOLE_KEY);
120
+ hash_console = simple_hash(LOG_CONSOLE_KEY);
121
#endif
122
- hash_cron = simple_hash(LOG_CRON_KEY);
123
- hash_daemon = simple_hash(LOG_DAEMON_KEY);
124
- hash_ftp = simple_hash(LOG_FTP_KEY);
122
+ hash_cron = simple_hash(LOG_CRON_KEY);
123
+ hash_daemon = simple_hash(LOG_DAEMON_KEY);
124
+ hash_ftp = simple_hash(LOG_FTP_KEY);
125
#ifdef __APPLE__
126
- hash_install = simple_hash(LOG_INSTALL_KEY);
126
+ hash_install = simple_hash(LOG_INSTALL_KEY);
127
#endif
128
- hash_kern = simple_hash(LOG_KERN_KEY);
129
- hash_lpr = simple_hash(LOG_LPR_KEY);
130
- hash_mail = simple_hash(LOG_MAIL_KEY);
131
-// hash_mark = simple_uhash();
128
+ hash_kern = simple_hash(LOG_KERN_KEY);
129
+ hash_lpr = simple_hash(LOG_LPR_KEY);
130
+ hash_mail = simple_hash(LOG_MAIL_KEY);
131
+// hash_mark = simple_uhash();
132
#ifdef __APPLE__
133
- hash_netinfo = simple_hash(LOG_NETINFO_KEY);
134
- hash_ras = simple_hash(LOG_RAS_KEY);
135
- hash_remoteauth = simple_hash(LOG_REMOTEAUTH_KEY);
133
+ hash_netinfo = simple_hash(LOG_NETINFO_KEY);
134
+ hash_ras = simple_hash(LOG_RAS_KEY);
135
+ hash_remoteauth = simple_hash(LOG_REMOTEAUTH_KEY);
136
#endif
137
- hash_news = simple_hash(LOG_NEWS_KEY);
137
+ hash_news = simple_hash(LOG_NEWS_KEY);
138
#ifdef __FreeBSD__
139
- hash_ntp = simple_hash(LOG_NTP_KEY);
139
+ hash_ntp = simple_hash(LOG_NTP_KEY);
140
#endif
141
- hash_security = simple_hash(LOG_SECURITY_KEY);
142
- hash_syslog = simple_hash(LOG_SYSLOG_KEY);
143
- hash_user = simple_hash(LOG_USER_KEY);
144
- hash_uucp = simple_hash(LOG_UUCP_KEY);
141
+ hash_security = simple_hash(LOG_SECURITY_KEY);
142
+ hash_syslog = simple_hash(LOG_SYSLOG_KEY);
143
+ hash_user = simple_hash(LOG_USER_KEY);
144
+ hash_uucp = simple_hash(LOG_UUCP_KEY);
145
#ifdef __APPLE__
146
- hash_launchd = simple_hash(LOG_LAUNCHD_KEY);
146
+ hash_launchd = simple_hash(LOG_LAUNCHD_KEY);
147
#endif
148
- hash_local0 = simple_hash(LOG_LOCAL0_KEY);
149
- hash_local1 = simple_hash(LOG_LOCAL1_KEY);
150
- hash_local2 = simple_hash(LOG_LOCAL2_KEY);
151
- hash_local3 = simple_hash(LOG_LOCAL3_KEY);
152
- hash_local4 = simple_hash(LOG_LOCAL4_KEY);
153
- hash_local5 = simple_hash(LOG_LOCAL5_KEY);
154
- hash_local6 = simple_hash(LOG_LOCAL6_KEY);
155
- hash_local7 = simple_hash(LOG_LOCAL7_KEY);
156
- }
157
-
158
- int hash = simple_hash(facility_name);
159
- if ( hash == hash_auth )
160
- {
161
- return LOG_AUTH;
162
- }
163
- else if ( hash == hash_authpriv )
164
- {
165
- return LOG_AUTHPRIV;
166
- }
148
+ hash_local0 = simple_hash(LOG_LOCAL0_KEY);
149
+ hash_local1 = simple_hash(LOG_LOCAL1_KEY);
150
+ hash_local2 = simple_hash(LOG_LOCAL2_KEY);
151
+ hash_local3 = simple_hash(LOG_LOCAL3_KEY);
152
+ hash_local4 = simple_hash(LOG_LOCAL4_KEY);
153
+ hash_local5 = simple_hash(LOG_LOCAL5_KEY);
154
+ hash_local6 = simple_hash(LOG_LOCAL6_KEY);
155
+ hash_local7 = simple_hash(LOG_LOCAL7_KEY);
156
+ }
157
+
158
+ int hash = simple_hash(facility_name);
159
+ if ( hash == hash_auth )
160
+ {
161
+ return LOG_AUTH;
162
+ }
163
+ else if ( hash == hash_authpriv )
164
+ {
165
+ return LOG_AUTHPRIV;
166
+ }
167
#ifdef __FreeBSD__
168
- else if ( hash == hash_console )
169
- {
170
- return LOG_CONSOLE;
171
- }
168
+ else if ( hash == hash_console )
169
+ {
170
+ return LOG_CONSOLE;
171
+ }
172
#endif
173
- else if ( hash == hash_cron )
174
- {
175
- return LOG_CRON;
176
- }
177
- else if ( hash == hash_daemon )
178
- {
179
- return LOG_DAEMON;
180
- }
181
- else if ( hash == hash_ftp )
182
- {
183
- return LOG_FTP;
184
- }
173
+ else if ( hash == hash_cron )
174
+ {
175
+ return LOG_CRON;
176
+ }
177
+ else if ( hash == hash_daemon )
178
+ {
179
+ return LOG_DAEMON;
180
+ }
181
+ else if ( hash == hash_ftp )
182
+ {
183
+ return LOG_FTP;
184
+ }
185
#ifdef __APPLE__
186
- else if ( hash == hash_install )
187
- {
188
- return LOG_INSTALL;
189
- }
186
+ else if ( hash == hash_install )
187
+ {
188
+ return LOG_INSTALL;
189
+ }
190
#endif
191
- else if ( hash == hash_kern )
192
- {
193
- return LOG_KERN;
194
- }
195
- else if ( hash == hash_lpr )
196
- {
197
- return LOG_LPR;
198
- }
199
- else if ( hash == hash_mail )
200
- {
201
- return LOG_MAIL;
202
- }
203
- /*
204
- else if ( hash == hash_mark )
205
- {
206
- //this is internal for all OS
207
- return INTERNAL_MARK;
208
- }
209
- */
191
+ else if ( hash == hash_kern )
192
+ {
193
+ return LOG_KERN;
194
+ }
195
+ else if ( hash == hash_lpr )
196
+ {
197
+ return LOG_LPR;
198
+ }
199
+ else if ( hash == hash_mail )
200
+ {
201
+ return LOG_MAIL;
202
+ }
203
+ /*
204
+ else if ( hash == hash_mark )
205
+ {
206
+ //this is internal for all OS
207
+ return INTERNAL_MARK;
208
+ }
209
+ */
210
#ifdef __APPLE__
211
- else if ( hash == hash_netinfo )
212
- {
213
- return LOG_NETINFO;
214
- }
215
- else if ( hash == hash_ras )
216
- {
217
- return LOG_RAS;
218
- }
219
- else if ( hash == hash_remoteauth )
220
- {
221
- return LOG_REMOTEAUTH;
222
- }
211
+ else if ( hash == hash_netinfo )
212
+ {
213
+ return LOG_NETINFO;
214
+ }
215
+ else if ( hash == hash_ras )
216
+ {
217
+ return LOG_RAS;
218
+ }
219
+ else if ( hash == hash_remoteauth )
220
+ {
221
+ return LOG_REMOTEAUTH;
222
+ }
223
#endif
224
- else if ( hash == hash_news )
225
- {
226
- return LOG_NEWS;
227
- }
224
+ else if ( hash == hash_news )
225
+ {
226
+ return LOG_NEWS;
227
+ }
228
#ifdef __FreeBSD__
229
- else if ( hash == hash_ntp )
230
- {
231
- return LOG_NTP;
232
- }
229
+ else if ( hash == hash_ntp )
230
+ {
231
+ return LOG_NTP;
232
+ }
233
#endif
234
- else if ( hash == hash_security )
235
- {
236
- //FreeBSD is the unique that does not consider
237
- //this facility deprecated. We are keeping
238
- //it for other OS while they are kept in their headers.
234
+ else if ( hash == hash_security )
235
+ {
236
+ //FreeBSD is the unique that does not consider
237
+ //this facility deprecated. We are keeping
238
+ //it for other OS while they are kept in their headers.
239
#ifdef __FreeBSD__
240
- return LOG_SECURITY;
240
+ return LOG_SECURITY;
241
#else
242
- return LOG_AUTH;
242
+ return LOG_AUTH;
243
#endif
244
- }
245
- else if ( hash == hash_syslog )
246
- {
247
- return LOG_SYSLOG;
248
- }
249
- else if ( hash == hash_user )
250
- {
251
- return LOG_USER;
252
- }
253
- else if ( hash == hash_uucp )
254
- {
255
- return LOG_UUCP;
256
- }
257
- else if ( hash == hash_local0 )
258
- {
259
- return LOG_LOCAL0;
260
- }
261
- else if ( hash == hash_local1 )
262
- {
263
- return LOG_LOCAL1;
264
- }
265
- else if ( hash == hash_local2 )
266
- {
267
- return LOG_LOCAL2;
268
- }
269
- else if ( hash == hash_local3 )
270
- {
271
- return LOG_LOCAL3;
272
- }
273
- else if ( hash == hash_local4 )
274
- {
275
- return LOG_LOCAL4;
276
- }
277
- else if ( hash == hash_local5 )
278
- {
279
- return LOG_LOCAL5;
280
- }
281
- else if ( hash == hash_local6 )
282
- {
283
- return LOG_LOCAL6;
284
- }
285
- else if ( hash == hash_local7 )
286
- {
287
- return LOG_LOCAL7;
288
- }
244
+ }
245
+ else if ( hash == hash_syslog )
246
+ {
247
+ return LOG_SYSLOG;
248
+ }
249
+ else if ( hash == hash_user )
250
+ {
251
+ return LOG_USER;
252
+ }
253
+ else if ( hash == hash_uucp )
254
+ {
255
+ return LOG_UUCP;
256
+ }
257
+ else if ( hash == hash_local0 )
258
+ {
259
+ return LOG_LOCAL0;
260
+ }
261
+ else if ( hash == hash_local1 )
262
+ {
263
+ return LOG_LOCAL1;
264
+ }
265
+ else if ( hash == hash_local2 )
266
+ {
267
+ return LOG_LOCAL2;
268
+ }
269
+ else if ( hash == hash_local3 )
270
+ {
271
+ return LOG_LOCAL3;
272
+ }
273
+ else if ( hash == hash_local4 )
274
+ {
275
+ return LOG_LOCAL4;
276
+ }
277
+ else if ( hash == hash_local5 )
278
+ {
279
+ return LOG_LOCAL5;
280
+ }
281
+ else if ( hash == hash_local6 )
282
+ {
283
+ return LOG_LOCAL6;
284
+ }
285
+ else if ( hash == hash_local7 )
286
+ {
287
+ return LOG_LOCAL7;
288
+ }
289
#ifdef __APPLE__
290
- else if ( hash == hash_launchd )
291
- {
292
- return LOG_LAUNCHD;
293
- }
290
+ else if ( hash == hash_launchd )
291
+ {
292
+ return LOG_LAUNCHD;
293
+ }
294
#endif
295
296
- return LOG_DAEMON;
296
+ return LOG_DAEMON;
297
}
298
299
//we do not need to use this now, but I already created this function to be
@@ -301,135 +301,135 @@ static int log_facility_id(const char *facility_name)
301
/*
302
char *log_facility_name(int code)
303
{
304
- char *defvalue = { "daemon" };
305
- switch(code)
306
- {
307
- case LOG_AUTH:
308
- {
309
- return "auth";
310
- }
311
- case LOG_AUTHPRIV:
312
- {
313
- return "authpriv";
314
- }
304
+ char *defvalue = { "daemon" };
305
+ switch(code)
306
+ {
307
+ case LOG_AUTH:
308
+ {
309
+ return "auth";
310
+ }
311
+ case LOG_AUTHPRIV:
312
+ {
313
+ return "authpriv";
314
+ }
315
#ifdef __FreeBSD__
316
- case LOG_CONSOLE:
317
- {
318
- return "console";
319
- }
316
+ case LOG_CONSOLE:
317
+ {
318
+ return "console";
319
+ }
320
#endif
321
- case LOG_CRON:
322
- {
323
- return "cron";
324
- }
325
- case LOG_DAEMON:
326
- {
327
- return defvalue;
328
- }
329
- case LOG_FTP:
330
- {
331
- return "ftp";
332
- }
321
+ case LOG_CRON:
322
+ {
323
+ return "cron";
324
+ }
325
+ case LOG_DAEMON:
326
+ {
327
+ return defvalue;
328
+ }
329
+ case LOG_FTP:
330
+ {
331
+ return "ftp";
332
+ }
333
#ifdef __APPLE__
334
- case LOG_INSTALL:
335
- {
336
- return "install";
337
- }
334
+ case LOG_INSTALL:
335
+ {
336
+ return "install";
337
+ }
338
#endif
339
- case LOG_KERN:
340
- {
341
- return "kern";
342
- }
343
- case LOG_LPR:
344
- {
345
- return "lpr";
346
- }
347
- case LOG_MAIL:
348
- {
349
- return "mail";
350
- }
339
+ case LOG_KERN:
340
+ {
341
+ return "kern";
342
+ }
343
+ case LOG_LPR:
344
+ {
345
+ return "lpr";
346
+ }
347
+ case LOG_MAIL:
348
+ {
349
+ return "mail";
350
+ }
351
#ifdef __APPLE__
352
- case LOG_NETINFO:
353
- {
354
- return "netinfo" ;
355
- }
356
- case LOG_RAS:
357
- {
358
- return "ras";
359
- }
360
- case LOG_REMOTEAUTH:
361
- {
362
- return "remoteauth";
363
- }
352
+ case LOG_NETINFO:
353
+ {
354
+ return "netinfo" ;
355
+ }
356
+ case LOG_RAS:
357
+ {
358
+ return "ras";
359
+ }
360
+ case LOG_REMOTEAUTH:
361
+ {
362
+ return "remoteauth";
363
+ }
364
#endif
365
- case LOG_NEWS:
366
- {
367
- return "news";
368
- }
365
+ case LOG_NEWS:
366
+ {
367
+ return "news";
368
+ }
369
#ifdef __FreeBSD__
370
- case LOG_NTP:
371
- {
372
- return "ntp" ;
373
- }
374
- case LOG_SECURITY:
375
- {
376
- return "security";
377
- }
370
+ case LOG_NTP:
371
+ {
372
+ return "ntp" ;
373
+ }
374
+ case LOG_SECURITY:
375
+ {
376
+ return "security";
377
+ }
378
#endif
379
- case LOG_SYSLOG:
380
- {
381
- return "syslog";
382
- }
383
- case LOG_USER:
384
- {
385
- return "user";
386
- }
387
- case LOG_UUCP:
388
- {
389
- return "uucp";
390
- }
391
- case LOG_LOCAL0:
392
- {
393
- return "local0";
394
- }
395
- case LOG_LOCAL1:
396
- {
397
- return "local1";
398
- }
399
- case LOG_LOCAL2:
400
- {
401
- return "local2";
402
- }
403
- case LOG_LOCAL3:
404
- {
405
- return "local3";
406
- }
407
- case LOG_LOCAL4:
408
- {
409
- return "local4" ;
410
- }
411
- case LOG_LOCAL5:
412
- {
413
- return "local5";
414
- }
415
- case LOG_LOCAL6:
416
- {
417
- return "local6";
418
- }
419
- case LOG_LOCAL7:
420
- {
421
- return "local7" ;
422
- }
379
+ case LOG_SYSLOG:
380
+ {
381
+ return "syslog";
382
+ }
383
+ case LOG_USER:
384
+ {
385
+ return "user";
386
+ }
387
+ case LOG_UUCP:
388
+ {
389
+ return "uucp";
390
+ }
391
+ case LOG_LOCAL0:
392
+ {
393
+ return "local0";
394
+ }
395
+ case LOG_LOCAL1:
396
+ {
397
+ return "local1";
398
+ }
399
+ case LOG_LOCAL2:
400
+ {
401
+ return "local2";
402
+ }
403
+ case LOG_LOCAL3:
404
+ {
405
+ return "local3";
406
+ }
407
+ case LOG_LOCAL4:
408
+ {
409
+ return "local4" ;
410
+ }
411
+ case LOG_LOCAL5:
412
+ {
413
+ return "local5";
414
+ }
415
+ case LOG_LOCAL6:
416
+ {
417
+ return "local6";
418
+ }
419
+ case LOG_LOCAL7:
420
+ {
421
+ return "local7" ;
422
+ }
423
#ifdef __APPLE__
424
- case LOG_LAUNCHD:
425
- {
426
- return "launchd";
427
- }
424
+ case LOG_LAUNCHD:
425
+ {
426
+ return "launchd";
427
+ }
428
#endif
429
- }
429
+ }
430
431
- return defvalue;
432
-}
431
+ return defvalue;
432
+}
433
*/
434
435
// ----------------------------------------------------------------------------
@@ -486,7 +486,7 @@ static FILE *open_log_file(int fd, FILE *fp, const char *filename, int *enabled_
486
filename = "/dev/null";
487
devnull = 1;
488
489
- syslog_init();
489
+ syslog_init();
490
if(enabled_syslog) *enabled_syslog = 1;
491
}
492
else if(enabled_syslog) *enabled_syslog = 0;
@@ -607,13 +607,15 @@ int error_log_limit(int reset) {
607
if(prevented) {
608
char date[LOG_DATE_LENGTH];
609
log_date(date, LOG_DATE_LENGTH);
610
- fprintf(stderr, "%s: %s LOG FLOOD PROTECTION reset for process '%s' (prevented %lu logs in the last %ld seconds).\n"
611
- , date
612
- , program_name
613
- , program_name
614
- , prevented
615
- , now - start
616
- );
610
+ fprintf(
611
+ stderr,
612
+ "%s: %s LOG FLOOD PROTECTION reset for process '%s' "
613
+ "(prevented %lu logs in the last %"PRId64" seconds).\n",
614
+ date,
615
+ program_name,
616
+ program_name,
617
+ prevented,
618
+ (int64_t)(now - start));
619
}
620
621
start = now;
@@ -628,13 +630,15 @@ int error_log_limit(int reset) {
630
if(prevented) {
631
char date[LOG_DATE_LENGTH];
632
log_date(date, LOG_DATE_LENGTH);
631
- fprintf(stderr, "%s: %s LOG FLOOD PROTECTION resuming logging from process '%s' (prevented %lu logs in the last %ld seconds).\n"
632
- , date
633
- , program_name
634
- , program_name
635
- , prevented
636
- , error_log_throttle_period
637
- );
633
+ fprintf(
634
+ stderr,
635
+ "%s: %s LOG FLOOD PROTECTION resuming logging from process '%s' "
636
+ "(prevented %lu logs in the last %"PRId64" seconds).\n",
637
+ date,
638
+ program_name,
639
+ program_name,
640
+ prevented,
641
+ (int64_t)error_log_throttle_period);
642
}
643
644
// restart the period accounting
@@ -650,15 +654,18 @@ int error_log_limit(int reset) {
654
if(!prevented) {
655
char date[LOG_DATE_LENGTH];
656
log_date(date, LOG_DATE_LENGTH);
653
- fprintf(stderr, "%s: %s LOG FLOOD PROTECTION too many logs (%lu logs in %ld seconds, threshold is set to %lu logs in %ld seconds). Preventing more logs from process '%s' for %ld seconds.\n"
654
- , date
655
- , program_name
656
- , counter
657
- , now - start
658
- , error_log_errors_per_period
659
- , error_log_throttle_period
660
- , program_name
661
- , start + error_log_throttle_period - now);
657
+ fprintf(
658
+ stderr,
659
+ "%s: %s LOG FLOOD PROTECTION too many logs (%lu logs in %"PRId64" seconds, threshold is set to %lu logs "
660
+ "in %"PRId64" seconds). Preventing more logs from process '%s' for %"PRId64" seconds.\n",
661
+ date,
662
+ program_name,
663
+ counter,
664
+ (int64_t)(now - start),
665
+ error_log_errors_per_period,
666
+ (int64_t)error_log_throttle_period,
667
+ program_name,
668
+ (int64_t)(start + error_log_throttle_period - now));
669
}
670
671
prevented++;
streaming/receiver.c
+27
-9
@@ -69,15 +69,33 @@ PARSER_RC streaming_timestamp(char **words, void *user, PLUGINSD_ACTION *plugins
69
time_t now = now_realtime_sec(), prev = rrdhost_last_entry_t(host);
70
time_t gap = 0;
71
if (prev == 0)
72
- info("STREAM %s from %s: Initial connection (no gap to check), remote=%ld local=%ld slew=%ld",
73
- host->hostname, cd->cmd, remote_time, now, now-remote_time);
72
+ info(
73
+ "STREAM %s from %s: Initial connection (no gap to check), "
74
+ "remote=%"PRId64" local=%"PRId64" slew=%"PRId64"",
75
+ host->hostname,
76
+ cd->cmd,
77
+ (int64_t)remote_time,
78
+ (int64_t)now,
79
+ (int64_t)now - remote_time);
80
else {
81
gap = now - prev;
76
- info("STREAM %s from %s: Checking for gaps... remote=%ld local=%ld..%ld slew=%ld %ld-sec gap",
77
- host->hostname, cd->cmd, remote_time, prev, now, remote_time - now, gap);
82
+ info(
83
+ "STREAM %s from %s: Checking for gaps... "
84
+ "remote=%"PRId64" local=%"PRId64"..%"PRId64" slew=%"PRId64" %"PRId64"-sec gap",
85
+ host->hostname,
86
+ cd->cmd,
87
+ (int64_t)remote_time,
88
+ (int64_t)prev,
89
+ (int64_t)now,
90
+ (int64_t)(remote_time - now),
91
+ (int64_t)gap);
92
}
93
char message[128];
80
- sprintf(message,"REPLICATE %ld %ld\n", remote_time - gap, remote_time);
94
+ sprintf(
95
+ message,
96
+ "REPLICATE %"PRId64" %"PRId64"\n",
97
+ (int64_t)(remote_time - gap),
98
+ (int64_t)remote_time);
99
int ret;
100
#ifdef ENABLE_HTTPS
101
SSL *conn = host->stream_ssl.conn ;
@@ -441,10 +459,10 @@ static int rrdpush_receive(struct receiver_state *rpt)
459
if(health_enabled != CONFIG_BOOLEAN_NO) {
460
if(alarms_delay > 0) {
461
rpt->host->health_delay_up_to = now_realtime_sec() + alarms_delay;
444
- info("Postponing health checks for %ld seconds, on host '%s', because it was just connected."
445
- , alarms_delay
446
- , rpt->host->hostname
447
- );
462
+ info(
463
+ "Postponing health checks for %" PRId64 " seconds, on host '%s', because it was just connected.",
464
+ (int64_t)alarms_delay,
465
+ rpt->host->hostname);
466
}
467
}
468
rrdhost_unlock(rpt->host);
streaming/rrdpush.c
+15
-3
@@ -287,7 +287,7 @@ static inline void rrdpush_send_chart_metrics_nolock(RRDSET *st, struct sender_s
287
RRDHOST *host = st->rrdhost;
288
buffer_sprintf(host->sender->build, "BEGIN \"%s\" %llu", st->id, (st->last_collected_time.tv_sec > st->upstream_resync_time)?st->usec_since_last_update:0);
289
if (s->version >= VERSION_GAP_FILLING)
290
- buffer_sprintf(host->sender->build, " %ld\n", st->last_collected_time.tv_sec);
290
+ buffer_sprintf(host->sender->build, " %"PRId64"\n", (int64_t)st->last_collected_time.tv_sec);
291
else
292
buffer_strcat(host->sender->build, "\n");
293
@@ -681,7 +681,13 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *url) {
681
host->receiver->shutdown = 1;
682
shutdown(host->receiver->fd, SHUT_RDWR);
683
host->receiver = NULL; // Thread holds reference to structure
684
- info("STREAM %s [receive from [%s]:%s]: multiple connections for same host detected - existing connection is dead (%ld sec), accepting new connection.", host->hostname, w->client_ip, w->client_port, age);
684
+ info(
685
+ "STREAM %s [receive from [%s]:%s]: multiple connections for same host detected - "
686
+ "existing connection is dead (%"PRId64" sec), accepting new connection.",
687
+ host->hostname,
688
+ w->client_ip,
689
+ w->client_port,
690
+ (int64_t)age);
691
}
692
else {
693
netdata_mutex_unlock(&host->receiver_lock);
@@ -689,7 +695,13 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *url) {
695
rrd_unlock();
696
log_stream_connection(w->client_ip, w->client_port, key, host->machine_guid, host->hostname,
697
"REJECTED - ALREADY CONNECTED");
692
- info("STREAM %s [receive from [%s]:%s]: multiple connections for same host detected - existing connection is active (within last %ld sec), rejecting new connection.", host->hostname, w->client_ip, w->client_port, age);
698
+ info(
699
+ "STREAM %s [receive from [%s]:%s]: multiple connections for same host detected - "
700
+ "existing connection is active (within last %"PRId64" sec), rejecting new connection.",
701
+ host->hostname,
702
+ w->client_ip,
703
+ w->client_port,
704
+ (int64_t)age);
705
// Have not set WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET - caller should clean up
706
buffer_flush(w->response.data);
707
buffer_strcat(w->response.data, "This GUID is already streaming to this server");
streaming/sender.c
+1
-1
@@ -646,7 +646,7 @@ void *rrdpush_sender_thread(void *ptr) {
646
if (s->version >= VERSION_GAP_FILLING) {
647
time_t now = now_realtime_sec();
648
sender_start(s);
649
- buffer_sprintf(s->build, "TIMESTAMP %ld", now);
649
+ buffer_sprintf(s->build, "TIMESTAMP %"PRId64"", (int64_t)now);
650
sender_commit(s);
651
}
652
rrdpush_claimed_id(s->host);
web/api/exporters/shell/allmetrics_shell.c
+26
-25
@@ -107,22 +107,23 @@ void rrd_stats_api_v1_charts_allmetrics_json(RRDHOST *host, BUFFER *wb) {
107
if(rrdset_is_available_for_viewers(st)) {
108
rrdset_rdlock(st);
109
110
- buffer_sprintf(wb, "%s\n"
111
- "\t\"%s\": {\n"
112
- "\t\t\"name\":\"%s\",\n"
113
- "\t\t\"family\":\"%s\",\n"
114
- "\t\t\"context\":\"%s\",\n"
115
- "\t\t\"units\":\"%s\",\n"
116
- "\t\t\"last_updated\": %ld,\n"
117
- "\t\t\"dimensions\": {"
118
- , chart_counter?",":""
119
- , st->id
120
- , st->name
121
- , st->family
122
- , st->context
123
- , st->units
124
- , rrdset_last_entry_t_nolock(st)
125
- );
110
+ buffer_sprintf(
111
+ wb,
112
+ "%s\n"
113
+ "\t\"%s\": {\n"
114
+ "\t\t\"name\":\"%s\",\n"
115
+ "\t\t\"family\":\"%s\",\n"
116
+ "\t\t\"context\":\"%s\",\n"
117
+ "\t\t\"units\":\"%s\",\n"
118
+ "\t\t\"last_updated\": %"PRId64",\n"
119
+ "\t\t\"dimensions\": {",
120
+ chart_counter ? "," : "",
121
+ st->id,
122
+ st->name,
123
+ st->family,
124
+ st->context,
125
+ st->units,
126
+ (int64_t)rrdset_last_entry_t_nolock(st));
127
128
chart_counter++;
129
dimension_counter = 0;
@@ -131,15 +132,15 @@ void rrd_stats_api_v1_charts_allmetrics_json(RRDHOST *host, BUFFER *wb) {
132
RRDDIM *rd;
133
rrddim_foreach_read(rd, st) {
134
if(rd->collections_counter && !rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) {
134
-
135
- buffer_sprintf(wb, "%s\n"
136
- "\t\t\t\"%s\": {\n"
137
- "\t\t\t\t\"name\": \"%s\",\n"
138
- "\t\t\t\t\"value\": "
139
- , dimension_counter?",":""
140
- , rd->id
141
- , rd->name
142
- );
135
+ buffer_sprintf(
136
+ wb,
137
+ "%s\n"
138
+ "\t\t\t\"%s\": {\n"
139
+ "\t\t\t\t\"name\": \"%s\",\n"
140
+ "\t\t\t\t\"value\": ",
141
+ dimension_counter ? "," : "",
142
+ rd->id,
143
+ rd->name);
144
145
if(isnan(rd->last_stored_value))
146
buffer_strcat(wb, "null");
web/api/formatters/rrdset2json.c
+47
-43
@@ -40,58 +40,62 @@ void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memor
40
time_t first_entry_t = rrdset_first_entry_t_nolock(st);
41
time_t last_entry_t = rrdset_last_entry_t_nolock(st);
42
43
- buffer_sprintf(wb,
44
- "\t\t{\n"
45
- "\t\t\t\"id\": \"%s\",\n"
46
- "\t\t\t\"name\": \"%s\",\n"
47
- "\t\t\t\"type\": \"%s\",\n"
48
- "\t\t\t\"family\": \"%s\",\n"
49
- "\t\t\t\"context\": \"%s\",\n"
50
- "\t\t\t\"title\": \"%s (%s)\",\n"
51
- "\t\t\t\"priority\": %ld,\n"
52
- "\t\t\t\"plugin\": \"%s\",\n"
53
- "\t\t\t\"module\": \"%s\",\n"
54
- "\t\t\t\"enabled\": %s,\n"
55
- "\t\t\t\"units\": \"%s\",\n"
56
- "\t\t\t\"data_url\": \"/api/v1/data?chart=%s\",\n"
57
- "\t\t\t\"chart_type\": \"%s\",\n"
58
- , st->id
59
- , st->name
60
- , st->type
61
- , st->family
62
- , st->context
63
- , st->title, st->name
64
- , st->priority
65
- , st->plugin_name?st->plugin_name:""
66
- , st->module_name?st->module_name:""
67
- , rrdset_flag_check(st, RRDSET_FLAG_ENABLED)?"true":"false"
68
- , st->units
69
- , st->name
70
- , rrdset_type_name(st->chart_type)
71
- );
43
+ buffer_sprintf(
44
+ wb,
45
+ "\t\t{\n"
46
+ "\t\t\t\"id\": \"%s\",\n"
47
+ "\t\t\t\"name\": \"%s\",\n"
48
+ "\t\t\t\"type\": \"%s\",\n"
49
+ "\t\t\t\"family\": \"%s\",\n"
50
+ "\t\t\t\"context\": \"%s\",\n"
51
+ "\t\t\t\"title\": \"%s (%s)\",\n"
52
+ "\t\t\t\"priority\": %ld,\n"
53
+ "\t\t\t\"plugin\": \"%s\",\n"
54
+ "\t\t\t\"module\": \"%s\",\n"
55
+ "\t\t\t\"enabled\": %s,\n"
56
+ "\t\t\t\"units\": \"%s\",\n"
57
+ "\t\t\t\"data_url\": \"/api/v1/data?chart=%s\",\n"
58
+ "\t\t\t\"chart_type\": \"%s\",\n",
59
+ st->id,
60
+ st->name,
61
+ st->type,
62
+ st->family,
63
+ st->context,
64
+ st->title,
65
+ st->name,
66
+ st->priority,
67
+ st->plugin_name ? st->plugin_name : "",
68
+ st->module_name ? st->module_name : "",
69
+ rrdset_flag_check(st, RRDSET_FLAG_ENABLED) ? "true" : "false",
70
+ st->units,
71
+ st->name,
72
+ rrdset_type_name(st->chart_type));
73
74
if (likely(!skip_volatile))
74
- buffer_sprintf(wb,
75
- "\t\t\t\"duration\": %ld,\n"
76
- , last_entry_t - first_entry_t + st->update_every//st->entries * st->update_every
75
+ buffer_sprintf(
76
+ wb,
77
+ "\t\t\t\"duration\": %"PRId64",\n",
78
+ (int64_t)(last_entry_t - first_entry_t + st->update_every) //st->entries * st->update_every
79
);
80
79
- buffer_sprintf(wb,
80
- "\t\t\t\"first_entry\": %ld,\n"
81
- , first_entry_t //rrdset_first_entry_t(st)
81
+ buffer_sprintf(
82
+ wb,
83
+ "\t\t\t\"first_entry\": %"PRId64",\n",
84
+ (int64_t)first_entry_t //rrdset_first_entry_t(st)
85
);
86
87
if (likely(!skip_volatile))
85
- buffer_sprintf(wb,
86
- "\t\t\t\"last_entry\": %ld,\n"
87
- , last_entry_t//rrdset_last_entry_t(st)
88
+ buffer_sprintf(
89
+ wb,
90
+ "\t\t\t\"last_entry\": %"PRId64",\n",
91
+ (int64_t)last_entry_t //rrdset_last_entry_t(st)
92
);
93
90
- buffer_sprintf(wb,
91
- "\t\t\t\"update_every\": %d,\n"
92
- "\t\t\t\"dimensions\": {\n"
93
- , st->update_every
94
- );
94
+ buffer_sprintf(
95
+ wb,
96
+ "\t\t\t\"update_every\": %d,\n"
97
+ "\t\t\t\"dimensions\": {\n",
98
+ st->update_every);
99
100
unsigned long memory = st->memsize;
101
web/api/web_api_v1.c
+7
-3
@@ -589,9 +589,13 @@ inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, c
589
w->id, google_version, google_reqId, google_sig, google_out, responseHandler, outFileName
590
);
591
592
- buffer_sprintf(w->response.data,
593
- "%s({version:'%s',reqId:'%s',status:'ok',sig:'%ld',table:",
594
- responseHandler, google_version, google_reqId, st->last_updated.tv_sec);
592
+ buffer_sprintf(
593
+ w->response.data,
594
+ "%s({version:'%s',reqId:'%s',status:'ok',sig:'%"PRId64"',table:",
595
+ responseHandler,
596
+ google_version,
597
+ google_reqId,
598
+ (int64_t)st->last_updated.tv_sec);
599
}
600
else if(format == DATASOURCE_JSONP) {
601
if(responseHandler == NULL)