|
23 | 23 | #include <fluent-bit/flb_pack.h> |
24 | 24 | #include <fluent-bit/flb_utils.h> |
25 | 25 | #include <fluent-bit/flb_sqldb.h> |
| 26 | +#include <fluent-bit/flb_input_chunk.h> |
26 | 27 | #include "winevtlog.h" |
27 | 28 |
|
28 | 29 | #define DEFAULT_INTERVAL_SEC 1 |
29 | 30 | #define DEFAULT_INTERVAL_NSEC 0 |
30 | 31 | #define DEFAULT_THRESHOLD_SIZE 0x7ffff /* Default reading buffer size */ |
31 | 32 | /* (512kib = 524287bytes) */ |
32 | 33 | #define MINIMUM_THRESHOLD_SIZE 0x0400 /* 1024 bytes */ |
33 | | -#define MAXIMUM_THRESHOLD_SIZE (FLB_INPUT_CHUNK_FS_MAX_SIZE - (1024 * 200)) |
| 34 | +#define MAXIMUM_THRESHOLD_PERCENT 90 |
34 | 35 |
|
35 | 36 | static int in_winevtlog_collect(struct flb_input_instance *ins, |
36 | 37 | struct flb_config *config, void *in_context); |
@@ -163,6 +164,7 @@ static int in_winevtlog_init(struct flb_input_instance *in, |
163 | 164 | int status = WINEVTLOG_SESSION_CREATE_OK; |
164 | 165 | double mult = 2.0; |
165 | 166 | DWORD tmp_ms = 0; |
| 167 | + size_t maximum_threshold_size; |
166 | 168 |
|
167 | 169 | /* Initialize context */ |
168 | 170 | ctx = flb_calloc(1, sizeof(struct winevtlog_config)); |
@@ -273,32 +275,33 @@ static int in_winevtlog_init(struct flb_input_instance *in, |
273 | 275 | ctx->session = session; |
274 | 276 |
|
275 | 277 | /* Set up total reading size threshold */ |
| 278 | + maximum_threshold_size = flb_input_chunk_get_max_size(config) / 100 * MAXIMUM_THRESHOLD_PERCENT; |
276 | 279 | if (ctx->total_size_threshold >= MINIMUM_THRESHOLD_SIZE && |
277 | | - ctx->total_size_threshold <= MAXIMUM_THRESHOLD_SIZE) { |
278 | | - flb_utils_bytes_to_human_readable_size((size_t) ctx->total_size_threshold, |
| 280 | + ctx->total_size_threshold <= maximum_threshold_size) { |
| 281 | + flb_utils_bytes_to_human_readable_size(ctx->total_size_threshold, |
279 | 282 | human_readable_size, |
280 | 283 | sizeof(human_readable_size) - 1); |
281 | 284 | flb_plg_debug(ctx->ins, |
282 | 285 | "read limit per cycle is set up as %s", |
283 | 286 | human_readable_size); |
284 | 287 | } |
285 | | - else if (ctx->total_size_threshold > MAXIMUM_THRESHOLD_SIZE) { |
286 | | - flb_utils_bytes_to_human_readable_size((size_t) MAXIMUM_THRESHOLD_SIZE, |
| 288 | + else if (ctx->total_size_threshold > maximum_threshold_size) { |
| 289 | + flb_utils_bytes_to_human_readable_size(maximum_threshold_size, |
287 | 290 | human_readable_size, |
288 | 291 | sizeof(human_readable_size) - 1); |
289 | 292 | flb_plg_warn(ctx->ins, |
290 | 293 | "read limit per cycle cannot exceed %s. Set up to %s", |
291 | 294 | human_readable_size, human_readable_size); |
292 | | - ctx->total_size_threshold = (unsigned int) MAXIMUM_THRESHOLD_SIZE; |
| 295 | + ctx->total_size_threshold = maximum_threshold_size; |
293 | 296 | } |
294 | 297 | else if (ctx->total_size_threshold < MINIMUM_THRESHOLD_SIZE){ |
295 | | - flb_utils_bytes_to_human_readable_size((size_t) MINIMUM_THRESHOLD_SIZE, |
| 298 | + flb_utils_bytes_to_human_readable_size(MINIMUM_THRESHOLD_SIZE, |
296 | 299 | human_readable_size, |
297 | 300 | sizeof(human_readable_size) - 1); |
298 | 301 | flb_plg_warn(ctx->ins, |
299 | 302 | "read limit per cycle cannot under 1KiB. Set up to %s", |
300 | 303 | human_readable_size); |
301 | | - ctx->total_size_threshold = (unsigned int) MINIMUM_THRESHOLD_SIZE; |
| 304 | + ctx->total_size_threshold = MINIMUM_THRESHOLD_SIZE; |
302 | 305 | } |
303 | 306 |
|
304 | 307 | /* Open channels */ |
|
0 commit comments