Re: [Nagios-devel] Host and Services update fonction called twice

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Host and Services update fonction called twice

Post by Guest »

Hello,

I'm Matthieu and I work with Julien, here at Merethis. I see that
there's a bit of a misunderstanding so I'll try to clarify and explain
what we believe to be a bug in Nagios. All code, dumps and
explanations below are extracted from the latest CVS revision of
Nagios.

On Thu, May 14, 2009 at 1:44 PM, Andreas Ericsson wrote:
> The figures you posted are really just crap to me as I have no idea what
> the different figures are suppose to mean.
>

Those are just plain text dump of what ndomod sends to ndo2db. The
format is really simple. Just notice that each "paragraph" is a
different event that will generate a DB query (ie. if you have twice
the same paragraph in a row, you'll execute the same query twice on
the DB).

> A hook such as the one below would let you debug this
> properly:
>
> [...]
> =A0 =A0 =A0 =A0if (ds->type !=3D NEBTYPE_SERVICE_CHECK_PROCESSED) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return 0;
> =A0 =A0 =A0 =A0}
> [...]
>

That's what tipped me off. In fact we weren't talking about
SERVICE_CHECK events but about SERVICE_STATUS events ! So I guess your
explanations about DNX support code is off the table... Right ?

Now that we're clear, here are my first investigations.

It seems that for each service status update on Nagios, the
update_service_status() function from common/statusdata.c is called
twice. This function generates a NEBTYPE_SERVICESTATUS_UPDATE event
each time it's called. Below is what I believe to be the offending
code from base/checks.c :



881 int handle_async_service_check_result(service *temp_service,
check_result *queued_check_result){
[...]
1560 /* schedule a non-forced check if we can */
1561 if(temp_service->should_be_scheduled=3D=3DTRUE)
1562 schedule_service_check(temp_service,temp_service->next_check,CHECK=
_OPTION_NONE);
[...] /* No modification of temp_service in between. */
1590 update_service_status(temp_service,FALSE);



Here's what to notice is :
- the call to schedule_service_check() with temp_service
- the call to update_service_status() below with no modification of
temp_service



1634 void schedule_service_check(service *svc, time_t check_time, int opti=
ons){
[...]
1764 /* update the status log */
1765 update_service_status(svc,FALSE);



Unfortunately, when trying to schedule the next service check, it is
possible that the temp_service object is reused, just updated on the
next service check time. So the event could be broadcasted a first
time in schedule_service_check() and a second time in
handle_async_service_check_result().

So what do you think about it ? I'm new to Nagios code so I might be mistak=
en.

Best regards,

--=20
Matthieu KERMAGORET | D=E9veloppeur

[email protected]

MERETHIS est =E9diteur du logiciel Centreon.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked