Taking a closer look at the script it looks to me that the user files are never closed, only opened when the script wants to read the data, and after some days there are 1024 files open (the ulimit on this box) and no new files can be opened. My problem is that I have no big knowledge of TCL and don't know where and how I should close those files, so any help would be greatly appreciated[02:00] /glftpd/ftp-data/users/dude
[02:00] glftpd-traffic.tcl: couldn't open "/glftpd/ftp-data/users/dude": too many open files
Here's the script:
Code: Select all
# v-1.05 22 Feb 05 (21:06:58)
# Don't know who the original author is, but I'm releasing this
# out with a few fixes to get around looping into negatives above
# 2GB when reading k size. -Genocaust
# glftpd users directory
set glftpdusers "/glftpd/ftp-data/users"
# output themes
# variables:
# $traffick - traffic in kilobytes
# $trafficm - traffic in megabytes
# $trafficg - traffic in gigabytes
# $msgtag - i just prepend to the outputs to match my bot theme
set msgtag "\002Alcatraz\002 :: \[\002stats \002\]"
set gtoutput(all) {$msgtag \002${trafficg}\002GB have passed through Alcatraz.}
set gtoutput(month) {$msgtag While passing through Alcatraz, \002${trafficg}\002GB had an out of body experience this month.}
set gtoutput(wk) {$msgtag \002${trafficg}\002GB saw Elvis this week in Alcatraz.}
set gtoutput(day) {$msgtag Today \002${trafficg}\002GB all agreed that 'if the dick don't fit, you must acquit.'}
# trigger
set gtcommand "!traffic"
# usage is: trigger [day/wk/month/all] - if not period is specified the default will be used
set gtdefault "month"
#regular announces
bind time - "00 00 * * *" gtgltraffic:t
bind time - "00 02 * * *" gtgltraffic:t
bind time - "00 04 * * *" gtgltraffic:t
bind time - "00 06 * * *" gtgltraffic:t
bind time - "00 08 * * *" gtgltraffic:t
bind time - "00 10 * * *" gtgltraffic:t
bind time - "00 12 * * *" gtgltraffic:t
bind time - "00 14 * * *" gtgltraffic:t
bind time - "00 16 * * *" gtgltraffic:t
bind time - "00 18 * * *" gtgltraffic:t
bind time - "00 20 * * *" gtgltraffic:t
bind time - "00 22 * * *" gtgltraffic:t
proc gtgltraffic:t {min h d m y} {
gtgltraffic {} {} {} #Alcatraz {}
return 0
}
proc gtgltraffic {nick host hand chan arg} {
set monthup 0
set monthdn 0
global msgtag
if {[llength [split $arg]]==0} {
set period $::gtdefault
} else {
set period [lindex $arg 0]
}
if {![info exists ::gtoutput($period)]} {
puthelp "PRIVMSG $chan :usage: $::gtcommand \[day/wk/month/all\]"
return
}
foreach user [glob -nocomplain $::glftpdusers/*] {
putlog $user
if {[catch {open $user} fp]} {
putlog "glftpd-traffic.tcl: $fp :("
continue
}
set lines [split [read $fp] \n]
foreach line $lines {
if {[lindex [split $line] 0]=="[string toupper $period]UP"} {
putlog $line
foreach {files size time} [lrange [split $line] 1 end] {
if {$size==""} {continue}
incr monthup $size
}
} elseif {[lindex [split $line] 0]=="[string toupper $period]DN"} {
putlog $line
foreach {files size time} [lrange [split $line] 1 end] {
if {$size==""} {continue}
incr monthdn $size
}
}
}
}
set traffick [expr wide($monthdn) + wide($monthup)]
set trafficm [format %.1f [expr wide($traffick) /1024.0]]
set trafficg [format %.1f [expr wide($trafficm) /1024.0]]
puthelp "PRIVMSG $chan :[subst -nocommands $::gtoutput($period)]"
}
bind pub - $gtcommand gtgltraffic
putlog "glFTPD Traffic 1.05 loaded"