|
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)); |
@@ -255,32 +257,33 @@ static int in_winevtlog_init(struct flb_input_instance *in, |
255 | 257 | ctx->session = session; |
256 | 258 |
|
257 | 259 | /* Set up total reading size threshold */ |
| 260 | + maximum_threshold_size = flb_input_chunk_get_max_size(config) / 100 * MAXIMUM_THRESHOLD_PERCENT; |
258 | 261 | if (ctx->total_size_threshold >= MINIMUM_THRESHOLD_SIZE && |
259 | | - ctx->total_size_threshold <= MAXIMUM_THRESHOLD_SIZE) { |
260 | | - flb_utils_bytes_to_human_readable_size((size_t) ctx->total_size_threshold, |
| 262 | + ctx->total_size_threshold <= maximum_threshold_size) { |
| 263 | + flb_utils_bytes_to_human_readable_size(ctx->total_size_threshold, |
261 | 264 | human_readable_size, |
262 | 265 | sizeof(human_readable_size) - 1); |
263 | 266 | flb_plg_debug(ctx->ins, |
264 | 267 | "read limit per cycle is set up as %s", |
265 | 268 | human_readable_size); |
266 | 269 | } |
267 | | - else if (ctx->total_size_threshold > MAXIMUM_THRESHOLD_SIZE) { |
268 | | - flb_utils_bytes_to_human_readable_size((size_t) MAXIMUM_THRESHOLD_SIZE, |
| 270 | + else if (ctx->total_size_threshold > maximum_threshold_size) { |
| 271 | + flb_utils_bytes_to_human_readable_size(maximum_threshold_size, |
269 | 272 | human_readable_size, |
270 | 273 | sizeof(human_readable_size) - 1); |
271 | 274 | flb_plg_warn(ctx->ins, |
272 | 275 | "read limit per cycle cannot exceed %s. Set up to %s", |
273 | 276 | human_readable_size, human_readable_size); |
274 | | - ctx->total_size_threshold = (unsigned int) MAXIMUM_THRESHOLD_SIZE; |
| 277 | + ctx->total_size_threshold = maximum_threshold_size; |
275 | 278 | } |
276 | 279 | else if (ctx->total_size_threshold < MINIMUM_THRESHOLD_SIZE){ |
277 | | - flb_utils_bytes_to_human_readable_size((size_t) MINIMUM_THRESHOLD_SIZE, |
| 280 | + flb_utils_bytes_to_human_readable_size(MINIMUM_THRESHOLD_SIZE, |
278 | 281 | human_readable_size, |
279 | 282 | sizeof(human_readable_size) - 1); |
280 | 283 | flb_plg_warn(ctx->ins, |
281 | 284 | "read limit per cycle cannot under 1KiB. Set up to %s", |
282 | 285 | human_readable_size); |
283 | | - ctx->total_size_threshold = (unsigned int) MINIMUM_THRESHOLD_SIZE; |
| 286 | + ctx->total_size_threshold = MINIMUM_THRESHOLD_SIZE; |
284 | 287 | } |
285 | 288 |
|
286 | 289 | /* Open channels */ |
|
0 commit comments