file size

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
gselvakumar
Posts: 96
Joined: Wed Mar 02, 2016 4:52 am

file size

Post 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
Last edited by gselvakumar on Tue Nov 15, 2016 12:46 am, edited 1 time in total.
Thanks & Regards,
Gomathyshankar Selvakumar
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: file size

Post 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.
Be sure to check out the Knowledgebase for helpful articles and solutions!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: file size

Post 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
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
https://www.mcapra.com/
gselvakumar
Posts: 96
Joined: Wed Mar 02, 2016 4:52 am

Re: file size

Post 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.
Last edited by gselvakumar on Tue Nov 15, 2016 11:19 pm, edited 1 time in total.
Thanks & Regards,
Gomathyshankar Selvakumar
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: file size

Post 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.
Former Nagios Employee
Locked