Guide

Summary: A leech killer that kills users and leeches (not mod+) who have been on the stated server or all servers longer than a configured time setting (default 15 minutes) who are sharing less than a stated number of files and are not in a chat room. From quietly counting to actually killing the leeches, there are several levels. When set to actually kill the leeches, the script will only kill a configured amount (default 30) at a time, reason is explained later.

Basically put the script somewhere in your path and load it into teknap, I put a load ~/.TekNap/scripts/leechkill in my ~/.teknaprc for this, but your installation might differ slightly, and if you're on Windows you'll just have to give it a shot.

You'll want to look at the source, and maybe edit a few things. Of the things you'll possibly want to change are the minonlinetimetmp, killmaxtmp and leechlog variables near the top of the script. By the way, in case you're wondering, I run a *lot* of teknap scripts so I make my variables pretty lengthy and somewhat descriptive to keep them from possibly interacting, no, please don't accuse me of knowing LISP. I don't. Honest.

minonlinetmp is the minimum number of minutes the user has to have been on to be considered. 15 is a reasonable number, I wouldn't suggest making it lower than 5.

killmaxtmp is the maximum number of users who would be killed, the rest are still counted and reported, however. This is for two reasons; killing lots of users at once will lag the servers as users log back in, and just in case something goes wrong with the script, only killmaxtmp number of users will be killed. gusers sometimes doesn't do the right thing, maybe a TekNap bug, not sure.. If the number of leeches exceeds the maximum kill number, at the end of the report you will be told how many were killed, how many remained, and the total leeches found. This way you have an idea how often you need to run the script, or perhaps raise the maxkilltmp to a higher value. I don't suggest higher than 100, 30 is on the low side but probably good to start out with.

leechlog is a path to a file to write leech client statistics to. Nothing to write a paper from here, just basic tracking of how many times we see a client that matches our leech critera. Make sure it's a valid path, you can write to it, etc.. In Linux I put ~/.TekNap/leechstats.log. If you don't provide a valid path, it won't save the stats between sessions.

leechusers is a path to a file to write some general statistics, total user count on server, files shared, library size, number of leeches killed, and total number of leeches on the system. The idea is to pull the information into something else, such as mrtg.

skipserver is a space-separated list of servers you do NOT want to kill people off of. For instance, a vip-type server, a private server, or maybe a server that the admin doesn't like getting users killed off of their server. Put the alias of the server in the list.

Now, there are some simple examples build into the program when you don't give it enough or proper arguments, but I'll go over examples here too.

Your basic syntax is as such:

/leechkill server minfiles level

server means a specific server, or you can put * for all servers.
minfiles is the minimum number of files to act on. 0 for 0 files, 15, etc.
level is the 'intensity' of the kill. Client statistics are gathered during level 2 and 3, but not during 0 or 1, you can consider the first two levels simply informative. Level 2 messages all users meeting the leech criteria, where level 3 kills all users up to the maxkill setting, for reasons mentioned above. And if there are remaining users, the script will tell you when it's finished how many it killed and how many remain.

Levels 0, 1, and 2 begin immediately. However, level 3 is on a 10 second delay in which you can run /leechkill again (any arguments) and it will cancel the script before it does any killing. After the script has started, the only way to abort would be to exit the client, so be sure you know what you're doing. Regardless, referring to the maxkill variable again, you'll only be killing a certain number of users regardless, so it's pretty safe.

There is also a /leechstat alias and a !leechstat message hook so you can view leech client statistics. /leechstat would be something you'd run yourself, and if you give it an option, example /leechstat 50 it shows only the clients with 50 or more hits. 15 is the default limit. And for !relinkstats, another user would message you with this, again with optional limit number, and it would message the user back with the information.

Finally, some examples:
(* All up to the maximum number configured.)

Also, leechkill can be done periodically, automatically. /leechtime mins server minfiles level will run it every mins minutes. The default is to repeat for one full day. To cancel the timer, run /leechtime again. The minimum time is 5 minutes.

If you use the script, do me a favor and let me know!

Feature list

Todo

Known Bugs

Change Log