From: Andreas E. <ae...@op...> - 2013-09-04 13:32:54
|
On 2013-09-04 12:51, AL13N wrote: >> On 2013-09-04 00:34, AL13N wrote: >>> Op dinsdag 3 september 2013 17:22:32 schreef Andreas Ericsson: >>>> On 2013-09-02 21:20, AL13N wrote: >>>>> Hi, >>>>> >>>>> i'm a Mageia distribution packager, and i'm maintaining some event >>>>> broker >>>>> modules. >>>>> >>>>> since these are packaged seperately we're trying to get things to work >>>>> out-of- the-box for our users, specifically adding event brokers in >>>>> the >>>>> configuration file for nagios. >>>>> >>>>> the problem we're facing is that: We don't want a nagios addon package >>>>> to >>>>> rewrite the configuration file itself. however, we would like to add >>>>> the >>>>> event broker (or other settings) and then reload/restart nagios. >>>>> >>>>> a beneficial thing would be a configuration directory (much like it >>>>> exists >>>>> with hosts and commands and stuff like that) but for the main nagios >>>>> configuration file. >>>>> >>>>> and if while we're at it, to have multiple directories, where >>>>> /usr/share/nagios/nagios.d/ has the "defaults" which can be overridden >>>>> in >>>>> /etc/nagios.d/ (for instance) (this is a convention that's growing in >>>>> use) >>>>> >>>>> I can try to start making a patch for this, but i'm asking about this >>>>> first, in order to find out if it makes a chance of getting accepted. >>>> >>>> Not only does it stand a chance of getting accepted; It's on the >>>> roadmap. If you start working on it I'll help as much as I can and >>>> I'm willing to accept less-than-awesome quality code, although I'll >>>> polish such later if it turns out to be an issue. >>>> >>>> The only real requirement is that any "main" config file option >>>> should be settable from any file in the dropdir. >>> >>> >>> the idea i thought might be doable, would be to allow multiple -d >>> options to >>> nagios, and allow those to be a file or a directory. >>> >> >> I'd much rather see this as "include=/some/path.d" where we read all >> files ending with .cfg and .conf if it's a directory, or the file if >> it's a fail, and then parse each include'd file in order of >> include-statement -> lexicographical order >> so that >> >> include=/etc/nagios.conf.d/ >> include=/etc/nagios.perfdata.d/ >> >> would cause all files from /etc/nagios.conf.d to be parsed before all >> files from /etc/nagios.perfdata.d. >> >> The included files can include other files, if they're so inclined. > > so, you mean to keep one nagios.cfg file and have include=/path/to/foo. > > would this mean that if you have > > setting1=value > > setting2=value > > include=/path/to/foo > > setting3=value > > that being parsed would: > 1) setting1 > 2) setting2 > 3) all from /path/to/foo if it's a file or directory > 4) setting3 > > > is this the priority that you aim for? > No. All variables from one file should be parsed before any variables from a different file, but the include-files from one file get parsed before we move along to the next file in that directory. If we pretend that /etc/nagios/conf.d contains two files, named A.cfg and B.cfg, where A.cfg has "include=/etc/nagios/perfdata.cfg" and the main nagios config file is /etc/nagios/nagios.cfg, but one also wants to oneshot parse /etc/nagios/debug.cfg, then one would execute Nagios like so: nagios -d /etc/nagios/nagios.cfg /etc/nagios/debug.cfg and with the above settings we would parse /etc/nagios/nagios.cfg nagios.cfg (all settings) /etc/nagios/conf.d/A.cfg (all settings) /etc/nagios/perfdata.cfg (all settings) /etc/nagios/conf.d/B.cfg (all settings) /etc/nagios/debug.cfg (all settings) In practice though, I expect the default settings will be so that /etc/nagios/nagios.cfg contains this: include=/etc/nagios/defaults.cfg include=/etc/nagios/conf.d Btw, we shouldn't error out when encountering an empty directory, but rather just print a warning about it. Or even have "include_dir" and "include_file", where both cause an error if the targeted path doesn't exist, although we allow empty directories. I just realized that this includes the "parse multiple config files from command-line", but since that's hardly a difficult issue once we can parse multiple config files, I doubt that's a problem. -- Andreas Ericsson and...@op... 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. |