How to tweak the metrics for number of files?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
linearstack
Posts: 26
Joined: Tue Nov 07, 2017 7:35 pm

How to tweak the metrics for number of files?

Post by linearstack »

Hi,

I have a host with which folder path is attached.
I want to tweak that "folder path" that it will send an alert when certain number files in that path exceeds. eg: if number to files exceeds to 100 in that folder it gives an alert.
?? :roll:
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to tweak the metrics for number of files?

Post by scottwilkerson »

Folder Watch Wizard
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
linearstack
Posts: 26
Joined: Tue Nov 07, 2017 7:35 pm

Re: How to tweak the metrics for number of files?

Post by linearstack »

Tried using folder watch but getting the below error while running the command.
Is it a syntax error??
If I'm setting this command for "abc" server which has "abc_data (D:)" drive on it. And Folder it want to monitor is "D:\Test"

error message:
/usr/local/nagios/libexec/folder_watch.pl -D D:\Test -F '[^\0]+' -C 'ls -lA' -r -w 2 -c 4 -f
UNKNOWN ERROR - could not chdir to D:Test - No such file or directory
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to tweak the metrics for number of files?

Post by lmiltchev »

It seems like you are trying to monitor a Windows host. The "Folder Watch Wizard" is normally used for Linux hosts. You could run it either "locally" or "remotely" (via SSH).
example01.PNG
Having said that, there are some 3rd party plugins on the Nagios Exchange that can get the job done for you. Here's a list of search results, using "check files windows":

https://exchange.nagios.org/index.php?o ... %20windows

These are not an official nagios plugins, and not guaranteed to work on all systems, but we will do our best to help you out if you get stuck on something.

Please, review our documentation on managing plugins in Nagios XI here:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

It will show you how to find and test new plugins, and how to define new commands and services in Nagios XI.
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
linearstack
Posts: 26
Joined: Tue Nov 07, 2017 7:35 pm

Re: How to tweak the metrics for number of files?

Post by linearstack »

I did installed the required tool as suggested in link previously, but still I'm getting this error message:
"UNKNOWN ERROR - execution of ssh administrator@$HOSTADDRESS$ ls -l C:\Test -R resulted in an error 65280 -"
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to tweak the metrics for number of files?

Post by lmiltchev »

The link showed up a number of plugins - which one did you install? What is the actual check that you are running?
Be sure to check out our Knowledgebase for helpful articles and solutions!
linearstack
Posts: 26
Joined: Tue Nov 07, 2017 7:35 pm

Re: How to tweak the metrics for number of files?

Post by linearstack »

"check_files.pl" plugin is installed to get the alerts when threshold for number of files is breached in a folder.
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: How to tweak the metrics for number of files?

Post by lmiltchev »

I don't think you could use this plugin on a Windows machine. Try using this one instead:

https://exchange.nagios.org/directory/P ... in/details

1. Download the check_files.vbs and place it in the NSClient++ scripts directory (usually C:\Program Files\NSClient++\scripts).

2. Create a command in the nsclient.ini file under the [/settings/external scripts/scripts] section, for example:

Code: Select all

check_count = cscript.exe //T:30 //NoLogo scripts\check_files.vbs $ARG1$
3. Save, exit and restart the nsclient (nscp) service.

4. Test your command from the command line on the Nagios XI server as such:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <windows server ip address> -c check_count -a '<arguments>'
Examples:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_count -a '-p C:\TEMP -r -w 100 -c 200'
OK: 6 files were matched.|'count'=6

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_count -a '-p C:\TEMP -r -w 5 -c 10'
WARNING: 6 files were matched.|'count'=6

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_count -a '-p C:\TEMP -r -w 1 -c 2'
CRITICAL: 6 files were matched.|'count'=6
Here, I am specifying the path to my folder with '-p', and I am using '-r' for "recursive". As you can see, changing the warning and critical thresholds changes the message (output).

Here's the plugin's usage (help):

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_count -a '-h'
Check_Files - Nagios NRPE plugin for windows, ver. 2009.11.1
Copyright (C) 2009, Alex Simenduev

Usage: check_files.vbs -p <path> [-r] [-f <filter>] -w <warn> -c <crit> |'-h

Command-line'=0 'options:
-p,'=0 '--path'=0 '<path>'=0 ':'=0 'folder'=0 'path
-r,'=0 '--recursive'=0 ':'=0 'check'=0 'directories'=0 'recursively
-f,'=0 '--filter'=0 '<filter>'=0 ':'=0 'add'=0 'filter'=0 'to'=0 'files,'=0 'can'=0 'be'=0 'specifed'=0 'more'=0 'than'=0 'once
-w,'=0 '--warn'=0 '<warn>'=0 ':'=0 'set'=0 'WARNING'=0 'state
-c,'=0 '--crit'=0 '<crit>'=0 ':'=0 'set'=0 'CRITICAL'=0 'state
-h,'=0 '--help'=0 ':'=0 'print'=0 'this'=0 'help'=0 'message

Avaliable'=0 'filters:
'=0 'Size,'=0 'AgeCreated,'=0 'AgeAccessed,'=0 'AgeModified,'=0 'RegEx

Examples:
'=0 'check_files.vbs'=0 '-p'=0 'C:\Windows\Temp'=0 '-w'=0 '100'=0 '-c'=0 '200
'=0 'Count'=0 'files'=0 'in'=0 'C:\Windows\Temp,'=0 'return'=0 'WARNING'=0 'if'=0 'number'=0 'of
'=0 'files'=0 'more'=0 'than'=0 '100'=0 'and'=0 'CRITICAL'=0 'if'=0 'more'=0 'than'=0 '2
Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
linearstack
Posts: 26
Joined: Tue Nov 07, 2017 7:35 pm

Re: How to tweak the metrics for number of files?

Post by linearstack »

We are using wmi for monitoring and authentication and have not setup NSCA/ NSclient.
Can suggest a wmi plugin to perform this??
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to tweak the metrics for number of files?

Post by scottwilkerson »

linearstack wrote:We are using wmi for monitoring and authentication and have not setup NSCA/ NSclient.
Can suggest a wmi plugin to perform this??
Unfortunately WMI cannot run custom plugins
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked