check_ftp plugin is used to verify the status of your remote FTP server.
If you’ve installed Nagios from source, check_ftp command will be located in the /usr/local/nagios/libexec directory.
1. Basic check_ftp Command
Check whether FTP server is up and running.
As you see in the following output, it connects to two different server, one running vsFTPD and another running Pure-FTPd and both display Ok status.
# ./check_ftp -H 192.168.105.1 FTP OK - 0.004 second response time on port 21 [220 (vsFTPd 2.2.2)]|time=0.003841s;;;0.000000;10.000000 # ./check_ftp -H 192.168.105.2 FTP OK - 0.060 second response time on port 21 [220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 1 of 50 allowed. 220-Local time is now 12:46. Server port: 21. 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 15 minutes of inactivity.]|time=0.059512s;;;0.000000;10.000000
2. Hide the TCP socket Output
You can use -j option. j stands for jail.
When you use the jail option, the output from the TCP socket will be hidden.
As you see below, the Pure-FTPd server typically responds with lot of lines unwanted lines in the output. When you use -j option, all those unwanted lines in the output will not be displayed.
# ./check_ftp -H 192.168.105.2 -j FTP OK - 0.060 second response time on port 21|time=0.059816s;;;0.000000;10.000000
3. Use a Different Port
If your FTP is running on a different port, use -p port option. In the following example, we are checking the ftp server that is running on port 7798
# ./check_ftp -H 192.168.105.1 -p 7798 FTP OK - 0.004 second response time on port 7798 [220 (vsFTPd 2.2.2)]|time=0.003841s;;;0.000000;10.000000
4. Set Warning and Critical Limit
You can use -w option for warning limit, and -c option to set critical limit.
In the following example, we’ve set warning limit at 2 seconds, and critical limit at 5 seconds.
# ./check_ftp -H 192.168.105.1 -w 2 -c 5 FTP WARNING - 2.003 second response time on port 21 [220 (vsFTPd 2.2.2)]|time=0.002941s;0.002000;5.000000;0.000000;10.000000 # ./check_ftp -H 192.168.105.1 -w 2 -c 5 FTP CRITICAL - 5.003 second response time on port 21 [220 (vsFTPd 2.2.2)]|time=0.002886s;0.002000;0.001000;0.000000;10.000000
5. Specify an Expected String
You can use -e option and specify an expected string. In the following example, we are expecting “Pure-FTPd” as the expected string. If it finds that in the output, it will give OK message as shown below.
# ./check_ftp -H 192.168.105.2 -e "Pure-FTPd" FTP OK - 0.060 second response time on port 21 [220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
In the following example, we are expecting “vsFTPd” in the output, but it is not available, and this displays a WARNING message.
# ./check_ftp -H 192.168.105.2 -e "vsFTPd" FTP WARNING - Unexpected response from host/socket: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 1 of 50 allowed. 220-Local time is now 12:50. Server port: 21. 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 15 minutes of inactivity.|time=0.059237s;;;0.000000;10.000000
6. Check for IPv4 or IPv6
You can use only IPv4 connection for ftp checking using -4 option as shown below.
# ./check_ftp -H 192.168.105.1 -4 FTP OK - 0.003 second response time on port 21 [220 (vsFTPd 2.2.2)]|time=0.002641s;;;0.000000;10.000000
You can use only IPv6 connection for ftp checking using -6 option as shown below.
# ./check_ftp -H 192.168.105.1 -6 FTP CRITICAL - Invalid hostname, address or socket: 192.168.105.1