Re: [Nagios-devel] Nagios 4: Registering object relationships in

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] Nagios 4: Registering object relationships in

Post by Guest »

--Apple-Mail-120-96780719
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="us-ascii"

Hi Andreas,

On 16 Jan 2013, at 17:37, Andreas Ericsson wrote:

> Well, the story goes like this:
> We would *actually* want to use the recombobulate_*groups() functions,
> but those rely on find_*(), add_member_to_group() and a whole bunch of
> other functions which are inside #ifndef NSCGI (or #ifdef NSCORE).
>=20
> Those functions bring in yet other functions and some of *those* live
> in other files. There are no functions anywhere that reside in the
> base/ directory which have to be linked to the cgi's no matter how far
> down the rabbithole you go, but it's a bit of a mess, really, and
> with the recent improbable-but-possible coredump issue in Nagios core
> I was forced to take a short hiatus from cgi issues and jump on that
> one instead.
>=20
> Anyways; It's unlikely manageable to fix it the proper way. If you
> beat me to a hack that just iterates over the string elements inside
> register_*group(), I think I'll just take that patch instead and put
> a big fat "FIXME this is fugly and should use instead".

I think I've fixed this "properly", as properly as possible. Can you =
review?

Most of the changes are just #ifdefs moved to appropriate places. It =
seems that the parsing of objects.cache was done, just the expansion was =
not. I'm assuming that host/service dependency information is not =
required in the CGIs.

I've also included a test update which checks the CGI are returning the =
object information correctly. svn has marked t/610cgistatus.t as an =
application/x-troff so was not showing the diff correctly. I've included =
as a separate file. Can this be fixed in svn please.

Ton


--Apple-Mail-120-96780719
Content-Disposition: attachment;
filename="nagios_fix_cgi_object_relationships.patch"
Content-Type: application/octet-stream; x-unix-mode=0644;
name="nagios_fix_cgi_object_relationships.patch"
Content-Transfer-Encoding: 7bit

Index: xdata/xodtemplate.c
===================================================================
--- xdata/xodtemplate.c (revision 2581)
+++ xdata/xodtemplate.c (working copy)
@@ -116,12 +116,17 @@
/* xodtemplate id / object counter */
static struct object_count xodcount;

-#ifndef NSCGI
/* reusable bitmaps for expanding objects */
static bitmap *host_map = NULL, *contact_map = NULL;
-#endif
static bitmap *service_map = NULL, *parent_map = NULL;

+/* These variables are defined in base/utils.c, but as CGIs do not need these
+ we just fake the values for this file */
+#ifdef NSCGI
+int use_precached_objects = TRUE;
+int use_regexp_matches = FALSE;
+int use_true_regexp_matching = FALSE;
+#endif

/*
* simple inheritance macros. o = object, t = template, v = variable
@@ -369,6 +374,7 @@
/* cleanup some additive inheritance stuff... */
xodtemplate_clean_additive_strings();
}
+#endif

/* do the meat and potatoes stuff... */
host_map = bitmap_create(xodcount.hosts);
@@ -380,16 +386,21 @@

if(result == OK)
result = xodtemplate_recombobulate_contactgroups();
+#ifndef NSCGI
if(test_scheduling == TRUE)
gettimeofday(&tv[3], NULL);
timing_point("Done recombobulating contactgroups\n");
+#endif

if(result == OK)
result = xodtemplate_recombobulate_hostgroups();
+#ifndef NSCGI
if(test_scheduling == TRUE)
gettimeofday(&tv[4], NULL);
timing_point("Done recombobulating hostgroups\n");
+#endif

+#ifndef NSCGI
if(use_precached_objects == FALSE) {
if(result == OK)
result = xodtemplate_duplicate_services();
@@ -397,6 +408,7 @@
gettimeofday(&tv[5], NULL);
timing_point("Created %u services (dupes possible)\n", xodcount.services);
}
+#endif

/* now we have an accurate service count */
service_map = bitmap_create(xodcount.services);
@@ -407,6 +419,7 @@

if(result == OK)
result = xodtemplate_recombobulate_servicegroups();
+#ifndef NSCGI
if(test_scheduling == TRUE)
gettimeofday(&tv[6], NULL);
timing_point("Done recombobulating servicegroups\n");
@@ -5942,6 +5955,7 @@



+#endif

/******************************************************************/
/*************** OBJECT RECOMBOBUL

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: ton.voon@opsview.com
Locked