check if windows folder exist

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

check if windows folder exist

Post 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!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check if windows folder exist

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: check if windows folder exist

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check if windows folder exist

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: check if windows folder exist

Post 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...
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check if windows folder exist

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: check if windows folder exist

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check if windows folder exist

Post by scottwilkerson »

can you share your nsclient ini file?

also what version are you using?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
lpereira
Posts: 143
Joined: Thu Jul 27, 2017 4:23 pm

Re: check if windows folder exist

Post 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)
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check if windows folder exist

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked