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

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

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

Post by Guest »


--Apple-Mail-22--844770302
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii

Hi,

We're looking at the latest Nagios 4 branch and have seen an issue where =
the refactoring around object relationships seems to be missing for the =
CGIs. The specific problem is that the contactgroups do not have all the =
members populated, though I think host groups and other relationships =
are affected.

It looks like the Nagios4 code uses a member_list structure which is =
NULL for #ifdef NSCGI, but is set correctly with a linked list for =
#ifdef NSCORE.

The patch below fixes this though I'm not convinced this is the right =
way to fix. It seems to me that the member_list structure should be =
populated correctly for NSCGI.

Ton


--Apple-Mail-22--844770302
Content-Disposition: attachment;
filename=nagios_cgi_contactgroups_not_expanded.patch
Content-Type: application/octet-stream;
name="nagios_cgi_contactgroups_not_expanded.patch"
Content-Transfer-Encoding: 7bit

diff -ur nagios-4.0.20130107/xdata/xodtemplate.c nagios-4.0.20130107.working/xdata/xodtemplate.c
--- nagios-4.0.20130107/xdata/xodtemplate.c 2012-12-24 19:56:13.000000000 +0000
+++ nagios-4.0.20130107.working/xdata/xodtemplate.c 2012-12-24 19:57:08.000000000 +0000
@@ -7186,6 +7186,7 @@
int xodtemplate_register_contactgroup(xodtemplate_contactgroup *this_contactgroup) {
contactgroup *new_contactgroup = NULL;
objectlist *list;
+ char *temp_ptr;

/* bail out if we shouldn't register this object */
if(this_contactgroup->register_object == FALSE)
@@ -7200,6 +7201,17 @@
return ERROR;
}

+
+#ifdef NSCGI
+ /* Opsview patch: When reading CGIs, the contact groups are not expanded out correctly. We do this manually from
+ the objects.cache, which is reliable as each item here should already be a valid contact.
+ It is okay to do the following member_list as this will be NULL
+ */
+ for(temp_ptr = strtok(this_contactgroup->members, ","); temp_ptr; temp_ptr = strtok(NULL, ",")) {
+ add_contact_to_contactgroup(new_contactgroup, temp_ptr);
+ }
+#endif
+
for(list = this_contactgroup->member_list; list; list = list->next) {
xodtemplate_contact *c = (xodtemplate_contact *)list->object_ptr;
add_contact_to_contactgroup(new_contactgroup, c->contact_name);

--Apple-Mail-22--844770302--





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