Fix monitor's statistics aggregation

Vitaliy Filippov 2021-02-28 19:51:14 +03:00
parent 6155b23a7e
commit 24e7075f08
2 changed files with 16 additions and 10 deletions

View File

@ -379,7 +379,7 @@ class Mon
} }
if (this.verbose) if (this.verbose)
{ {
console.log(e); console.log(JSON.stringify(e));
} }
} }
if (stats_changed) if (stats_changed)
@ -974,21 +974,21 @@ class Mon
for (const op in st.op_stats||{}) for (const op in st.op_stats||{})
{ {
op_stats[op] = op_stats[op] || { count: 0n, usec: 0n, bytes: 0n }; op_stats[op] = op_stats[op] || { count: 0n, usec: 0n, bytes: 0n };
op_stats[op].count += BigInt(st.op_stats.count||0); op_stats[op].count += BigInt(st.op_stats[op].count||0);
op_stats[op].usec += BigInt(st.op_stats.usec||0); op_stats[op].usec += BigInt(st.op_stats[op].usec||0);
op_stats[op].bytes += BigInt(st.op_stats.bytes||0); op_stats[op].bytes += BigInt(st.op_stats[op].bytes||0);
} }
for (const op in st.subop_stats||{}) for (const op in st.subop_stats||{})
{ {
subop_stats[op] = subop_stats[op] || { count: 0n, usec: 0n }; subop_stats[op] = subop_stats[op] || { count: 0n, usec: 0n };
subop_stats[op].count += BigInt(st.subop_stats.count||0); subop_stats[op].count += BigInt(st.subop_stats[op].count||0);
subop_stats[op].usec += BigInt(st.subop_stats.usec||0); subop_stats[op].usec += BigInt(st.subop_stats[op].usec||0);
} }
for (const op in st.recovery_stats||{}) for (const op in st.recovery_stats||{})
{ {
recovery_stats[op] = recovery_stats[op] || { count: 0n, bytes: 0n }; recovery_stats[op] = recovery_stats[op] || { count: 0n, bytes: 0n };
recovery_stats[op].count += BigInt(st.recovery_stats.count||0); recovery_stats[op].count += BigInt(st.recovery_stats[op].count||0);
recovery_stats[op].bytes += BigInt(st.recovery_stats.bytes||0); recovery_stats[op].bytes += BigInt(st.recovery_stats[op].bytes||0);
} }
} }
for (const op in op_stats) for (const op in op_stats)

View File

@ -25,7 +25,7 @@ OSD6_PID=$!
cd mon cd mon
npm install npm install
cd .. cd ..
node mon/mon-main.js --etcd_url http://$ETCD_URL --etcd_prefix "/vitastor" &>./testdata/mon.log & node mon/mon-main.js --etcd_url http://$ETCD_URL --etcd_prefix "/vitastor" --verbose 1 &>./testdata/mon.log &
MON_PID=$! MON_PID=$!
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":16,"failure_domain":"osd"}}' $ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":16,"failure_domain":"osd"}}'
@ -97,9 +97,15 @@ try_change 17
try_change 16 try_change 16
# Monitor should report non-zero overall statistics at least once
if ! (grep /vitastor/stats ./testdata/mon.log | jq -s -e '[ .[] | select((.kv.value.op_stats.primary_write.count | tonumber) > 0) ] | length > 0'); then
format_error "FAILED: monitor doesn't aggregate stats"
fi
# Changing pg count should never produce the 'has_degraded' object state # Changing pg count should never produce the 'has_degraded' object state
if grep has_degraded testdata/osd*.log; then if grep has_degraded ./testdata/osd*.log; then
format_error "FAILED: some objects were degraded during PG move" format_error "FAILED: some objects were degraded during PG move"
fi fi