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
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.