An Introduction to /stats by Ntd

 Level:4 (quite advanced)

(No scripting knowledge required, but talks about some un-newbie stuff like ircds, ports, etc.)

Introduction

/stats is a powerful command that lets you get a lot of very useful information about servers, but it is rather underused. One possible reason is that it's replies are often rather cryptic. While mIRC takes the /links output and renders it in a clear tree structure, /stats output simply fills your status window and is often little more than a stream of letter codes and numbers. However, take the trouble to learn a little bit about the command and it can be worth your while.

The Curse Of Deviation

As everyone who has used IRC for a fair length of time knows, a major problem at the moment is that there is probably not any network whose ircd matches the specification in RFC1459. All the 'big four' have ircds very different from that worthy but now outdated document, and the differences can be noticable when it comes to /stats. These differences are the worst kind: not new features, but the same commands and raws doing different things. For this reason, don't be surprised if things in this document don't do what I say they do, and for the same reason, any scripting from stats replies might want to use a few if ($network == clauses ;)

The Basics

The first thing to understand about /stats is that on its own it does nothing. You need to give it a letter saying which stats you want. According to the RFC, the following letters are available:

Letter  Output
cc:lines
hhub/leaf info
ii:lines
kk:lines
llinks
mcommands
oo:lines
yy:lines
uuptime

Now you'll see a lot of 'lines' in there. What are these? Well, the IRC server has certain lines of text in the configuration file which say which hosts are allowed to do certain things. When a host is added, it is on a new line in the conf file, hence it is said to be an i:line (or whatever kind of line it is). And here is what the lines mean. c means 'connection', and refers to what servers the server will try to connect to. c:lines come in pairs with N:lines which are those servers allowed to connect to it. i means 'invite' and refers to what clients are allowed to connect to it. k means 'kill' and refers to those clients who are banned from connecting. i and k are probably the most important to the average user, so more on them later. o means 'operator' and refers to those hosts from which a client can become an operator. Finally, y:lines define connection classes. Of the others in that list, l shows what servers are actually connected at the time (different from n which is what servers could connect), m returns supported /commands, u shows how long the server has been running and hub/leaf information is probably of little interest unless you are fascinated by network topology...

Other letters

Remember I warned you about different ircd's having different letters? Here we go.

First most of you who use nets with these features probably have heard of a G:Line, g for 'global', and these are like global k:lines - anyone from that unlucky host is banned from the entire network. These, incredibly enough, are visible from /stats g.

Here is a real handy trick for all those who want to impress people with their eleet expert knowledge of irc: a stats portscan. This is a good example of when /stats can actually be useful, because by seeing the amounts of traffic on each port you can see which one is quietest. Then you can connect to this port, and it will be faster. Tip: 6667 is basically guaranteed to be the busiest, slowest port. Do the cool thing and find a quieter one. To list ports, it is usually /stats p. However I seem to remember this varied on different nets. So it's worth remembering that /stats l also gives some port related info, such as send queue in bytes/messages, etc. You don't need to know which numbers mean what: just look for small numbers! :)

The 'command cosmos' tells me that undernet supports stats t, z, w, and (when in debug mode) r and x, all giving various statistics and information, such as memory usage. These are probably not the most useful things in the world, so I won't go into any more detail. If you want to see what you get - just try it!

IRCNet also supports Q:lines (quarantine), R:Lines (a bit like a K:line), S:lines (what services are allowed to connect), V:lines (restrictions on N:Lines based on things such as version), and even a few more which seem so esoteric that I shan't even list them. Now, as a general rule, for each type of line there will be a corresponding /stats to return that information. For example, /stats q. Does this work? I don't know, you'll have to try: thats the fun of /stats.

And as usual, I have referred only to the nets I use. I have no doubt that experienced dalnetters (if there is such thing) and efnetters will know of some other /stats supported on those networks.

What use is this?

Well, I gave one use above, in finding a fast port to connect to. There is of course another reason for this type of port query. Maybe you are firewalled from IRC because your irritating college or workplace blocks 6000-7000 ports to prevent you wasting time on IRC. Well, check what ports your favourite server supports and you may get a pleasant surprise. My regular server is also open on all manner of weird ports such as 1234, and I have also seen a server listen on port 31337 (some sort of kewl joke ;)). Connect to a port like that and you could evade a lame firewall, but when you get caught IRCing, don't tell them I told you how to! ;)

Using unusual ports can also help avoid ICMP nukes. If you have a copy of the infamous ICMP nuker CLICK.EXE that came with the infamous war script 7th Sphere (I won't ask why you have such a thing), then load it up. See next to "server" it says start at port 6660 and go through to port 6669? Well use a port outside this range and those nuke's wont get you unless the nuker changes this setting - and how many of the brain-dead lamers who thinks it's clever to nuke do you think are smart enough to change any of the default settings?

Another good use related to i and k:lines. How many times will I see people post to alt.irc.mirc and say "Help, I get this Unauthorized Connection message!" It truly is an FAQ and the answer is i:lines. Say a server is in Sweden (*.se). Usual practice with IRC servers is to allow connection from nearby places, so maybe it has i:lines for *.se, *.no, *.fi. (Sweden, Norway, Finland). Now you live in Holland and you connect to this Swedish server - and get disconnected, unauthorized connection. The reason is there is no *.nl i:line, you are better off looking for a *.nl irc server to use!

Do a /stats i and you will get your list of hosts which can connect. But wait a minute, you say, since you are not on that server, how can you /stats it in the first place? Welcome to the beauty of remote stats, where you can query servers other than your own. Just use /stats i irc.server.com or whatever. (NB: Undernet disabled many remote stats for bandwidth conservation reasons).

Credits

Not something I usually do because I usually write docs from my own head. But this time I really had to do some research, which came from the legendary RFC1459, the conf files that came with ircnet ircd2.10.2b4, and the 'IRC Command Cosmos' by Roar Nybo, which is an excellent and thorough guide to the more advanced and unknown features of irc, particularly ircu, available from irchelp. If you want to get a bit more detailed than this introduction, that is the file I suggest you look at!

So, thanks to those, and hopefully this was a good condensed version for the rest of you!

  -Ntd