fix stat output
This commit is contained in:
@@ -60,7 +60,7 @@ calculate() {
|
|||||||
local fields=($(echo "$curr_data" | jq -r '.[].fields | to_entries | .[] | .key' | grep -v timestamp_ms))
|
local fields=($(echo "$curr_data" | jq -r '.[].fields | to_entries | .[] | .key' | grep -v timestamp_ms))
|
||||||
local curr_ts=$(echo "$curr_data" | jq -r '.[].timestamp_ms')
|
local curr_ts=$(echo "$curr_data" | jq -r '.[].timestamp_ms')
|
||||||
local prev_ts=$(echo "$prev_data" | jq -r '.[].timestamp_ms')
|
local prev_ts=$(echo "$prev_data" | jq -r '.[].timestamp_ms')
|
||||||
local diff_ts=$((($curr_ts - $prev_ts) / 1000))
|
local diff_ts=$(($curr_ts - $prev_ts))
|
||||||
local seconds=$((curr_ts / 1000))
|
local seconds=$((curr_ts / 1000))
|
||||||
local buffer=()
|
local buffer=()
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ calculate() {
|
|||||||
if [ $diff_ts -eq 0 ]; then
|
if [ $diff_ts -eq 0 ]; then
|
||||||
speed=0
|
speed=0
|
||||||
else
|
else
|
||||||
speed=$((diff_val / diff_ts))
|
speed=$((diff_val * 1000 / diff_ts))
|
||||||
fi
|
fi
|
||||||
buffer+=("$(printf "%-30s" $field)$(printf "%-20s" $curr_val)$(printf "%-20s" $speed)\n")
|
buffer+=("$(printf "%-30s" $field)$(printf "%-20s" $curr_val)$(printf "%-20s" $speed)\n")
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ struct stellar_thread
|
|||||||
pthread_t tid;
|
pthread_t tid;
|
||||||
uint16_t idx;
|
uint16_t idx;
|
||||||
uint64_t is_runing;
|
uint64_t is_runing;
|
||||||
uint64_t stat_last_merge_ts;
|
|
||||||
uint64_t timing_wheel_last_update_ts;
|
uint64_t timing_wheel_last_update_ts;
|
||||||
struct ip_reassembly *ip_mgr;
|
struct ip_reassembly *ip_mgr;
|
||||||
struct session_manager *sess_mgr;
|
struct session_manager *sess_mgr;
|
||||||
@@ -257,12 +256,7 @@ static void *work_thread(void *arg)
|
|||||||
thread->timing_wheel_last_update_ts = now;
|
thread->timing_wheel_last_update_ts = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now - thread->stat_last_merge_ts > 1000)
|
|
||||||
{
|
|
||||||
merge_thread_stat(thread, now);
|
merge_thread_stat(thread, now);
|
||||||
thread->stat_last_merge_ts = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_reassembly_expire(ip_reass, now);
|
ip_reassembly_expire(ip_reass, now);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
@@ -289,7 +283,6 @@ static int stellar_thread_init(struct stellar_runtime *ctx, uint8_t nr_threads)
|
|||||||
struct stellar_thread *thread = &ctx->threads[i];
|
struct stellar_thread *thread = &ctx->threads[i];
|
||||||
thread->idx = i;
|
thread->idx = i;
|
||||||
thread->is_runing = 0;
|
thread->is_runing = 0;
|
||||||
thread->stat_last_merge_ts = now;
|
|
||||||
thread->timing_wheel_last_update_ts = now;
|
thread->timing_wheel_last_update_ts = now;
|
||||||
thread->sess_mgr = session_manager_new(&config->sess_mgr_opts, now);
|
thread->sess_mgr = session_manager_new(&config->sess_mgr_opts, now);
|
||||||
if (thread->sess_mgr == NULL)
|
if (thread->sess_mgr == NULL)
|
||||||
@@ -419,7 +412,7 @@ int main(int argc, char **argv)
|
|||||||
while (!ATOMIC_READ(&runtime->need_exit))
|
while (!ATOMIC_READ(&runtime->need_exit))
|
||||||
{
|
{
|
||||||
timestamp_update();
|
timestamp_update();
|
||||||
if (timestamp_get_msec() - runtime->stat_last_output_ts > 1000)
|
if (timestamp_get_msec() - runtime->stat_last_output_ts > 2000)
|
||||||
{
|
{
|
||||||
runtime->stat_last_output_ts = timestamp_get_msec();
|
runtime->stat_last_output_ts = timestamp_get_msec();
|
||||||
stellar_stat_output(runtime->stat);
|
stellar_stat_output(runtime->stat);
|
||||||
|
|||||||
Reference in New Issue
Block a user