Page 1 of 2

Nagios FTP aged file monitor for WebMethods

Posted: Tue Jan 23, 2018 5:57 am
by rtsupport
Nagios XI 2014R2.7
OS= Unix

User Requirement -

Implement Nagios FTP aged file monitor for WebMethods
using provided ftp connection details, log onto each ftp server every 5 min, check for any files greater than 15 min and send alert to DL.

ftp site/host name: test.test.com
user: *****
Password: *****
check files in folder: /test_dir/12345/123

To make it work we have tried multiple plugin but using that script we are able to count the number of files in ftp directory but we need file older than 15 Mins which we are not able to get details as per requirement. I have attached script using which we are trying to fetch the details.

Re: Nagios FTP aged file monitor for WebMethods

Posted: Tue Jan 23, 2018 2:39 pm
by npolovenko
@rtsupport, Looks like you could add a warning and/or a critical threshold to your command. -w 10 -c 15 If you did that already please share with us the command definition and the service check definition.

Re: Nagios FTP aged file monitor for WebMethods

Posted: Wed Jan 24, 2018 6:00 am
by rtsupport
Just to recall -- our requirement is to find out file on FTP and if any file is there older than 15 mins then Nagios will send the Alert.

we are able to count the number of file are available on FTP folder. but facing issue while we are trying to get info for file have older than 15 mins.

with attached plugin in first note we are using below command to get the output.

/usr/local/nagios/libexec/check_ftp_edited.pl -H test.xerox.com -u test_mon -p '*****' -d / -f '*' -w 50 -c 100
OK: To_Syncreon changed -43 minutes ago

Wrong Result --- ( its not fetching the correct result as file was created yesterday but it is showing 43 Mins ago or sometime it was checking in wrong directory)

Re: Nagios FTP aged file monitor for WebMethods

Posted: Wed Jan 24, 2018 1:46 pm
by npolovenko
@rtsupport, The plugin has an error. Please change this line:

Code: Select all

# # Round the Result
 $mins = sprintf ("%.0f", $mins); 
to this:

Code: Select all

# # Round the Result
 $mins = sprintf ("%.0f", $mins1); 
That should fix it.

Re: Nagios FTP aged file monitor for WebMethods

Posted: Mon Jan 29, 2018 6:45 am
by rtsupport
Not working :(

still time is not correct, changes was done as per advise but still time is not correct. i have create another file "test4" a min ago but command out put is showing 690 mins.

Attached screen shot -
File created (Time in IST)
Command Output (Time in EST)

Re: Nagios FTP aged file monitor for WebMethods

Posted: Mon Jan 29, 2018 1:39 pm
by npolovenko
@rtsupport, I'd probably paste these variables in the plugin:

Code: Select all

print "t1 time the file was modified = $t1";
print "time now =  $now";
print "now - t1  =  $mins1";
print "mins  =  $mins";
Right before:

Code: Select all

$status = 3;

if (( $critical != 0 ) && ( $critical < $mins )) {
That way when you run the plugin you'll see some timestamps that are being used. Seems like $mins1 is the variable that represents a difference between the current time and the time the file was modified. But I suggest checking out these variables on your system to see what's going on.

Here's a time stamp converter: https://www.epochconverter.com/

Re: Nagios FTP aged file monitor for WebMethods

Posted: Tue Jan 30, 2018 5:31 am
by rtsupport
Done with suggested code, but result is still incorrect..

File was update 2018-01-30 05:27 EST
but command out is modified was 628 Mins ago which should be 1 or 2 Mins as modified.

[nagios@usa********** libexec]$ ./check_ftp_edited.pl -H *****xerox.com -u test -p '*******' -d / -f test4.txt -w 50 -c 100
t1 time the file was modified = 1517288400time now = 1517326099now - t1 = 628.316666666667mins = 628CRITICAL: test4.txt changed 628 minutes ago

Re: Nagios FTP aged file monitor for WebMethods

Posted: Tue Jan 30, 2018 10:40 am
by npolovenko
@rtsupport, So the timestamp on the file modified is 2018-01-30 05:27, which is the same as t1 variable.
However, your time now is way off:

Code: Select all

my $now = gmtime();
Can you run these two commands from the command line and show us the output, also please mention the actual time when you ran the commands:

Code: Select all

perl -MPOSIX -le'print strftime "%x %X", localtime time'
perl -MPOSIX -le'print strftime "%x %X", gmtime time'
This needs to be done on a local server that has the plugin. And please make sure that you installed:

Code: Select all

cpan Date::Parse;
PS: Do you have these servers in the same country and in the same timezone?

Re: Nagios FTP aged file monitor for WebMethods

Posted: Wed Jan 31, 2018 8:44 am
by rtsupport
Please see command output -- All time in EST

[nagios@***** libexec]$ date
Wed Jan 31 08:25:25 EST 2018
[nagios@***** libexec]$ perl -MPOSIX -le'print strftime "%x %X", localtime time'
01/31/2018 08:25:36 AM
[nagios@***** libexec]$ perl -MPOSIX -le'print strftime "%x %X", gmtime time'
01/31/2018 01:25:52 PM

> Plugin for Date::Parse; is installed without this plugin this command will not work. and for time zone, i am not sure this need to be verify with requester.

Re: Nagios FTP aged file monitor for WebMethods

Posted: Wed Jan 31, 2018 11:26 am
by dwhitfield
Did you get this off of our exchange? There's no author information in the plugin. Unfortunately, it's not a plugin we wrote, and although we have tried to give some hints, we are unable to provide full support for it.

If you feel this is a plugin we are missing in our suite, feel free to request it at https://github.com/nagios-plugins/nagio ... issues/new