-
Notifications
You must be signed in to change notification settings - Fork 28
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
Enable template options #61
base: master
Are you sure you want to change the base?
Conversation
OK, starting to look at this now. Dumping questions as i see them. Is the feature not more appropriately named template variables ? |
return template_output, filename | ||
|
||
def _parse_template_opts(opt_file): | ||
import yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this import to the top of the file.
Also, please put yaml dependency in requirements.txt, rpm spec file and debian/ directory
Ok i didnt run this yet, but the code diff looks good. Then i just stumbled on to an idea that might seem idiodic but... Seems like in your http example there is 1:1 mapping between attributes, and the "template option names". Why not have this --opt foo=bar describe any attribute name ? Benefits:
Cons:
Again, we come back to we need more concrete examples. Currently the http feature is kind of already implemented in adagios via okconfig > add service |
(so a quick summary, i dont see a problem with the code per se, but i worry that the feature could be implemented without a need for another config file. |
The destination-filename is a stumbling block, plus alternate service_descriptions which I want to address. Instead of going with the mssql, I'm going to post an example using check_postgres which highlights the problem more adequetaly. There we have server based checks and then we have per-database checks. The per database checks would need to be noted in the service_description and I would see adding a postgres-{hostname}-{database}.cfg for each database. Why a configuration file? I want to enrich the user experience of arguments where there is a description of what the option is and even going with enum fields where there are only a few valid options. No functionality has been implemented yet but consumers can read the description field and I'm working on the functionality of The 1:1 mapping is almost correct but I'm offering for sane defaults where something like VIRTUAL_HOST can be derived from HOSTNAME by default but the user is allowed to specify his own VIRTUAL_HOST where appropriate. |
Ok sounds good. Postgres template sounds nice. |
Additionally, thoughts on a less confusing name ? (suggestion: template variables) |
I have a few templates that would benefit from this. Basically all checks that belong on a host that have to check via some 3rd party, e.g. iLO checks need an IP address parameter and vSphere node checks need various parameters for querying the vSphere API. I like the "template variables" name better as well. |
Are you still working on this ? |
@@ -44,6 +44,7 @@ | |||
examples_directory_local= config.examples_directory_local | |||
destination_directory = config.destination_directory | |||
import socket | |||
import yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like yaml is a new dependency. Should be marked as such in packaging.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
What it does
Enables template options via --opt VAR=SOMETHING
What it does NOT
Break how everything used to work, so old templates still work
Description
Contents of the file (/etc/nagios/okconfig/hosts/default/www.okconfig.org-http-vhost.okconfig.org.cfg) become
Then there is the configuration for the template options.
/usr/share/okconfig/examples/http.yml
It still uses the example file which now looks like this: