SFTP

Powerful shell scripts – sftp

Description:

This plugin is a bash shell script that connects to an ftp server using ssh ftp protocol on port 22
to check if a certain file , specified through the path and filename, exists on the server and contains a specified number of text rows.

Current Version

1.0.0

Last Release Date

2012-03-20

Compatible With

  • Nagios 1.x
  • Nagios 2.x
  • Nagios 3.x
  • Nagios XI
  • Nagios Fusion

License

GPL


Project Files
Project Notes
The script then returns "OK" Nagios state if the file exists together with the number of rows it contains, while it returns "CRITICAL" state if the file does not exist or does not contain the specified number of rows. To accomplish the possibility that more than one versions of the same file exist in the path, filename date extension support is provided by specifying the date format to use. This is first release and it's a to-be-refined version! I plan to release a much more refined, complete and powerful version! Usage: The typical usage of such script is to check if a scheduled labels creation task has been executed correctly. Usually, upon creation, the labels are uploaded on an ftp server from which they can be downloaded remotely for printing, the ftp folder mantaining different version of labels generated on different dates (daily, weekly, monthly ...) so the check is able to possibly distinguish the newly created file from the older ones. Requirements: -the usual and powerful Bash shell environment -lftp : command line file transfer client program located in /usr/bin directory Examples: -we want to find out if "myfile.txt" containing 15 rows of text, is located in the /home/Vittorio directory of the SFTP host "myhost.mydomain". We'll assume that user Vittorio with a given password has got at least the read permission on the file and that there will be only one file named myfile.txt without any date extension (note the "none" value as the 6th argument). We will issue the script with the following arguments : #check_sftp_file.sh myhost.mydomain Vittorio /home/Vittorio myfile.txt none 15 -we want to find out if "labels20120302.txt" exists in the path /home/vmemmo directory of the SFTP host "host124.nationaldom". and contains 450 rows of text. We will assume that user "vmemmo" with the given password, has got at least read permission on the file "labels20120302.txt" We will issue the script with the following arguments (note the date format YYYYmmdd passed in the 6th argument): #check_sftp_file.sh host124.nationaldom vmemmo m12201phx /home/vmemmo labels %Y%m%d 450 -we want to find out if "lab10032011.cvs" exists in the /laboratory/mvictor directory of the SFTP host "server121.nationaldom" and finally that it contains 235 rows of text. We will assume that user "mvictor" with the given password, has got at least read permission on the file "lab10032011" We will issue the script with the following arguments: #check_sftp_file.sh server121.nationaldom mvictor n23312qiw /laboratory/mvictor lab.cvs %d%m%Y 235
Reviews (1) Add a Review
Just found it and was just what i needed
by aseques, October 31, 2017

I was looking for a script to check the connection to an sftp server, this script provides that an more, I just added some minor enhancements to make it more practical (in case you don't need to check the number of lines)



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4 (1)
Favorites
0
Views
75,769