@@ -18,52 +18,54 @@ local function worker(format)
1818
1919 -- Get memory space in bytes
2020 _mem .total = tonumber (vm_stats .v_page_count ) * pagesize
21- _mem .buf .f = tonumber (vm_stats .v_free_count ) * pagesize
22- _mem .buf .a = tonumber (vm_stats .v_active_count ) * pagesize
23- _mem .buf .i = tonumber (vm_stats .v_inactive_count ) * pagesize
24- _mem .buf .c = tonumber (vm_stats .v_cache_count ) * pagesize
25- _mem .buf .w = tonumber (vm_stats .v_wire_count ) * pagesize
21+ _mem .buf .free = tonumber (vm_stats .v_free_count ) * pagesize
22+ _mem .buf .laundry = tonumber (vm_stats .v_laundry_count ) * pagesize
23+ _mem .buf .cache = tonumber (vm_stats .v_cache_count ) * pagesize
24+ _mem .buf .wired = tonumber (vm_stats .v_wire_count ) * pagesize
2625
2726 -- Rework into megabytes
2827 _mem .total = math.floor (_mem .total / 1048576 )
29- _mem .buf .f = math.floor (_mem .buf .f / 1048576 )
30- _mem .buf .a = math.floor (_mem .buf .a / 1048576 )
31- _mem .buf .i = math.floor (_mem .buf .i / 1048576 )
32- _mem .buf .c = math.floor (_mem .buf .c / 1048576 )
33- _mem .buf .w = math.floor (_mem .buf .w / 1048576 )
28+ _mem .buf .free = math.floor (_mem .buf .free / 1048576 )
29+ _mem .buf .laundry = math.floor (_mem .buf .laundry / 1048576 )
30+ _mem .buf .cache = math.floor (_mem .buf .cache / 1048576 )
31+ _mem .buf .wired = math.floor (_mem .buf .wired / 1048576 )
3432
3533 -- Calculate memory percentage
36- _mem .free = _mem .buf .f + _mem .buf .c + _mem .buf .i
34+ _mem .free = _mem .buf .free + _mem .buf .cache
35+ -- used memory basically consists of active+inactive+wired
3736 _mem .inuse = _mem .total - _mem .free
38- _mem .wire = _mem .buf .w
37+ _mem .notfreeable = _mem .inuse - _mem .buf .laundry
38+ _mem .wire = _mem .buf .wired
39+
3940 _mem .usep = math.floor (_mem .inuse / _mem .total * 100 )
40- _mem .inusep = math.floor (_mem .inuse / _mem .total * 100 )
41+ _mem .wirep = math.floor (_mem .wire / _mem .total * 100 )
42+ _mem .notfreeablep = math.floor (_mem .notfreeable / _mem .total * 100 )
4143
4244 -- Get swap states
4345 local vm_swap_total = tonumber (helpers .sysctl (" vm.swap_total" ))
4446 local vm_swap_enabled = tonumber (helpers .sysctl (" vm.swap_enabled" ))
4547 local _swp = { buf = {}, total = nil }
46-
48+
4749 if vm_swap_enabled == 1 and vm_swap_total > 0 then
4850 -- Get swap space in bytes
4951 _swp .total = vm_swap_total
50- _swp .buf .f = _swp .total - tonumber (vm_stats .v_swapin )
52+ _swp .buf .free = _swp .total - tonumber (vm_stats .v_swapin )
5153 -- Rework into megabytes
5254 _swp .total = math.floor (_swp .total / 1048576 )
53- _swp .buf .f = math.floor (_swp .buf .f / 1048576 )
55+ _swp .buf .free = math.floor (_swp .buf .free / 1048576 )
5456 -- Calculate percentage
55- _swp .inuse = _swp .total - _swp .buf .f
57+ _swp .inuse = _swp .total - _swp .buf .free
5658 _swp .usep = math.floor (_swp .inuse / _swp .total * 100 )
5759 else
5860 _swp .usep = - 1
5961 _swp .inuse = - 1
6062 _swp .total = - 1
61- _swp .buf .f = - 1
63+ _swp .buf .free = - 1
6264 end
6365
6466 return { _mem .usep , _mem .inuse , _mem .total , _mem .free ,
65- _swp .usep , _swp .inuse , _swp .total , _swp .buf .f ,
66- - 1 , _mem .wire }
67+ _swp .usep , _swp .inuse , _swp .total , _swp .buf .free ,
68+ _mem . wirep , _mem .wire , _mem . notfreeablep , _mem . notfreeable }
6769end
6870
6971return setmetatable (mem_freebsd , { __call = function (_ , ...) return worker (... ) end })
0 commit comments