Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/v1/debug/malloc_info: call malloc_info(3) if available #10015

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Al2Klimov
Copy link
Member

The GNU libc function malloc_info(3) provides memory allocation and usage statistics of Icinga 2 itself.

@Al2Klimov Al2Klimov added enhancement New feature or request area/api REST API labels Mar 4, 2024
@cla-bot cla-bot bot added the cla/signed label Mar 4, 2024
Comment on lines 2520 to 2566
<total type="fast" count="64" size="5504"/>
<total type="rest" count="41" size="12648"/>
<system type="current" size="368640"/>
<system type="max" size="368640"/>
<aspace type="total" size="368640"/>
<aspace type="mprotect" size="368640"/>
<aspace type="subheaps" size="1"/>
</heap>
<heap nr="28">
<sizes>
<size from="17" to="32" total="544" count="17"/>
<size from="33" to="48" total="432" count="9"/>
<size from="49" to="64" total="64" count="1"/>
<size from="81" to="96" total="192" count="2"/>
<size from="97" to="112" total="5152" count="46"/>
<size from="113" to="128" total="384" count="3"/>
<size from="65" to="65" total="520" count="8"/>
<size from="81" to="81" total="729" count="9"/>
<size from="97" to="97" total="873" count="9"/>
<size from="577" to="577" total="577" count="1"/>
<size from="673" to="673" total="673" count="1"/>
<size from="737" to="737" total="737" count="1"/>
<size from="769" to="769" total="769" count="1"/>
<size from="1041" to="1041" total="2082" count="2"/>
</sizes>
<total type="fast" count="78" size="6768"/>
<total type="rest" count="33" size="11440"/>
<system type="current" size="401408"/>
<system type="max" size="401408"/>
<aspace type="total" size="401408"/>
<aspace type="mprotect" size="401408"/>
<aspace type="subheaps" size="1"/>
</heap>
<heap nr="29">
<sizes>
<size from="33" to="33" total="363" count="11"/>
<size from="49" to="49" total="343" count="7"/>
<size from="81" to="81" total="243" count="3"/>
<size from="97" to="97" total="679" count="7"/>
<size from="113" to="113" total="1130" count="10"/>
<size from="129" to="129" total="129" count="1"/>
<size from="161" to="161" total="322" count="2"/>
<size from="177" to="177" total="1416" count="8"/>
<size from="193" to="193" total="579" count="3"/>
<size from="209" to="209" total="627" count="3"/>
<size from="225" to="225" total="225" count="1"/>
<size from="257" to="257" total="1285" count="5"/>
<size from="289" to="289" total="289" count="1"/>
<size from="337" to="337" total="674" count="2"/>
<size from="353" to="353" total="1059" count="3"/>
<size from="369" to="369" total="369" count="1"/>
<size from="401" to="401" total="401" count="1"/>
<size from="417" to="417" total="417" count="1"/>
<size from="433" to="433" total="433" count="1"/>
<size from="465" to="465" total="465" count="1"/>
<size from="481" to="481" total="962" count="2"/>
<size from="497" to="497" total="497" count="1"/>
<size from="513" to="513" total="513" count="1"/>
<size from="529" to="529" total="1058" count="2"/>
<size from="545" to="545" total="1090" count="2"/>
<size from="657" to="657" total="657" count="1"/>
</sizes>
<total type="fast" count="0" size="0"/>
<total type="rest" count="82" size="50977"/>
<system type="current" size="344064"/>
<system type="max" size="344064"/>
<aspace type="total" size="344064"/>
<aspace type="mprotect" size="344064"/>
<aspace type="subheaps" size="1"/>
</heap>
<heap nr="30">
<sizes>
<size from="17" to="32" total="96" count="3"/>
<size from="33" to="48" total="576" count="12"/>
<size from="49" to="64" total="64" count="1"/>
<size from="97" to="112" total="3584" count="32"/>
<size from="49" to="49" total="98" count="2"/>
<size from="81" to="81" total="810" count="10"/>
<size from="257" to="257" total="2827" count="11"/>
<size from="689" to="689" total="689" count="1"/>
<size from="705" to="705" total="705" count="1"/>
<unsorted from="81" to="81" total="81" count="1"/>
</sizes>
<total type="fast" count="48" size="4320"/>
<total type="rest" count="27" size="118618"/>
<system type="current" size="135168"/>
<system type="max" size="135168"/>
<aspace type="total" size="135168"/>
<aspace type="mprotect" size="135168"/>
<aspace type="subheaps" size="1"/>
</heap>
<total type="fast" count="938" size="79392"/>
<total type="rest" count="700" size="4409469"/>
<total type="mmap" count="0" size="0"/>
<system type="current" size="15114240"/>
<system type="max" size="15114240"/>
<aspace type="total" size="15114240"/>
<aspace type="mprotect" size="15114240"/>
</malloc>
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very long and provides very little information for its length. Please shorten it to a reasonable length. I'd suggest replacing all but the first <heap> element with <!-- ... -->.

Comment on lines +2508 to +2510
The GNU libc function `malloc_info(3)` provides memory allocation and usage
statistics of Icinga 2 itself. You can call it directly by sending a `GET`
request to the URL endpoint `/v1/debug/malloc_info`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some glibc documentation explaining how this is to be interpreted that can be referenced?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd not reference anything beyond "malloc_info(3)" as the format is versioned and hence may be changed. I guess someone who wants to deeply analyse that stuff won't have any problem – looking up a manual about internals of (the current version at that time of) malloc takes just a few minutes: https://sourceware.org/glibc/wiki/MallocInternals


response.result(200);
response.set(http::field::content_type, "application/xml");
response.body() = std::string(boost::string_view(buf, bufSize));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use boost::string_view here, std::string can be used with the same constructor parameters directly. (Apart from that, C++17 has std::string_view).

The GNU libc function malloc_info(3) provides memory allocation and usage
statistics of Icinga 2 itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api REST API cla/signed enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants