View Single Post
  #8  
Old 22nd June 2011, 19:01
erosbk erosbk is offline
Senior Member
 
Join Date: Mar 2011
Posts: 337
Thanks: 49
Thanked 36 Times in 30 Posts
Default

Add ispconfig system table (multiuse to store values of different types, for different modules that could need it in a future)
- With this, you can save a variable value, needed to be updated from time to time:
- ( ftp_traffic, traffic_timestamp, "", 0, 1234512345 ) (instead of saving data to a file if needed, or saving a value

multiple times in differents columns as it was my original idea...)

sys_vars
* var_module (char)
* var_name (char)
* var_string (varchar)
* var_integer (bigint)
* var_timestamp (timestamp)

Add ftp_traffic table

ftp_traffic
* hostname
* ftp_user
* traffic_date
* traffic_type
* traffic_bytes

Basically, this should be the program (in pseudo-pseudo code :P)

If server = FTP server (where to obtain this from a slave??)

read last update from sys_vars.var_timestamp and save in lasttimestamp
read ftplogfile

while !eof(ftplogfile)

if ftplogfile.line.timestamp > lasttimestamp

updatearray[] = ftplogfile.line.values, hostname of ftplogfile.line.ftp_user
x = x + 1
endif

if x = 10
call addtraffic
x = 0
end if
end while

if x > 0
call addtraffic
end if


function addtraffic
begin transaction
if exists in ftp_traffic
update ftp_traffic (values and hostname)
else
insert ftp_traffic (values and hostname)
endif
update sys_vars.var_timestamp with updatearray[].timestamp
end transaction
end function

end if

I hope you understand my idea, sorry for my poor and limited english...
Reply With Quote