File Monitoring via nrpe (windows)

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
nms
Posts: 222
Joined: Wed Sep 28, 2016 9:35 am

File Monitoring via nrpe (windows)

Post by nms »

Hi all,

I have a folder in which files are placed on a daily basis, usually early morning.

I am trying to monitor if the last file has been placed in the past 24 hrs, i.e. if older then 24 hrs I raise an alert.
I am using the check_nrpe for this using the check_files script.

The format I'm trying to use is:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H am1-sha-app01-p_w-billing -t 30 -c check_files -a path="D:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= written > -24h' 'warn= count > 0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs'
But if a file is not placed (or I remove the last file for testing) I still get an ok.

Am I using the correct format for monitoring a file? The files placed are in CSV format as per attached.

Rgds
You do not have the required permissions to view the files attached to this post.
User avatar
Francesco
Posts: 124
Joined: Wed Oct 28, 2015 5:02 am
Location: /usr
Contact:

Re: File Monitoring via nrpe (windows)

Post by Francesco »

Ciao,
can you show us the nrpe.cfg of the windows server?

Di you try to execute the plugin locally on the remote server, in a dos window?

Ciao,
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: File Monitoring via nrpe (windows)

Post by lmiltchev »

Trying using 'filter= creation', and changing 'warn= count > 0' to 'warn= count = 0'.

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H am1-sha-app01-p_w-billing -t 30 -c check_files -a path="D:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= creation > -24h' 'warn= count = 0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs'
Now, you should get "OK" state if there is a newer than 24 hours file in the folder. If there is no new file, you would get a "WARNING".
Be sure to check out our Knowledgebase for helpful articles and solutions!
nms
Posts: 222
Joined: Wed Sep 28, 2016 9:35 am

Re: File Monitoring via nrpe (windows)

Post by nms »

Hi,

I tried to the filter from written to creation.

Code: Select all

[nagios@am1nms-nagiosxi ~]$ /usr/local/nagios/libexec/check_nrpe -H am1-sha-app01-p_w-billing -t 30 -c check_files -a path="D:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= creation > -24h' 'warn= count = 0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs' 
WARNING: Last MVNOAccountBalance File is older then 24Hrs|'count'=0;0;0
However, I still encounter the same problem. For this case, I think the count = 0 will make sense since that there were no files > 24hrs. so in that case hat should be count =0 -> OK.
But in any case when I removed a file to test the count was still 0.

Rgds,
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: File Monitoring via nrpe (windows)

Post by scottwilkerson »

What this is doing is counting the files that were create within the last 24 hours, and then warns if there are not any files that have been created in the last 24 hours.

Is this not what you were trying to achieve?
nms wrote:I am trying to monitor if the last file has been placed in the past 24 hrs, i.e. if older then 24 hrs I raise an alert.
I am using the check_nrpe for this using the check_files script.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
nms
Posts: 222
Joined: Wed Sep 28, 2016 9:35 am

Re: File Monitoring via nrpe (windows)

Post by nms »

Hi,

May I'm not getting it right. Assume we have these files (see attached) which are being created daily. As you can see the last is created which means less than 24 hrs. So this means that there should be no alarm and the count should be 1, not 0.

If I run the command with those files in place I get:

Code: Select all

[nagios@am1nms-nagiosxi ~]$ /usr/local/nagios/libexec/check_nrpe -H am1-sha-app01-p_w-billing -t 30 -c check_files -a path="D:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= creation > -24h' 'warn= count =0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs' 
WARNING: Last MVNOAccountBalance File is older then 24Hrs|'count'=0;0;0
I am getting a warning, of course since the count is 0. However, that should not be the case since the last file is created less than 24 hours ago?

What I am trying to achieve is to raise an alert if this particular last file time is older then 24hrs.

Rgds
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: File Monitoring via nrpe (windows)

Post by scottwilkerson »

Hmm, we may need to change creation to written, lets try the following:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H am1-sha-app01-p_w-billing -t 30 -c check_files -a path="D:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= written > -24h' 'warn= count =0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs'
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
nms
Posts: 222
Joined: Wed Sep 28, 2016 9:35 am

Re: File Monitoring via nrpe (windows)

Post by nms »

Hi Scott,

I have changed the filter to written and tried out 2 tests.

in the first test, the last file placed in the directory was less than 24 hrs, so when we run

