Nagios 4: Registering object relationships in CGIs

Ton Voon tonvoon at gmail.com
Tue Jan 8 10:24:10 CET 2013


Hi Andreas,

On 7 Jan 2013, at 19:27, Andreas Ericsson wrote:

> On 01/07/2013 05:31 PM, Ton Voon wrote:
>> I'll create a testcase for you, if that helps.
> 
> That would be most helpful, yes.

The existing test suite has been broken, so please find patches attached that fix the 610cgistatus.t test. I've also included the necessary test files to demonstrate the problem. Invoke with "perl t/610cgistatus.t"

Patch explanations:
 * t/etc/nagios.cfg - file locations used to be based on current working directory, but now appear to be relative to the nagios.cfg directory. Rather than change Nagios, I've just changed the test data. Note: if Nagios is left, this may affect some systems that use relative directories, but I only know of tests that utilise this
 * cgi/cgiutils.c - I've added the object_cache_file to be read from the main nagios.cfg file. This is required for testing purposes, but also if not used, the object_cache_file will just use DEFAULT_OBJECT_CACHE_FILE, which I guess is undesirable
 * t/610cgistatus.t - I've updated some existing tests because the strings in the HTML output are different (because of the pagination feature). I've also added in the last test which uses the status.cgi as the "second" user, which demonstrates this problem
 * t/var/objects.cache - this is the definition file used to support the test. Note the normalhostcontactgroup is defined correctly for the host and the service, yet the status.cgi fails with a permission failure message. If you add the "second" user as a normal contact, then this works. This says to me that the contactgroups are not expanded correctly for the CGIs

My original patch, reattached, is not ideal but fixes the problem, so I present it as a way to show why the current behaviour is wrong. I'm sure there's a better solution, probably some other "do expansion of object relationships" call that should be invoked instead, but I can't quite understand the C-fu magic that is going on with the new configuration code!

Ton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nagios_test_fixes_and_show_contactgroup_problem.patch
Type: application/octet-stream
Size: 4974 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20130108/fb6a8c14/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nagios_cgi_contactgroups_not_expanded.patch
Type: application/octet-stream
Size: 1309 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20130108/fb6a8c14/attachment-0001.obj>
-------------- next part --------------
------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list