Check Number Files in a directory

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.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Check Number Files in a directory

Post by cocoyanouck »

Hi everybody,

Firstly, sorry for my english but i'm a french user ...
I hope this is the good emplacement to write my problem :

I just installed Nagios 4.1.1 on a debian 8 Jessie. I don't really use Linux daily, and I need to migrate "nagios on our windows server to this nagios server.
I delete the old nsclient++ on windows server and install the latest 0.4.4.19

The installation and configuration are OK, but i'm blocked about monitoring "Check number files in a directory".
Indeed, I want to supervise a directory and count file on this directory in a windows server.


On nagios (debian), in command.cfg i' wrote :

define command {
command_name CheckNumberFiles
command_line $USER1$/check_nrpe §H $HOSTADDRESS$ §c $ARG1$ §a $ARG2$
}

In windows.cfg :

define service {
use generic-service
host_name name of my windows server
service_description Number of files on directory XXX
check_commande CheckNumberFiles!check_files!/path:C:\\DIRECTORY\\OTHER DIRECTORY" /searchdepth:1 /selage:ignore /warning:5 /critical:10
}

On my web interface, i've an error concerning this service :
Number of files on Request
UNKNOWN 08-04-2016 13:44:06 0d 2h 2m 18s 3/3 Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).


So I think my problem is on my windows server.

I suppose check_nrpe is OK because i use it with another service and it's OK (checkMEM).
But maybe the script check_files or the nsclient.ini is not ok... ?

Anyone help me please ?

Best Regards,
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Check Number Files in a directory

Post by rkennedy »

Take a look at your nsclient.ini, and look for the [/settings/NRPE/server] section. under it, add or modify these two variables -

Code: Select all

; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = 1

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = 1
They may already exist in your config, and if they do just change the 0's to 1's. Then, restart the NSClient++ service, and the check should be working. If not, please post your NSClient++ configuration for us to look at.
Former Nagios Employee
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Check Number Files in a directory

Post by cocoyanouck »

Thanks a lot for fast reply !!!

Indeed, I'd add (or verify) this lines in nsclient.ini on all windows server. Moreover, they are at 1.

So, i copy the content of this file :

Code: Select all

# If you want to fill this file with all avalible options run the following command:
#   nscp settings --generate --add-defaults --load-all
# If you want to activate a module and bring in all its options use:
#   nscp settings --activate-module <MODULE NAME> --add-defaults
# For details run: nscp settings --help

; Undocumented section
[/settings/default]

; Undocumented key
password = mypassword XXX

; Undocumented key
allowed hosts = nagios-debian

; Undocumented section
[/settings/NRPE/server]

port=5666

allow_arguments = 1

allow_nasty_meta_chars = 1

; Undocumented key
verify mode = none

; Undocumented key
insecure = true

[/settings/external scripts]
allow arguments = 1

allow_nasty_meta_chars = 1

; Undocumented section
[/modules]

NRPEListener.dll                 #I've add ths lines recently to test if it's better because in older server "nagios" on windows i saw this lines on nsc.ini ... but it doesn't work.
NSClientListener.dll
CheckWMI.dll
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
CheckEventLog.dll
CheckHelpers.dll
CheckSystem.dll
SysTray.dll
CheckWMI.dll
CheckNSCP.dll
CheckExternalScripts.dll
NRPEClient.dll
CheckTaskSched.dll                        

; Undocumented key
CheckExternalScripts = 1

; Undocumented key
CheckHelpers = 1

; Undocumented key
CheckEventLog = 1

; Undocumented key
CheckNSCP = 1

; Undocumented key
CheckDisk = 1

; Undocumented key
CheckSystem = 1

; Undocumented key
NSClientServer = 1

; Undocumented key
NRPEServer = 1

[crash]
; Archive crash dump files if a crash is detected
;archive=1

; Submit crash reports to a crash report server (this overrrides archive)
;submit=0

; Restart service if a crash is detected
restart=1

EDIT : i check once again your reply and i notice that i wrote "allow_nasty_meta_chars = 1" or you tell me that it's "allow_nasty_chars = 1".
Maybe this is that ?
Last edited by tmcdonald on Fri Apr 08, 2016 12:06 pm, edited 1 time in total.
Reason: Please use [code][/code] tags around long output
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Check Number Files in a directory

Post by lmiltchev »

I am running NSClient++ v. 0.4.4.15, and in the nsclient.ini file I have:

Code: Select all

allow nasty characters = 1
According to the NSClient++ "stable (0.4.4)" documentation, the correct syntax is

Code: Select all

allow nasty characters = true
example01.PNG
http://docs.nsclient.org/0.4.4/faq/index.html

You can use "true" or "1" - both should work, but I don't think underscores ("allow_nasty_meta_chars") will work with this version of NSClient++.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Check Number Files in a directory

Post by cocoyanouck »

Thanks, I'll try tomorrow and tell you if it's working.

Good evening,
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Check Number Files in a directory

Post by hsmith »

Sounds good, let us know.
Former Nagios Employee.
me.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Check Number Files in a directory

Post by cocoyanouck »

Hi,

I've modified the following lines and it's better :
allow nasty characters = true
allow nasty characters = 1

But still not working => Invalid command line: unrecognised option '/path:C:GESTIONREQUEST'

So I saw again the example of nsclient into check_files.vbs :

check_command check_nrpe_external!check_files!/path:"d:\\journal" /searchdepth:1 /selage:ignore /warning:30 /critical:40
' give alarm if there are more than 30 files under d:\journal

And in mi windows.cfg :

check_command check_nrpe!check_files!/path:"C:\\GESTION\\REQUEST\\" /searchdepth:1 /selage:ignore /warning:5 /critical:10

Thanks by advance.
Last edited by cocoyanouck on Mon Apr 11, 2016 2:10 pm, edited 1 time in total.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Check Number Files in a directory

Post by hsmith »

Can you try the check from the command line instead of in XI? Post the output of running it here.
Former Nagios Employee.
me.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: Check Number Files in a directory

Post by cocoyanouck »

I need to install the demo of Nagios XI in another VM in order to try the command, it's exact ?
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Check Number Files in a directory

Post by hsmith »

Do you have terminal access to your current Nagios XI server?
Former Nagios Employee.
me.
Locked