GetSessionStatistic from ConnectionList-IDs

You can share your Lua Scripts with everybody here.

GetSessionStatistic from ConnectionList-IDs

Postby Broemmelhaus » Fri Mar 31, 2017 6:20 am

Hello,

I try to get informations out of the SessionStatistic-table. But I only want the informations of actually logged in users. Therefore I teke the ID's of the ConnectionsList.

The Lua-script works sometimes and sometimes it say "...attempt to index global 'SessStat' (a nil value)!" after printing some values. I do not know what is wrong with this. Here is the part of my script which makes the problem. Can someone help?

Code: Select all
local SessStat = {}
local sessid = 0

local strUserlist = c_GetConnectionsList('Domain')
for nr in pairs(strUserlist) do
    sessid = strUserlist[nr].id
    SessStat = c_GetSessionStatistic('Domain',sessid)
    print(SessStat.down_bytes..'\n')
end
Broemmelhaus
 
posts 5
 
joined Tue Nov 29, 2011 12:00 pm
Location: Bonn, Germany

Re: GetSessionStatistic from ConnectionList-IDs

Postby FTP » Thu Apr 27, 2017 11:32 am

Because if the session does not upload/download any files, the value "SessStat" will be "nil", so you need to add a judgement like:

Code: Select all
    SessStat = c_GetSessionStatistic('Domain',sessid)
    if SessStat ~= nil
        print(SessStat.down_bytes..'\n')
    end
FTP
Site Admin
 
posts 1518
 
joined Tue Sep 29, 2009 6:09 am


Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 1 guest