Code: Select all

[nagios@am1nms-nagiosxi ~]$ /usr/local/nagios/libexec/check_nrpe -H am1-sha-app01-p_w-billing -t 30 -c check_files -a path="D:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= written > -24h' 'warn= count =0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs' 
WARNING: Last MVNOAccountBalance File is older then 24Hrs|'count'=0;0;0
The answer is correct since we have a count =0, The warning, of course, is there since the empty-state=warning .. I think!

For the second test, I removed the last file, which means the last file which I have is now older than 24hrs.
Running the same command produces the same result, the count remains 0.
if I'm getting it right, the count should have been greater than 0 now.

maybe the folder "path="D:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" " should be changes to specify the filenames? Maybe it's looking for the modification time of the directory, and hence that's why the 2nmd test fails?

can you specify a file name or regex in the filter?

Rgds,
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: File Monitoring via nrpe (windows)

Post by ssax »

Works on mine with NSClient++ v 0.5.2035:

One new file:

Code: Select all

[root@xid nagiosxi]# /usr/local/nagios/libexec/check_nrpe -H 192.168.5.232 -t 30 -c check_files -a path="C:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= written > -24h' 'warn= count =0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs'
OK: All 1 files are ok|'count'=1;0;0
No files:

Code: Select all

[root@xid nagiosxi]# /usr/local/nagios/libexec/check_nrpe -H 192.168.5.232 -t 30 -c check_files -a path="C:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= written > -24h' 'warn= count =0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs'
WARNING: Last MVNOAccountBalance File is older then 24Hrs|'count'=0;0;0
Old file:

Code: Select all

[root@xid nagiosxi]# /usr/local/nagios/libexec/check_nrpe -H 192.168.5.232 -t 30 -c check_files -a path="C:\\WS06\\CdrProcessing\\Reports\\VFI\\BalanceReportsFrom_eServ\\POSTFONE\\Sent\\" 'filter= written > -24h' 'warn= count =0' 'empty-state=warning' 'empty-syntax=${status}: Last MVNOAccountBalance File is older then 24Hrs'
WARNING: Last MVNOAccountBalance File is older then 24Hrs|'count'=0;0;0
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: File Monitoring via nrpe (windows)

Post by lmiltchev »

We tried a similar setup in house, and everything seems to be working as expected. Here's what I did:

1. I had two CSV files in C:\TEMP directory
example01.PNG
2. Here's the output of the command I ran from the CLI:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a path="C:\\TEMP\\" 'filter= written > -24h' 'warn= count = 0' 'empty-state=warning' 'empty-syntax=${status}: My CSV File is older then 24Hrs'
WARNING: My CSV File is older then 24Hrs|'count'=0;0;0
I got a WARNING as both files were older than 24 hours.

3. I modified one of the files, and made sure the timestamp changed.
example02.PNG
4. I reran my command:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a path="C:\\TEMP\\" 'filter= written > -24h' 'warn= count = 0' 'empty-state=warning' 'empty-syntax=${status}: My CSV File is older then 24Hrs'
OK: All 1 files are ok|'count'=1;0;0
I got an OK as one for the files were newer than 24 hours.

5. I copied a few new files to the C:\TEMP folder, and ran the check again:
example03.PNG
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a path="C:\\TEMP\\" 'filter= written > -24h' 'warn= count = 0' 'empty-state=warning' 'empty-syntax=${status}: My CSV File is older then 24Hrs'
OK: All 4 files are ok|'count'=4;0;0
The output was OK as there were files in the TEMP folder, newer than 24 hours. It said: "4 files" as there was one "modified" file, and 3 "new" files in the folder.

6. I removed the 4 "new" files, and the output changed to WARNING again (as the only file that was left was older than 24 hours).

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a path="C:\\TEMP\\" 'filter= written > -24h' 'warn= count = 0' 'empty-state=warning' 'empty-syntax=${status}: My CSV File is older then 24Hrs'
WARNING: My CSV File is older then 24Hrs|'count'=0;0;0
I am not sure if you are doing something else. It would help us if you actually showed screenshots of the timestamps of your files at the time you test your command from the CLI.
can you specify a file name or regex in the filter?
You could use something like this:

Code: Select all

pattern=*.txt
https://docs.nsclient.org/0.5.0/referen ... heck_files
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!
Locked