Page 1 of 1

file size

Posted: Fri Nov 11, 2016 12:33 am
by gselvakumar
Hi Team,
Could you please help us with the below requirement.

Nagios alert needs to be setup for the following:

Time: 2:30 AM every Sunday
SFTP Address: xx.xx.xx.xx
SFTP file location: /PRD
FileName: xx_x__x.log
Event: If the file xx_x__x.log is not present in the location. OR the file size is 0 an alert need to be sent

Re: file size

Posted: Fri Nov 11, 2016 12:39 pm
by bwallace
All sorts of examples and combinations of checking for files/file sizes/patterns here:
http://sites.box293.com/nagios/guides/c ... es-folders

...find one that works for you and let us know if you have any questions on configuring the check.

Re: file size

Posted: Fri Nov 11, 2016 12:44 pm
by mcapra
I modified a plugin on the exchange:
https://exchange.nagios.org/directory/P ... 29/details

That can do this. You will need to install a few Perl modules first to get it working:

Code: Select all

cpan -i Net::SFTP::Foreign
cpan -i Net::FTPSSL
cpan -i IO::Pty
In action:

Code: Select all

[root@localhost libexec]# ./check_sftp_size.pl --host 192.168.67.105 --user root --password welcome123 --dir /prd --file Product_Colorway_Data.log --sftp
WARNING: Got file Product_Colorway_Data.log but it was empty!

# I add some content to the file

[root@localhost libexec]# ./check_sftp_size.pl --host 192.168.67.105 --user root --password hunter2 --dir /prd --file Product_Colorway_Data.log --sftp
Connected to 192.168.67.105, logged in as root, chdir'ed to /prd, downloaded Product_Colorway_Data.log

Re: file size

Posted: Mon Nov 14, 2016 6:50 am
by gselvakumar
Thanks mcapra and bwallace.

But to how to check file xx_xx_xx.log is not present in the location or the file size is 0 exactly at 3.00 am every Sunday.Could please help me with this requirement also.

Re: file size

Posted: Mon Nov 14, 2016 12:06 pm
by rkennedy
You would need to define a check period, something like this, and then assign it to that service.

Code: Select all

define timeperiod{
        timeperiod_name sun-3am
        alias           Sun 3am
        sunday          02:55-03:05
}
This would give it a 10 minute window to check the service. There isn't a way to tell it to check 'exactly' at 3:00 due to scheduling.