-1

I've installed my first plugin on a Nagios server, but am having trouble getting the arguments right. I've tried some things with $ARG1$ but am essentially just flopping around.

One complication, perhaps: this plugin is supposed to run on the nagios server itself; no npre call to a remote box.

The plugin is a shell script that makes a curl call against a remote box under the hood. Typical command line use with flags would read:

my_shell_script.sh -H my.server.of.interest -P 9000 -I ./tmp/settings_file -timeout 80

(yes, it has its own '-H' flag, unrelated to nagios' hostname flag.)

Here's the skeleton I have right now. Nagios appears to think all my flags are one giant one.

define command {
   command_name    my_command
   command_line    $USER1$/my_shell_script.sh $ARG1$
}

define service {
   use                  generic-service;
   host_name            {{what do I put here?  This is supposed to run on the nagios box itself. My shell script is installed on it.}};
   service_description      some description
   check_command         my_command!{{what goes here?}}
}

The above is a little stripped down for readability, but that's the gist of it. It's the hostname and arguments and bits in the 'what do I put here' that are giving me trouble. I could use a nudge, and thanks for the suggestions.

[Edit] it seems the intent of my post has been misunderstood, through my own language.

When I say I 'am essentially flopping around', that comes after several attempts at using the $ARG$ macros and rearranging things in a number of ways and realizing what I was trying simply wasn't working. I intentionally put up a simplified version of my plugin code in an attempt to get a point in the right direction.

  • 1
    Instead of random shots, just read the docs. If something is still unclear after that, ask questions. – Sven Oct 14 '14 at 23:29
  • I've been looking over the nagios documentation while doing this...do you have any good links from their documentation on command line arguments I can review? – larryq Oct 14 '14 at 23:54
  • 2
6

In the service definition you put the host_name of the host where the service is running that you want to check.

The check_command definition my_command!whatever will pass whatever to the command definition as $ARG1$. Add more !more for $ARG2$, etc.

You need to pass the needed parameters to my_shell_script.sh in the command definition. You have access to things like $HOSTNAME$ and $HOSTADDRESS$; the command you define in the define command section will be run locally on the nagios server; for things like nrpe there's a command definition that connects to the nrpe server... hence also then the command is run locally!

Start here for nagios documentation, e.g. "The Basics" and "Standard Macros in Nagios".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.