I haven't run this in production yet, but it seems to me from reading the bash script that it will only return one status for the entire dump of data and one message. In our case, certain checks should be polled at certain intervals, and also we'd want different escalation depending on which check it was.

Am I missing something or does this script basically just set a status in Nagios and then dump the entire string?

How would you implement a more specific check? Should the data be parsed in the plugin? Or would you recommend different endpoints?

Also, why did you decide to use the format you did? Doesn't it make more sense to use a known serialization format like XML, JSON, YAML, etc?

Best,
Jacob

Comments

JacobSingh’s picture

Title: Possible to get status individually for each check? » Run checks for a specific module or a specific check inside a module
Category: support » feature
Status: Active » Needs review
StatusFileSize
new4.15 KB

I've created a patch which gets this working. Also, I was updating the docs and decided to move them to nagios.api.php which I believe is the common format these days. It's more or less the same, but I added the new param there to the hook definition.

I also removed the $skip_invoke stuff because it didn't seem like it was doing anything.

 function nagios_status_page() {
-  $skip_invoke = FALSE;
-
+  $args = func_get_args();
+  // Module to run checks for.
+  $module = array_shift($args);
+  // ID to run checks for.
+  $id = array_shift($args);
+  

+    if ($module) {
+      // A specific module has been requested.
+      $nagios_data = array();
+      $nagios_data[$module] = module_invoke($module, 'nagios', $id);
+    }
+    else {
+      $nagios_data = nagios_invoke_all('nagios');
+    }

is the gist of it.

kbahey’s picture

Status: Needs review » Needs work

I am still not clear on what the problem was that this patch fixes, but see that if no module is specified, it will still work as it always did via invoke all.

The patch does not include the nagios.api.php file. Please attach it as a .txt and I will add it.

JacobSingh’s picture

Sorry if the point wasn't clear. The problem is:

Perhaps we want to run a bunch of different checks, but get the status of each one individually because we would escalate them differently. We also want to run some checks every minute, but some are more intensive or don't want constant alerts, so we run them every hour.

Bad, generic example:

Say we've got 10 checks we want to run. I can't think of great examples, but let's called them c1...c10

We want to check c1 every minute, and if it fails, throw a CRIT

We want to check c2, c3 and c4 every 5 minutes, they all have different error levels they might throw.

With the current code, there is no way to do this. With my patch, we can setup 5-6 services in Nagios and tune them to just check what we need to check when. And of course, the original functionality hasn't changed as you noted.

My bad on the new file. f*!@#@ing CVS.

Attached the new patch.

Thanks!

kbahey’s picture

Status: Needs work » Fixed

Committed.

It is backward compatible, so safe, even if it adds a new feature.

Shukrya hein ...

JacobSingh’s picture

Koi baat nahi :) Shukriya

I didn't know you spoke Urdu! how did you learn? Or is it the same in Egyptian Arabic? I don't know, but I think it's Shukran in Arabic

We should chat sometime about nagios. I'm trying to figure out how to build something with rrdtool to do performance monitoring (send perf stats to nagios and build tables and graphs). If you have any ideas in this area, I'd appreciate it.

Best,
J

kbahey’s picture

I don't speak Urdu/Hindi. Just know a few words/expressions, and as you said, there is a lot of borrowing from Arabic. So some of it sticks out.

Open a new issue for graphic nagios performance data. Seems like something interesting to do.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xcession’s picture

Component: Miscellaneous » Documentation
Status: Closed (fixed) » Active

As far as I can tell the nagios.api.php example file that JacobSingh provided in his second patch file - which is vital for anyone trying to roll their own nagios-enabled modules - is still missing from the stable release, despite the other changes in this ticket being merged (namely the removal of the api documenation from the README).

As a result there is currently no api documentation.

I've altered the component of this issue to be "Documentation" accordingly.

  • kbahey committed 97bd222 on 8.x-1.x
    #794074 by JacobSingh: Allow for running checks for a specific module or...
greg.harvey’s picture

Issue summary: View changes

Hmm, I'm confused by the status of this. It's open under D6, but something was committed to the D8 branch?

greg.harvey’s picture

Status: Active » Closed (outdated)

Right, I think the above was just the commit bot having a "moment". This is seems well obsolete now. Closing.

greg.harvey’s picture

Version: 6.x-1.x-dev » 8.x-1.x-dev
Status: Closed (outdated) » Needs work

Actually, I realised the comment in #8 is still valid, the README was changed the API documentation file was not added.

I've added it now, as all the other code is in. I imagine this is still valid for Drupal 8 as well, however I noted Drupal 8 has a kind of hybrid README file, so the docs need checking before this gets merged through.

greg.harvey’s picture

Commit bot isn't showing the commit, so for reference it's here: http://cgit.drupalcode.org/nagios/commit/?id=27a7400

gogowitsch’s picture

Status: Needs work » Fixed

I added the API documentation in Commit a6733b5a.

Also, both Drupal 7 and 8 now allow the HTTP status page to return information on a single module, and pass an $id to hook_nagios().

On the Jacob's question about the format: it is the classical Nagios format. If someone needs a new format, you are very welcome to open a new issue. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.