Mercurial > prosody-modules
view mod_measure_malloc/mod_measure_malloc.lua @ 4581:3e2e708fd18b
mod_adhoc_dataforms_demo: Add compat with 0.11 (vs trunk api change)
The name of the "access for anyone" permission level changed from "user"
in 0.11 to "any" in 0.12/trunk to make it clearer that it's basically
unrestricted. This is unfortunately not backwards-compatible.
Thanks to Sam for stumbling upon this during a demo.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 01 Jun 2021 19:23:32 +0200 |
parents | 5b4f43b90766 |
children | b9af1ccac98b |
line wrap: on
line source
module:set_global(); local metric = require"core.statsmanager".metric; local pposix = require"util.pposix"; local allocated = metric( "gauge", "malloc_heap_allocated", "bytes", "Allocated bytes by mode of allocation", {"mode"} ); local used = metric( "gauge", "malloc_heap_used", "bytes", "Used bytes" ):with_labels(); local unused = metric( "gauge", "malloc_heap_unused", "bytes", "Unused bytes" ):with_labels(); local returnable = metric( "gauge", "malloc_heap_returnable", "bytes", "Returnable bytes" ):with_labels(); module:hook("stats-update", function () meminfo = pposix.meminfo(); if meminfo.allocated then allocated:with_labels("sbrk"):set(meminfo.allocated); end if meminfo.allocated_mmap then allocated:with_labels("mmap"):set(meminfo.allocated_mmap); end if meminfo.used then used:set(meminfo.used); end if meminfo.unused then unused:set(meminfo.unused); end if meminfo.returnable then returnable:set(meminfo.returnable); end end);