Help with NRPE please

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
csward
Posts: 46
Joined: Fri Mar 08, 2013 4:37 pm

Help with NRPE please

Post by csward »

Hello, I'm trying to use Check_WinFile and using the NAME filter in my arguements. This is my config. Can you help me place the arguements in my statements? I'm sure I have them in the wrong place. I basically want to have nagios send an alert when there hasn't been a file written to a particular folder in over an hour:

Windows.cfg
define service {

use generic-service
host_name CSITFPSP01A
service_description Check Files in CSITFPSP01a
check_command check_nrpe!check_winfile --target J:\AWIIProxy\ProcessedMessages --filter "age ge -1 hours" --filter "name eq *GeneralUpdateAttachmentZip*" --critical 0
}


Commands.cfg
define command{
command_name check_nrpe
command_line /usr/local/src/nagios-plugins-1.4.16/plugins/check_nrpe -H $HOSTADDRESS$ -t 120 -c $ARG1$
}


Nsclient.ini
check_winfile=check_winfile.exe //T:30 //NoLogo scripts/check_winfile.pl $Arg1$ $Arg2$ $Arg3$ $Arg4$

Thanks!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Help with NRPE please

Post by slansing »

Well you will need to designate a "-a" section in your nrpe command on the nagios side as that defines your arguments. While it is possible to use multiple argument sections through NSClient++ I typically recommend you use only a $ARG1$ and then place all of your information which will be sent over in the argument after the single "-a" on the nagios side. Also, were you looking to get a warning threshold in there as well? Or just a critical?
csward
Posts: 46
Joined: Fri Mar 08, 2013 4:37 pm

Re: Help with NRPE please

Post by csward »

What's the difference between -c and -a ? Is this the NRPE command you are referring to?

Commands.cfg
define command{
command_name check_nrpe
command_line /usr/local/src/nagios-plugins-1.4.16/plugins/check_nrpe -H $HOSTADDRESS$ -t 120 -c $ARG1$
}

I really only need a critical threshold. Thanks
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Help with NRPE please

Post by abrist »

'-c' is used by check_nrpe for the actual command name (defined in the remote host's nrpe.cfg or nsclient config file - i.e. check_disk, check_procs, etc).
'-a' is used for the arguments that are passed to the command on the remote host (i.e. warning and critical thresholds, mount points, etc) The arguments are plugin specific.

I would suggest the following changes:

Code: Select all

command_line /usr/local/src/nagios-plugins-1.4.16/plugins/check_nrpe -H $HOSTADDRESS$ -t 120 -c $ARG1$ $ARG2$
And:

Code: Select all

check_command check_nrpe!check_winfile! -a '--target J:\AWIIProxy\ProcessedMessages --filter "age ge -1 hours" --filter "name eq *GeneralUpdateAttachmentZip*" --critical 0'
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
csward
Posts: 46
Joined: Fri Mar 08, 2013 4:37 pm

Re: Help with NRPE please

Post by csward »

Thanks, I will try this.

So, why would I have two arguements in the command_line statement? Since I only have one command defined on the remote host ini file, shouldn't I need only one? Or will it matter. Does it disregard an arg statement if it isn't needed?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Help with NRPE please

Post by slansing »

This all depends on how you want the information to be passed. It has nothing to do with a specific type of check or plugin it just makes it so you do not have to hard code checks. When you define the ARG's in your command string which you then assign to the service, you can also assign that same command to other services on other hosts without having to create a new one. You simply pass the arguments in the service definition and are separated by "!". This is the chain of events the way andy laid them out:

Nagios runs the service check:

-Nagios looks at the service definition, grabs the name of your defined command in commands.cfg and then fills in all Argument spaces in that definition with those you defined in the service definition. In this case that would be check_winfile and the -a string.

-That command is ran as it would be manually from the command line, verbose. And when it reaches the windows server everything you have after the "-a" is placed where you have added $ARG1$ in the nsc.ini file.
csward
Posts: 46
Joined: Fri Mar 08, 2013 4:37 pm

Re: Help with NRPE please

Post by csward »

Thanks for the clarification. That is what I was hoping it would do.

I have another issue with the .ini portion:

ExternalCommands: failed to create process (scritpscheck_winfile.exe //T:30 //NoLogo scriptscheck_winfile.pl $Arg1$): 2: The system cannot find the file specified.

My .ini file is stated like this:


check_winfile= scritps\check_winfile.exe //T:30 //NoLogo scripts\check_winfile.pl $Arg1$

Also, do i need to specify were perl is located somehow within this statement to run the script?

Thanks
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Help with NRPE please

Post by lmiltchev »

Isn't this:
check_winfile= scritps\check_winfile.exe //T:30 //NoLogo scripts\check_winfile.pl $Arg1$
supposed to be:
check_winfile= scripts\check_winfile.exe //T:30 //NoLogo scripts\check_winfile.pl $Arg1$
?
Be sure to check out our Knowledgebase for helpful articles and solutions!
csward
Posts: 46
Joined: Fri Mar 08, 2013 4:37 pm

Re: Help with NRPE please

Post by csward »

Yeah, i know, i was just testing you guys :)


Here is my issue now:

define service {

use generic-service
host_name CSITFPSP01A
service_description Check Files in CSITFPSP01a
check_command check_nrpe!check_winfile! -a '--target J:\AWIIProxy\ProcessedMessages --filter "age ge -1 hours" --filter "name eq *GeneralUpdateAttachmentZip*" --critical 0'
}



If I run the command with the quotes (as suggested) I get

FILE UNKNOWN - No targets are specified.

So thinking I could just run this without the quotes and it should take the commands still, I get this:

(No output returned from plugin)


This is my .ini file config:


check_winfile= scripts\check_winfile.exe //T:30 //NoLogo scripts\check_winfile.pl $Arg1$


Thanks for the help.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Help with NRPE please

Post by lmiltchev »

A few things that *may* help...

You need to change this:
define command{
command_name check_nrpe
command_line /usr/local/src/nagios-plugins-1.4.16/plugins/check_nrpe -H $HOSTADDRESS$ -t 120 -c $ARG1$
}
to this:
define command{
command_name check_nrpe
command_line /usr/local/src/nagios-plugins-1.4.16/plugins/check_nrpe -H $HOSTADDRESS$ -t 120 -c $ARG1$ $ARG2$
}
if you want to pass arguments.

I am not sure if nsclient++ "cares" about the case, but you will have to probably change $Arg1$ (mixed case) to $ARG1$.

You should probably remove the "scripts\check_windfile.pl" section from the following line:

Code: Select all

check_winfile= scripts\check_winfile.exe //T:30 //NoLogo scripts\check_winfile.pl $ARG1$
This is not, how you run this plugin. Take a look at some of the examples below:
EXAMPLES

check_winfile --target c:\temp --warn 100 --critical 250

Counts all files in the directory c:\temp. Returns WARNING for more than 100 files or CRITICAL for more than 250 files.

check_winfile -t c:\backup\db1,c:\backup\db2 --filter "age ge -24 hours" --critical 0

Returns CRITICAL if at least one of the files c:\backup\db1 and c:\backup\db2 is 24 hours old.

check_winfile --target "c:\logfiles" --filter "size gt 10485760","age lt -15 minutes" --filter "name match \.log$" --delete --warning 10 --critical 50

Counts and deletes files with .log extension, which are modified within last 15 minutes AND are larger than 10 MB. Returns WARNING if there are more than 10 files meeting the criteria, CRITICAL for more than 50 files.
Try running it locally first (on the Windows box) to test it.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked