Hello,
I’m finding a way to export the list of users with uptime , total upload & download.
Like we have in the users tab.
I tried the report function but no luck.
And didn’t find anything with the cli.
Is it someting possible?
Hello,
I’m finding a way to export the list of users with uptime , total upload & download.
Like we have in the users tab.
I tried the report function but no luck.
And didn’t find anything with the cli.
Is it someting possible?
No luck in CLI or WinBox
There is also Webfig to be explored.
And even http:////um/user/#status , for per user webpages.
In those HTML sources, there could be a clue , like in the part ‘user.js’
Which contains things like …this, but probably needs quite some reverse engineering or lookup work to be usefull.
function loadStatusData() {
ajax.post('../api/getUser', null, function(responseText) {
try {
obj = JSON.parse(responseText); // XXX probably wont work if <= IE7
if (obj.success) {
var tableRows = "";
tableRows += "<tr><td>Username:</td><td>" + obj.data.username + "</td></tr>";
tableRows += "<tr><td>Max simultaneous sessions:</td><td>" + (obj.data.sharedUsers == 0 ? 'unlimited' : obj.data.sharedUsers) + "</td></tr>";
tableRows += "<tr><td>Currently active sessions:</td><td>" + obj.data.activeSess + "</td></tr>";
tableRows += "<tr><td>Total download:</td><td>" + obj.data.download + "</td></tr>";
tableRows += "<tr><td>Total upload:</td><td>" + obj.data.upload + "</td></tr>";
tableRows += "<tr><td>Total uptime:</td><td>" + obj.data.uptime + "</td></tr>";
document.getElementById("status-data").innerHTML = tableRows;
}
else {
processFailedResp(obj);
}
}
catch (e) {
alert("Unknown error.");
}
unblockGUI(); // Not 100% correct in this case
});
I think the users view is from TWO CLI commands:
/user-manager/user/print
/user-manager/user/monitor
So it’s a PITA/complex… But you store the “print as-value”, then :foreach over it and run monitor on each users to get the total-download, etc stats to add to the array from print. So something like this, although you’d need to adapt it for your use:
:foreach k,v in=[/user-manager/user/print detail as-value] do={
:local attrs ([/user-manager/user/monitor ($v->".id") once as-value], $v)
:put $attrs
}
.id=*1;active-sessions=0;active-sub-sessions=0;attributes=;attributes-details=;co
mment=;group=default;name=user1;otp-secret=;password=;shared-users=1;total-downlo
ad=0;total-upload=0;total-uptime=00:00:00
Thank you for the advices I’ll try to play and adapt for my needs.
the cool thing is with a script you can transform them into .csv