|
10 | 10 |
|
11 | 11 | #include <errno.h>
|
12 | 12 | #include <math.h>
|
| 13 | +#include <stdio.h> |
13 | 14 | #include <stdlib.h>
|
14 | 15 | #include <string.h>
|
15 | 16 |
|
@@ -1058,24 +1059,41 @@ const char* lsb_heka_get_lua_file(lsb_heka_sandbox *hsb)
|
1058 | 1059 |
|
1059 | 1060 | lsb_heka_stats lsb_heka_get_stats(lsb_heka_sandbox *hsb)
|
1060 | 1061 | {
|
1061 |
| - if (!hsb) return (struct lsb_heka_stats){ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 1062 | + if (!hsb) return (struct lsb_heka_stats){ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
1062 | 1063 |
|
1063 | 1064 | return (struct lsb_heka_stats){
|
1064 |
| - .mem_cur = lsb_usage(hsb->lsb, LSB_UT_MEMORY, LSB_US_CURRENT), |
1065 |
| - .mem_max = lsb_usage(hsb->lsb, LSB_UT_MEMORY, LSB_US_MAXIMUM), |
1066 |
| - .out_max = lsb_usage(hsb->lsb, LSB_UT_OUTPUT, LSB_US_MAXIMUM), |
1067 |
| - .ins_max = lsb_usage(hsb->lsb, LSB_UT_INSTRUCTION, LSB_US_MAXIMUM), |
1068 |
| - .im_cnt = hsb->stats.im_cnt, |
1069 |
| - .im_bytes = hsb->stats.im_bytes, |
1070 |
| - .pm_cnt = hsb->stats.pm_cnt, |
1071 |
| - .pm_failures = hsb->stats.pm_failures, |
1072 |
| - .pm_avg = hsb->stats.pm.mean, |
1073 |
| - .pm_sd = lsb_sd_running_stats(&hsb->stats.pm), |
1074 |
| - .te_avg = hsb->stats.te.mean, |
1075 |
| - .te_sd = lsb_sd_running_stats(&hsb->stats.te) |
| 1065 | + .mem_cur = lsb_usage(hsb->lsb, LSB_UT_MEMORY, LSB_US_CURRENT), |
| 1066 | + .mem_max = lsb_usage(hsb->lsb, LSB_UT_MEMORY, LSB_US_MAXIMUM), |
| 1067 | + .ext_mem_cur = lsb_usage(hsb->lsb, LSB_UT_EXTERNAL_MEMORY, LSB_US_CURRENT), |
| 1068 | + .ext_mem_max = lsb_usage(hsb->lsb, LSB_UT_EXTERNAL_MEMORY, LSB_US_MAXIMUM), |
| 1069 | + .out_max = lsb_usage(hsb->lsb, LSB_UT_OUTPUT, LSB_US_MAXIMUM), |
| 1070 | + .ins_max = lsb_usage(hsb->lsb, LSB_UT_INSTRUCTION, LSB_US_MAXIMUM), |
| 1071 | + .im_cnt = hsb->stats.im_cnt, |
| 1072 | + .im_bytes = hsb->stats.im_bytes, |
| 1073 | + .pm_cnt = hsb->stats.pm_cnt, |
| 1074 | + .pm_failures = hsb->stats.pm_failures, |
| 1075 | + .pm_avg = hsb->stats.pm.mean, |
| 1076 | + .pm_sd = lsb_sd_running_stats(&hsb->stats.pm), |
| 1077 | + .te_avg = hsb->stats.te.mean, |
| 1078 | + .te_sd = lsb_sd_running_stats(&hsb->stats.te) |
1076 | 1079 | };
|
1077 | 1080 | }
|
1078 | 1081 |
|
| 1082 | +size_t lsb_heka_get_ext_memory_limit(lsb_heka_sandbox *hsb) |
| 1083 | +{ |
| 1084 | + return hsb ? lsb_usage(hsb->lsb, LSB_UT_EXTERNAL_MEMORY, LSB_US_LIMIT) : 0; |
| 1085 | +} |
| 1086 | + |
| 1087 | +void lsb_heka_adjust_ext_memory_usage(lsb_heka_sandbox *hsb, int sizechange) |
| 1088 | +{ |
| 1089 | + size_t oldsize = hsb->lsb->usage[LSB_UT_EXTERNAL_MEMORY][LSB_US_CURRENT]; |
| 1090 | + size_t newsize = hsb->lsb->usage[LSB_UT_EXTERNAL_MEMORY][LSB_US_CURRENT] + sizechange; |
| 1091 | + |
| 1092 | + if (newsize > hsb->lsb->usage[LSB_UT_EXTERNAL_MEMORY][LSB_US_MAXIMUM]) { |
| 1093 | + hsb->lsb->usage[LSB_UT_EXTERNAL_MEMORY][LSB_US_MAXIMUM] = newsize; |
| 1094 | + } |
| 1095 | + hsb->lsb->usage[LSB_UT_EXTERNAL_MEMORY][LSB_US_CURRENT] = newsize; |
| 1096 | +} |
1079 | 1097 |
|
1080 | 1098 | bool lsb_heka_is_running(lsb_heka_sandbox *hsb)
|
1081 | 1099 | {
|
|
0 commit comments