process_check_result_file Memory Leak on Nagios 4
Posted: Mon Feb 20, 2017 10:50 pm
Hi,
I have been checking memory leaks from our monitoring system for the past few days. We are using Nagios 3.5.1 and we have developed our own web UI to create and view status of our devices. Researching online led me to use valgrind to check memory leaks (https://support.nagios.com/forum/viewto ... 34&t=20350) and I found three issues so far:
1. log_service_event Memory Leak
Valgrind reports the following logs for log_service_event:
(1) ==21781== 95 bytes in 1 blocks are definitely lost in loss record 242 of 317
(1) ==21781== at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
(1) ==21781== by 0x55D11FA: vasprintf (vasprintf.c:84)
(1) ==21781== by 0x55B3596: asprintf (asprintf.c:35)
(1) ==21781== by 0x43793F: log_service_event (logging.c:297)
(1) ==21781== by 0x419535: handle_async_service_check_result (checks.c:1246)
(1) ==21781== by 0x416F83: reap_check_results (checks.c:180)
(1) ==21781== by 0x4349E3: handle_timed_event (events.c:1361)
(1) ==21781== by 0x433E31: event_execution_loop (events.c:1071)
(1) ==21781== by 0x413435: main (nagios.c:858)
This is solved after applying the fix from: https://sourceforge.net/p/nagios/nagios ... 0e201575d/
2. MK Live Status Memory Leak
Valgrind reports the following logs for MK Live Status Memory Leak:
(1) ==5679== 36 bytes in 1 blocks are definitely lost in loss record 1,857 of 8,053
(1) ==5679== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
(1) ==5679== by 0x55E7729: strdup (strdup.c:42)
(1) ==5679== by 0x65BB993: livestatus_parse_arguments (in /opt/nagios/main/var/nebmodsOeKUS)
(1) ==5679== by 0x65BC0B7: nebmodule_init (in /opt/nagios/main/var/nebmodsOeKUS)
(1) ==5679== by 0x415842: neb_load_module (in /opt/nagios/main/bin/nagios)
(1) ==5679== by 0x4154C7: neb_load_all_modules (in /opt/nagios/main/bin/nagios)
(1) ==5679== by 0x41307C: main (in /opt/nagios/main/bin/nagios)
I have not seen any fix for this on the internet and so we decided to turn off LiveStatus by commenting out broker_module on Nagios Configuration file. We will get the status from Nagios Status File instead.
3. process_check_result_file Memory Leak
This is the issue I am not able to fix and I cannot find any fix on the internet.
Valgrind logs reports as:
(1) ==24848== 11,960 (8,704 direct, 3,256 indirect) bytes in 64 blocks are definitely lost in loss record 306 of 321
(1) ==24848== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
(1) ==24848== by 0x44DA25: process_check_result_file (utils.c:2652)
(1) ==24848== by 0x44D53D: find_executing_checks (utils.c:2502)
(1) ==24848== by 0x41327B: main (nagios.c:825)
I have tried modifying utils.c to free new_cr in various places of the source code but nothing seems to work. I am not sure if this has something to do with my setup because I cannot find anybody having the same issue on the internet.
I hope somebody can suggest a fix for this. Any information you need please let me know.
Thank you.
I have been checking memory leaks from our monitoring system for the past few days. We are using Nagios 3.5.1 and we have developed our own web UI to create and view status of our devices. Researching online led me to use valgrind to check memory leaks (https://support.nagios.com/forum/viewto ... 34&t=20350) and I found three issues so far:
1. log_service_event Memory Leak
Valgrind reports the following logs for log_service_event:
(1) ==21781== 95 bytes in 1 blocks are definitely lost in loss record 242 of 317
(1) ==21781== at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
(1) ==21781== by 0x55D11FA: vasprintf (vasprintf.c:84)
(1) ==21781== by 0x55B3596: asprintf (asprintf.c:35)
(1) ==21781== by 0x43793F: log_service_event (logging.c:297)
(1) ==21781== by 0x419535: handle_async_service_check_result (checks.c:1246)
(1) ==21781== by 0x416F83: reap_check_results (checks.c:180)
(1) ==21781== by 0x4349E3: handle_timed_event (events.c:1361)
(1) ==21781== by 0x433E31: event_execution_loop (events.c:1071)
(1) ==21781== by 0x413435: main (nagios.c:858)
This is solved after applying the fix from: https://sourceforge.net/p/nagios/nagios ... 0e201575d/
2. MK Live Status Memory Leak
Valgrind reports the following logs for MK Live Status Memory Leak:
(1) ==5679== 36 bytes in 1 blocks are definitely lost in loss record 1,857 of 8,053
(1) ==5679== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
(1) ==5679== by 0x55E7729: strdup (strdup.c:42)
(1) ==5679== by 0x65BB993: livestatus_parse_arguments (in /opt/nagios/main/var/nebmodsOeKUS)
(1) ==5679== by 0x65BC0B7: nebmodule_init (in /opt/nagios/main/var/nebmodsOeKUS)
(1) ==5679== by 0x415842: neb_load_module (in /opt/nagios/main/bin/nagios)
(1) ==5679== by 0x4154C7: neb_load_all_modules (in /opt/nagios/main/bin/nagios)
(1) ==5679== by 0x41307C: main (in /opt/nagios/main/bin/nagios)
I have not seen any fix for this on the internet and so we decided to turn off LiveStatus by commenting out broker_module on Nagios Configuration file. We will get the status from Nagios Status File instead.
3. process_check_result_file Memory Leak
This is the issue I am not able to fix and I cannot find any fix on the internet.
Valgrind logs reports as:
(1) ==24848== 11,960 (8,704 direct, 3,256 indirect) bytes in 64 blocks are definitely lost in loss record 306 of 321
(1) ==24848== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
(1) ==24848== by 0x44DA25: process_check_result_file (utils.c:2652)
(1) ==24848== by 0x44D53D: find_executing_checks (utils.c:2502)
(1) ==24848== by 0x41327B: main (nagios.c:825)
I have tried modifying utils.c to free new_cr in various places of the source code but nothing seems to work. I am not sure if this has something to do with my setup because I cannot find anybody having the same issue on the internet.
I hope somebody can suggest a fix for this. Any information you need please let me know.
Thank you.