naemon / naemon-core

Networks, Applications and Event Monitor
http://www.naemon.io/
GNU General Public License v2.0
154 stars 63 forks source link

External commands logging #377

Closed tomaszdubiel18 closed 1 year ago

tomaszdubiel18 commented 2 years ago

Hello. Although I have set: log_external_commands=0 log_passive_checks=1 Naemon still writes to log: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT................. PASSIVE SERVICE CHECK I want only passive service checks to be logged, not external command. Naemon 1.3.0. Debian 10.11

tomaszdubiel18 commented 2 years ago

This problem makes naemon's log grow very quickly. Can you look at this? Is this bug or some configuration issue?

tomaszdubiel18 commented 2 years ago

Hello.

tomaszdubiel18 commented 2 years ago

Bump

tomaszdubiel18 commented 2 years ago

Is this bug or some configuration issue?

nook24 commented 2 years ago

That's probably a bug because Naemon is logging the external command first, but flagging it as NSLOG_PASSIVE_CHECK: https://github.com/naemon/naemon-core/blob/f62b741eec55012197ddebbd31c6ecda96abc479/src/naemon/commands.c#L3395-L3399

This will write

EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;hplj2605dn;PING;0;This is an example plugin output.

to the naemon.log.

Later in the process, Naemon will log the actual processing of the passive check result: https://github.com/naemon/naemon-core/blob/f62b741eec55012197ddebbd31c6ecda96abc479/src/naemon/checks_service.c#L578 This is the

PASSIVE SERVICE CHECK: hplj2605dn;PING;0;This is an example plugin output.

message.

PS: Your spamy bump comments are annoying.

tomaszdubiel18 commented 2 years ago

I bump, because it causes significant difference in log files in my environment and if it was my configuration error, I would be grateful to stress where the error is. Thank you for confirming a bug. Now I will patiently wait for the fix.

sni commented 2 years ago

if you don't what those logs, why don't you set log_passive_checks=0?

tomaszdubiel18 commented 2 years ago

I want those logs, but I get the same twice. for example: [1651743734] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;;;;<some text"

and THE SAME:

[1651743734] PASSIVE SERVICE CHECK:;;;<some text"

tomaszdubiel18 commented 2 years ago

I get the same info, first as external command: process_service_check_result and then, as passive service check. @nook24 explained that.

tomaszdubiel18 commented 2 years ago

I remind I have set: log_external_commands=0 but still external_commands are written to log

sni commented 2 years ago

I'd suggest to set:

log_external_commands=1
log_passive_checks=0

There is usually no need to log each passive result comming in. But logging external commands is usually a good idea.

tomaszdubiel18 commented 2 years ago

I can try this and probably duplicates will disappear, but still I think that's a bug. Thanks.

tomaszdubiel18 commented 2 years ago

No, that's not a solution. With those settings Naemon doesn't write to log any info about result checks. I want to check service history and no data! I returned to original settings.

nook24 commented 2 years ago

Do you parse the log file to get history information instead of using a database for this?

tomaszdubiel18 commented 2 years ago

obraz Here you can see, since 12:12:03 there was no logs in service history. I reverted settings, restarted naemon and results from 12:28:04 got logged. That's a Thruk and I could get rid of those dupplicates by: logcache_import_exclude = "EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT" but anyway, log gets bigger and bigger with those dupplicates. @nook24, no. I use database for this.

tomaszdubiel18 commented 2 years ago

In logfile then, I had only warnings logged about external commands, but the actual results were missing.

nook24 commented 2 years ago

As mentioned in my comment above https://github.com/naemon/naemon-core/issues/377#issuecomment-1029361547, for some reason Naemon is logging the external command as NSLOG_PASSIVE_CHECK when it get's passed via naemon.cmd and naemon.qh.

https://github.com/naemon/naemon-core/blob/f62b741eec55012197ddebbd31c6ecda96abc479/src/naemon/commands.c#L3394-L3402

Maybe @sni can bring some light in the dark why it is done this way.

But according to git blame this is the way it works for more than 21 years now https://github.com/naemon/naemon-core/blame/7e61a03ca1c46ee8ded5704fe083317400fa1232/base/commands.c#L515-L531

Man i feel old now.

sni commented 2 years ago

how should i know why something happened 21 years ago. Don't even know what i did last week. Anyway, changing line 3398 to something like if (log_passive_checks == TRUE && log_external_commands == TRUE) should do the trick.