Page 2 of 3

Re: Trying to setup plugin check_numoffiles.sh

Posted: Tue Jul 26, 2016 7:07 am
by joshtate2001
The final nail ended up being a permission issue with the plugin. I did a chmod 755 on check_numoffiles.sh and restarted the nagios. It seems to be now reporting correctly.

Re: Trying to setup plugin check_numoffiles.sh

Posted: Tue Jul 26, 2016 7:18 am
by joshtate2001
Well, I was able to solve the error regarding the (Return code 13 being out of bounds).
This was a permission issue on the plugin it self.

The service is showing green and reporting 0 files.
I dropped three files in the folder, which should have generated a warning.

The service is still green and reporting 0 files. Not sure what I am missing.
I restarted the nagios processes and did a re-check of the service, but still showing the same.

Re: Trying to setup plugin check_numoffiles.sh

Posted: Tue Jul 26, 2016 10:00 am
by rkennedy

Code: Select all

   check_command      check_numoffiles.sh!C:\DoceServe\Active\!2!4
It looks like you're trying to execute a bash script, with a windows path. Just to clarify - Are you dropping files in that folder above?

See what @mcapra mentioned above -
Also, if your intention is to use this plugin to check the number of files on a remote machine, you would need to put that script on the remote machine and execute it via check_nt, check_nrpe, or check_by_ssh.

Re: Trying to setup plugin check_numoffiles.sh

Posted: Tue Jul 26, 2016 10:12 am
by joshtate2001
The intention is to use the plugin to check the number of files in folder specified in my code above. This is a folder on a remote windows machine.
The remote machine (host) is running the NSClient++ agent on the remote windows host.

I saw some examples of how to use the nsclient cfg file to basically call the script from the agent somehow. It was very unclear.

So, I am trying to figure out what I need to do on the host side with the script itself (check_numoffiles.sh) and/or the ncclient cfg file.
Then I guess I would need to do something different with the service command for the object cfg file.

Re: Trying to setup plugin check_numoffiles.sh

Posted: Tue Jul 26, 2016 3:42 pm
by joshtate2001
How do I check the number of files in a folder using check_nt?

Re: Trying to setup plugin check_numoffiles.sh

Posted: Tue Jul 26, 2016 10:55 pm
by Box293
joshtate2001 wrote:The intention is to use the plugin to check the number of files in folder
There's no need to create any special scripts, NSClient++ has this functionality built in using check_nrpe (can't be done with check_nt).

Example
Check the amount of files in a folder (and sub-folders). Generate a warning if more that 500 files exist, critical if more than 1000 files exist.

Command:

Code: Select all

check_nrpe -H 192.168.142.1 -t 30 -c CheckFiles -a path='C:\\NO BACKUP' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=500 MaxCrit=1000

Output:
{12347 Files Found}, found files: 12347 > critical|'found files'=12347;500;1000
There's more examples here:
http://sites.box293.com/nagios/guides/c ... es-folders

Re: Trying to setup plugin check_numoffiles.sh

Posted: Wed Jul 27, 2016 11:11 am
by joshtate2001
Thanks for your help! I have done this code for my service, but I am getting a error on verifying the config in nagios.

Service Code:

Code: Select all

define service{
	use			doceserve-services
	host_name		doc-e-serve
	service_description	Fileage Verification of C:\Doceserve\Active
	check_command		check_nrpe -c CheckFiles -a path='C:\\WJTNagiosTest' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=500 MaxCrit=1000
	}	
I do not specify hostname or port because that is dfned in the Command Difinition:

Code: Select all

# 'check_nrpe' command definition
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}

Re: Trying to setup plugin check_numoffiles.sh

Posted: Wed Jul 27, 2016 11:30 am
by joshtate2001
So, based on my code in my command definition:

Code: Select all

# 'check_nrpe' command definition
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}
I changed my service code to this:

Code: Select all

define service{
	use			doceserve-services
	host_name		doc-e-serve
	service_description	Fileage Verification of C:\Doceserve\Active
	check_command		check_nrpe!CheckFiles!-a path='C:\\WJTNagiosTest' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=500 MaxCrit=1000
	}
The config passes verification in Nagios. However, I am now getting this error in nagios UI.
Exception processing request: Request command contained illegal metachars!

Re: Trying to setup plugin check_numoffiles.sh

Posted: Wed Jul 27, 2016 12:32 pm
by mcapra
There's a specific setting in NSClient to account for this:

Code: Select all

[/settings/NRPE/server]
allow nasty characters=true

[/settings/external scripts]
allow nasty characters=true
From:
http://docs.nsclient.org/faq/#nasty-metacharacters

Re: Trying to setup plugin check_numoffiles.sh

Posted: Wed Jul 27, 2016 1:00 pm
by joshtate2001
That got rid of the meta character issue. Now getting.
Unknown argument: -a
Service Code:

Code: Select all

define service{
	use			doceserve-services
	host_name		doc-e-serve
	service_description	Fileage Verification of C:\Doceserve\Active
	check_command		check_nrpe!CheckFiles!-a path='C:\\WJTNagiosTest' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=500 MaxCrit=1000
	}
Command Code:

Code: Select all

# 'check_nrpe' command definition
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}