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

How do I pass arguments to check_nginx? #96

Open
egrist opened this issue Oct 26, 2016 · 5 comments
Open

How do I pass arguments to check_nginx? #96

egrist opened this issue Oct 26, 2016 · 5 comments

Comments

@egrist
Copy link
Contributor

egrist commented Oct 26, 2016

Using v1.0.10
How do I add arguments to check_nginx?

I've tried in yaml: nagios::check::nginx::args: 'argument'
and: nagios_check_nginx_args: 'argument'

If I add a block of nagios::check::nginx and using args parameter, it works, though the "default (which contains no arguments)" check is still there.

@pelacables
Copy link

Hi,
I'm running the version "1.0.7" of this puppet module and hiera 1.3.4.
hiera data binding for defines is not supported (I guess it isn't in any hiera version, but I'm not 100% sure).

I came to the same problem when trying to pass arguments to check_http ("-u /something" in my case) and the only way I found to do that was to patch the nagios::check::httpd define call in defaultchecks.pp (so the data binding takes places when calling the define and not later).

diff --git a/modules/nagios/manifests/defaultchecks.pp b/modules/nagios/manifests/defaultchecks.pp
index 8b6e7e1..6cc3cd4 100644
--- a/modules/nagios/manifests/defaultchecks.pp
+++ b/modules/nagios/manifests/defaultchecks.pp
@@ -15,7 +15,9 @@ class nagios::defaultchecks {
   # Conditional checks, enabled based on custom facts
   if $::nagios_check_httpd_disable != 'true' and
      $::nagios_httpd {
-    nagios::check::httpd { $nagios::client::host_name: }
+    nagios::check::httpd { $nagios::client::host_name:
+      args => hiera('nagios_check_httpd_args',''),
+    }
   } else {
     nagios::check::httpd { $nagios::client::host_name: ensure => absent }
   }

So I guess you should do the same for the nginx check (with some extra modification in the check::nginx define itself:

diff --git a/modules/nagios/manifests/defaultchecks.pp b/modules/nagios/manifests/defaultchecks.pp
index 6cc3cd4..1c012f7 100644
--- a/modules/nagios/manifests/defaultchecks.pp
+++ b/modules/nagios/manifests/defaultchecks.pp
@@ -35,7 +35,9 @@ class nagios::defaultchecks {
   }
   if $::nagios_check_nginx_disable != 'true' and
      $::nagios_httpd_nginx {
-    nagios::check::nginx { $nagios::client::host_name: }
+    nagios::check::nginx { $nagios::client::host_name:
+      args => hiera('nagios_check_nginx_args',''),
+    }
   } else {
     nagios::check::nginx { $nagios::client::host_name: ensure => absent }
   }

then change the nginx check define to:

define nagios::check::nginx (
 $ensure = undef,
 $args   = $::nagios_check_nginx_args,
) {

and set nagios_check_nginx_args in your hiera file:

nagios_check_nginx_args: '-u /s'

HTH

@egrist
Copy link
Contributor Author

egrist commented May 31, 2017

Nice, thanks a lot for this, will you make a PR?

@pelacables
Copy link

I don't know...
I see 9 PR in queue and @thias not very active lately...

@egrist
Copy link
Contributor Author

egrist commented May 31, 2017

Well, you could fork or branch it, and we can use that in the mean time until it maybe gets merged since we are using r10k.

@pelacables
Copy link

I've not tested the nginx part so I cannot ensure that it will work. Also, I'm running and old version of the module (1.0.7), so I don't think it's a good idea to create a PR.
This is a 4 lines "patch", I prefer to leave the solution here and wait until I move to the latest version of the module where I'll implement the patch for both nginx and http.

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