This tutorial will implement a JSS process trigger that maintains user statistics, such as number of uploads/downloads, logins, total bytes uploaded, etc.. It will be an event-handler that writes to your chosen data-store, e.g. JSON DB, embedded database, Excel spreadsheet.
Now let’s see how to set it up.
In Windows, create the folder: C:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Stats.
Create a Virtual folder under this.
Enable the 'Download files' and 'Upload files' permissions under 'Folder Properties' for 'All users'.
Open the Events panel in the CompleteFTP Manager, then add the new process trigger, and set the name to Record user stats. After this, choose the Log in event, select JSS script as the script type and paste the following script into the script field:
var db = new JsonDB('/Stats');
var userStatRef = '/Stats/User/logins';
var userInfo
try {
userInfo = db.read(userStatRef);
} catch (e) {
userInfo = {
loginCount: 0
};
}
userInfo.loginCount++;
userInfo.lastLogin = new Date();
db.write(userStatRef, userInfo);
Click on 'Apply changes'.
Now check to see what happens when you login with Filezilla and upload a file.
If you look in the folder C:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Stats, there should be a new folder with the name of the login user and it should include a json file which has the following content:
{
"loginCount": 1,
"lastLogin": "2020-04-21T07:18:48.771Z"
}