What is FTP?
FTP is one of the standard protocols for file transfer between a client and server on a global network. The first description for FTP (File Transfer Protocol) was written by Abhay Bhushan and published on 16 April 1971. FTP can run in passive and active mode. FTP doesn’t encrypt its traffic. All traffic is in a basic text mode, e.g. commands, data, even username and password information can be read by any person who will be able to capture packets. This problem is common for many of protocols. Solution for this problem includes using the secure version of FTP and secure connections like SSH or VPN.
To ensure the availability, response time, security certificate expiration date and other performance details of business critical files and documents, served through FTP server, it’s necessary to regularly monitor it.
How to monitor FTP server?
If you simply need to check your FTP server availability you can use basic FTP Uptime monitoring. But what to do if you need more advanced monitoring? For instance, you have an FTP server with username and password authentication, and need to download /upload some file. Additionally, you want to then check something in downloaded files.
In this case you can use Monitis JMeter monitoring. JMeter allows you create a script which will upload, download, check any information in downloaded content during one test. Also you will be able to do the test with different quantity of users and tell them to run their tests several times during one check.
Create JMeter Script Step by Step
First of all, you need to add “Thread Group” in order to be able to test with multiple users in JMeter. After opening JMeter you should right click on “Test Plan” -> Add -> Threads -> press on “Thread Group”.
After adding “Thread Group” you can configure quantity of users and iterations. From “Thread Properties” you should set:
- Thread name
- Number of Threads (quantity of users)
- Ramp-up Period (time period in which your test should be done)
- Loop Count (quantity of iterations which you want to execute)
In order to check FTP server, you should add FTP requests sampler in thread group. For that you should right click on “Thread Group” → Add → Sampler → and then choose FTP Request.
In order to to download and upload a file you should add 2 FTP requests – for download and upload functions respectively. Let’s rename FTP Requests with appropriate names: Check Download and Check Upload.
For configuring upload request, you should add:
- Server name or IP
- Port Number
- Remote File (This will be the file name with which uploaded file will be saved. Path for new file also should be specified.)
- Local File Content:
In case of authentication: Username and Password.
From above screenshot you can see that in case of executing Check Upload request .txt file will be uploaded into “10.137.24.248” server with “FileForTest.txt” name and “Hello !!!” content. We used 21 port which is FTP default port and “put” method.
For configuring “Check Download” you should change method to “get” and after executing this method file “FileForTest.txt” name from “10.137.24.248” sever will be downloaded.
You can add “View Results Tree” listener for checking results. To fulfill that again right click on “Thread Group” and go to Add → Listener → View Results Tree.
After executing the script, you can click on “View Results Tree” listener and look at your test results.
As you can see, we have results for 1 user and 1 cycle of test. Surely, it will be better to increase the quantity of both users and iterations until making sure that the script functions correctly. Now from Result Tree you can understand that the script is okay and you can add more users and iterations.
From “View Results Tree” listener you can see sampler result, namely, details on request and response. In case of need, you can set up assertions for checking MD5Hex checksum or size of a downloaded file. Right-click on FTP request and go to Add → Assertion → choose the type of assertion.
If the test is finished and requests passed with OK results in View Results Tree, you can save the test on your local machine .
To save the test, go to File → Save Test Plan As → then choose location for saving and save your script.
Currently, JMeter 3.3 doesn’t support SFTP for secure connection. If you need to use SFTP protocol you need to add “SSH Protocol Support” plugin from JMeter Plugins Manager.
After adding “SSH Protocol Support” you will have “SSH SFTP” in your samplers list.
Congrats! You have already created “JMeter_demo.jmx” script on your local machine. Now you can execute it any time you need. For constant monitoring you would need a JMeter Monitor.
To avoid a possible abuse of the service, JMeter scripts, added by in-trial users, will be reviewed by Monitis Tech Support within 24 hours before they are allowed to run. If no threat detected, the script will be enabled from server side.