Page 1 of 2

check if windows folder exist

Posted: Fri Aug 24, 2018 8:00 am
by lpereira
Hello All:
I'm having a request to check if a specific Windows Folder has been modified. However i think is easier to check if the folder exist. If the Folder name has been modified, then it should alert as folder missing, which from our end is the same.

is there a way to get it done?

thanks!

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 9:16 am
by scottwilkerson
You can do this with NSClient and the NRPE module for it

Here is an example
https://support.nagios.com/kb/article/f ... der_exists

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 9:21 am
by lpereira
scottwilkerson wrote:You can do this with NSClient and the NRPE module for it

Here is an example
https://support.nagios.com/kb/article/f ... der_exists

great i can see the plugin.

Code: Select all

Nagios Plugins
Nagios Plugins comes with the check_file_age plugin, this will return a critical state if the file does not exist.

Command:

./check_file_age -f /var/log/cron
Output:

FILE_AGE OK: /var/log/cron is 163 seconds old and 18974 bytes  | age=163s;240;600 size=18974B;0;0;0
But how do i use the plugin in order to monitor the remote windows server? -H parameter does not work

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 9:27 am
by scottwilkerson
In the link I gave you , the command you want to look at is in the NSClient++ via check_nrpe section

Code: Select all

./check_nrpe -H 10.25.11.3 -c check_files -a path='C:\\your_folder_' 'warn= count < 1' 'crit= count < 1' top-syntax='${status}: ${count} files found ${problem_list}' 'empty-state=critical' show-all

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 9:31 am
by lpereira
scottwilkerson wrote:In the link I gave you , the command you want to look at is in the NSClient++ via check_nrpe section

Code: Select all

./check_nrpe -H 10.25.11.3 -c check_files -a path='C:\\your_folder_' 'warn= count < 1' 'crit= count < 1' top-syntax='${status}: ${count} files found ${problem_list}' 'empty-state=critical' show-all
i have tried that as well

Code: Select all

[root@nagios libexec]# ./check_nrpe -H SERVERIP -c check_files -a path=’C:\\Temp’ ’warn= count < 1’ ’crit= count < 1’ top-syntax=’${status}: ${count} files found ${problem_list}’ ’empty-state=critical’ show-all
-bash: 1’: No such file or directory
i got that error...

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 9:45 am
by scottwilkerson
Sorry that article has backticks instead of apostrophe

run this

Code: Select all

./check_nrpe -H SERVERIP -c check_files -a path='C:\\Temp' 'warn= count < 1' 'crit= count < 1' top-syntax='${status}: ${count} files found ${problem_list}' 'empty-state=critical' show-all
I will be editing the article to correct the issue

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 9:50 am
by lpereira
scottwilkerson wrote:Sorry that article has backticks instead of apostrophe

run this

Code: Select all

./check_nrpe -H SERVERIP -c check_files -a path='C:\\Temp' 'warn= count < 1' 'crit= count < 1' top-syntax='${status}: ${count} files found ${problem_list}' 'empty-state=critical' show-all
I will be editing the article to correct the issue
Thanks, but it seems that does not like it

Code: Select all

[root@nagios libexec]# ./check_nrpe -H SERVERIP -c check_files -a path='C:\\Temp' 'warn= count < 1' 'crit= count < 1' top-syntax='${status}: ${count} files found ${problem_list}' 'empty-state=critical' show-all -n
CHECK_NRPE: Invalid packet type received from server.

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 9:54 am
by scottwilkerson
can you share your nsclient ini file?

also what version are you using?

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 10:00 am
by lpereira
scottwilkerson wrote:can you share your nsclient ini file?

also what version are you using?
here is the version

Code: Select all

[root@nagios libexec]# /usr/local/nagios/bin/nrpe -V                                                                                         
NRPE - Nagios Remote Plugin Executor
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
Last Modified: 09-06-2013
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required

***************************************************************
** POSSIBLE SECURITY RISK - COMMAND ARGUMENTS ARE SUPPORTED! **
**      Read the NRPE SECURITY file for more information     **
***************************************************************

***************************************************************
** POSSIBLE SECURITY RISK - TCP WRAPPERS ARE NOT AVAILABLE!  **
**      Read the NRPE SECURITY file for more information     **
***************************************************************

Usage: nrpe [-n] -c <config_file> [-4|-6] <mode>

Options:
 -n            = Do not use SSL
 <config_file> = Name of config file to use
 -4            = use ipv4 only
 -6            = use ipv6 only
 <mode>        = One of the following operating modes:
   -i          =    Run as a service under inetd or xinetd
   -d          =    Run as a standalone daemon
   -d -s       =    Run as a subsystem under AIX

Notes:
This program is designed to process requests from the check_nrpe
plugin on the host(s) running Nagios.  It can run as a service
under inetd or xinetd (read the docs for info on this), or as a
standalone daemon. Once a request is received from an authorized
host, NRPE will execute the command/plugin (as defined in the
config file) and return the plugin output and return code to the
check_nrpe plugin.
attached is the nsclient (i have modified nagios IP data)

Re: check if windows folder exist

Posted: Fri Aug 24, 2018 10:38 am
by lmiltchev
Modify the following lines in the nsclient.ini so that they look like this:

Code: Select all

insecure = true
extended response = 0
and restart tne nsclient++ service.

Test your check by running:

Code: Select all

./check_nrpe -H SERVERIP -n -c check_files -a path='C:\\Temp' 'warn= count < 1' 'crit= count < 1' top-syntax='${status}: ${count} files found ${problem_list}' 'empty-state=critical' show-all
Let us know if this helped.