Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showlog uses hardcoaded cgi.cfg not compatible with naemon #5

Open
techadrian opened this issue Jan 27, 2017 · 3 comments
Open

showlog uses hardcoaded cgi.cfg not compatible with naemon #5

techadrian opened this issue Jan 27, 2017 · 3 comments

Comments

@techadrian
Copy link

Hi Guys,

Please have a look at this line :
https://github.com/op5/ninja/blob/500b186445aba158ac1d8cc57072e785287e93be/modules/monitoring/helpers/showlog.php#L38 :
$etc_path = System_Model::get_nagios_etc_path();
$cgi_cfg = rtrim($etc_path, '/').'/cgi.cfg';

In a standard naemon install etc directory is here :
$config['nagios_etc_path'] = '/etc/naemon/';
as defined also in /var/www/html/ninja/application/config/config.php

showlog.php looks into this path for cgi.cfg : /etc/naemon/cgi.cfg but standard naemon install place cgi.cfg in /etc/thruk/cgi.cfg .

Quickfix is to create a symlink between /etc/thruk/cgi.cfg /etc/naemon/cgi.cfg but I would suggest cgi.cfg and nagios.cfg files not to be hardcoaded into the code but used as user defined variables in ninja/application/config/config.php .

The problem with cgi.cfg not being available to ninja is that Ninja will not display the Event Log in Menu : Report / EventLog

Cheers,
Adrian

@chelmertz
Copy link
Contributor

Thanks for another excellent report!

In #3, I suggested to move/duplicate the configuration parameter from naemon.cfg to Ninja's configuration files, but in this case, I would propose another way of solving the issue. As you can tell, Ninja is a bit incoherent about where to look for data from external parts, which makes it sad to debug from time to time.

A small recap: the showlog binary belongs to Merlin, which emits report events as text or HTML. One of the arguments to the showlog binary is the path to the file cgi.cfg, and as far as I can tell, it only uses the contents of cgi.cfg to find the value of main_config_file=X. That value resolves to some/path/nagios.cfg (or naemon.cfg). Following that, the only values that showlog is interested in, are log_file and log_archive_path because showlog operates on the log files.

So, basically, this API is a bit of a mess to begin with. I would like Ninja to be decoupled from Merlin, Ninja should at minimum not call hardcoded things from within the code.

I think we will have to think about how to best approach this, because of its tight connection to Merlin (and on top of that, the Merlin that is shipped and configured with OP5 Monitor contrary to the open source version of Merlin).

@techadrian
Copy link
Author

Hi Carl,

One suggestion if I may.

I would switch the execution from something like this :
/usr/local/lib/merlin/showlog --cgi-cfg /etc/naemon/cgi.cfg
to
/usr/local/lib/merlin/showlog --nagios-cfg /etc/naemon/naemon.cfg

Maybe naemon.cfg can be reference in /var/www/html/ninja/application/config/config.php as something like:
$config['nagios_cfg'] = $config['nagios_etc_path'].'/naemon.cfg';

nagios_cfg will become a user defined variable, and then can be reused across all code.
Not sure if that will technically work as the code structure is way above my head, but trying to bring some ideas into the picture :)

merlin - ninja integration .....I understand what you mean ...but hey...if its designed to work together...then it makes total sense to keep that tight integration and refine the api calls ;)

Good luck and have a nice weekend,
Adrian

@chelmertz
Copy link
Contributor

I totally agree with not pointing at cgi.cfg. It should be deprecated and each of its config-lines should be either discarded or moved to a better place. The "CGI" part of the filename refers to the now-dead interface of Nagios, i.e. a legacy; after that we just continued using some of the file's variables.

I agree with your proposition, referring to naemon.cfg/nagios.cfg might be a good middleground. Ideally, Ninja should not depend on other programs' configuration files. "Bounded context", if I may throw in a buzzword. On the other hand, the user should not have to edit identical configuration values in different locations.

Have a nice weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants