How to Monitor FTP Server With Monitis?
How to Monitor FTP Server With Monitis?
Learn how to monitor the performance and security of your servers by using this freely available tool along with the open source tool JMeter.
Join the DZone community and get the full member experience.Join For Free
Container Monitoring and Management eBook: Read about the new realities of containerization.
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. The 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 an FTP server, it's necessary to regularly monitor it.
How to Monitor an 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 the downloaded files.
In this case, you can use Monitis JMeter monitoring. JMeter allows you create a script which will upload, download, and check any information in downloaded content during one test. Also, you will be able to do the test with a different quantity of users and tell them to run their tests several times during one check.
How to Create a 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 -> then click on "Thread Group."
Adding Thread Group in JMeter
After adding "Thread Group," you can configure the number of users and iterations. From "Thread Properties" you should set:
- Thread name.
- Number of Threads (quantity of users).
- Ramp-up Period ( the time period in which your test should be performed).
- Loop Count (quantity of iterations which you want to execute).
Thread Group Properties
In order to check the FTP server, you should add an FTP requests sampler in the thread group. For that, you should right-click on "Thread Group" → Add → Sampler → and then choose FTP Request.
Adding FTP Request
In order to download and upload a file, you should add 2 FTP requests - for download and upload functions respectively. Let's rename the FTP Requests with appropriate names: Check Download and Check Upload.
For configuring an upload request, you should add:
FTP Requests Examples
- Server name or IP.
- Port Number.
- Remote File (This will be the file name with which an uploaded file will be saved. The path for a new file should also be specified).
- Local File Content.
- In case of authentication, add a Username and Password.
FTP Request Fields for Upload Check
From the above screenshot, you can see that in the case of executing a Check Upload request, a .txt file will be uploaded into the "10.137.24.248" server with the name "FileForTest.txt" and "Hello !!!" as its content. We used port 21 which is the FTP default port and we also used a "put" method.
For configuring "Check Download," you should change the method to "get" and after executing this method, the file with the name "FileForTest.txt" from sever "10.137.24.248" will be downloaded.
FTP Request Fields for Download Check
You can add a "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 the "View Results Tree" listener and look at your test results.
Check Results in View Results Tree
As you can see, we have results for 1 user and 1 test cycle. Surely, it will be better to increase the quantity of both users and iterations until making sure that the script functions correctly. Now from the Result Tree, you can understand that the script is okay and you can add more users and iterations.
From the "View Results Tree" listener, you can see sampler results, namely, details on requests and responses. In case you need it, 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.
Adding Additional Assertions
If the test is finished and the requests results pass in the 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 your preferred location for saving and save your script.
Saving JMeter Script
Currently, JMeter 3.3 doesn't support SFTP for a secure connection. If you need to use the SFTP protocol you need to add "SSH Protocol Support" plugin from the JMeter Plugins Manager.
JMeter Plugin Manager
After adding "SSH Protocol Support" you will have "SSH SFTP" in your samplers list.
SSH Plugin in 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.
Published at DZone with permission of Levon Sukoyan , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.