Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Powerful shell scripts - sftp
1.0.0
2012-03-20
- Nagios 1.x
- Nagios 2.x
- Nagios 3.x
- Nagios XI
- Nagios Fusion
GPL
75763
File | Description |
---|---|
check_sftp_file.sh | check_sftp_file.sh |
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
to check if a certain file , specified through the path and filename, exists on the server and contains a specified number of text rows.
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
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
-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)
byaseques, October 17, 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)