Nagios 4: Registering object relationships in CGIs

Andreas Ericsson ae at op5.se
Tue Jan 8 11:16:44 CET 2013


On 01/08/2013 10:24 AM, Ton Voon wrote:
> 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

True. The previous behaviour was surprising though, since it meant that
when Nagios was started from an init script, it would normally be started
from the filesystem root, making relative paths impossible. Some paths
would be parsed relative to the home directory of the user we're running
as, and some would be parsed relative to the directory Nagios was started
from. Given that, I doubt anyone sane could have used relative paths for
anything much and kept their sanity.

>   * 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!
> 

Thanks a lot. I'll get this fixed today.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

------------------------------------------------------------------------------
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




More information about the Developers mailing list