diff --git a/src/box/lua/slab.cc b/src/box/lua/slab.cc index 0a88bd0c9ce5a5604878e3418a67213a6f123f93..6b0fe31929e9b3dbcc2adb14424619b7371cebe3 100644 --- a/src/box/lua/slab.cc +++ b/src/box/lua/slab.cc @@ -97,6 +97,24 @@ lbox_slab_info(struct lua_State *L) lua_pushstring(L, "arena_size"); luaL_pushnumber64(L, totals.total); lua_settable(L, -3); + + char value[32]; + double items_used_perc = 100 + * ((double)totals.used) + / ((double)talloc.cache->arena->prealloc + 0.0001); + snprintf(value, sizeof(value), "%0.1lf%%", items_used_perc); + lua_pushstring(L, "items_used_%"); + lua_pushstring(L, value); + lua_settable(L, -3); + + double arena_used_perc = 100 + * ((double)talloc.cache->arena->used) + / ((double)talloc.cache->arena->prealloc + 0.0001); + snprintf(value, sizeof(value), "%0.1lf%%", arena_used_perc); + lua_pushstring(L, "arena_used_%"); + lua_pushstring(L, value); + lua_settable(L, -3); + return 1; } diff --git a/test/box/misc.result b/test/box/misc.result index f144c5debf03902a95d1cf37a324d084b26a372d..16611f5ec8b175d9844c6450cbc7b81e3b162c97 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -147,9 +147,11 @@ end; ... t; --- -- - slabs - - arena_size +- - arena_used_% - arena_used + - items_used_% + - arena_size + - slabs ... ---------------- -- # box.error