Memory leak in Nagios3?

Ethan Galstad nagios at nagios.org
Sun Nov 4 17:09:51 CET 2007


Andreas Ericsson wrote:
> Hendrik Bäcker wrote:
>> Hi List,
>>
>> after a four days running nagios 3 (latest cvs) I've recognized that my
>> system has only 80 MByte of free Memory (top).
>> After stopping Nagios the amount of free memory jumps up to 2,7 GByte.
>>
> 
> Are you using embedded perl? It's the single largest memory-sink in Nagios
> at the moment.
> 
>> Now my question: What is the best way to find such a leak (if there is one)?
>>
> 
> Ues valgrind.
> 
>> I know tools like valgrind, but I am not familar with right use of it.
>>
>> So, if someone can hit me to the right direction, I will try to debug.
>>
> 
> man valgrind, or learn how to implement ref-counting in C and add it to
> Nagios. If done properly, it will eliminate all in-core leaks and leave
> only the embedded perl ones.
> 

I'm guessing the mem leak is somewhere in the newly rewritten macro 
code.  Here's what I do to run valgrind...

Edit base/Makefile and uncomment the "CFLAGS" line below...

# Compiler flags for use with Valgrind
#CFLAGS=-O0 -g -DHAVE_CONFIG_H @GLIB_INCLUDE@ -DNSCORE

This will override the normal flags used to compile the Nagios daemon.
Recompile the Nagios daemon:

cd base
make clean
make

NOTE: If the large_installation_tweaks option is enabled, you will get a 
lot of errors, because Nagios intentionally does not free memory in 
child processes - it leaves that up to the kernel.  I would recomment 
running Nagios with this option disabled in order to track down memory 
leaks.

Run valgrind like so - debug files will be written to 
/tmp/valgrind.[pid] for inspection.

valgrind --log-file=/tmp/valgrind --trace-children=no --leak-check=full 
nagios /usr/local/nagios/etc/nagios.cfg

I just ran this myself and noticed several mem leaks from the new macro 
code.  Damn, I thought I ran valgrind before committing the changes. 
Heading out of town today, but I'll get some patches into CVS when I get 
back in a few days.


Ethan Galstad
Nagios Developer
___
Email: nagios at nagios.org
Web:   www.nagios.org

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/




More information about the Developers mailing list