Archive for July, 2010

A Strategic Reason To Move Away From WASD

Ever since I started gaming when I was a kid, everyone used WASD for their primary movement controls. Back when I was a kid it made sense too. The keys are in the same layout as the arrow keys, but they allow you to have access to other keys around it (with the added bonus of not having to reach across the keyboard with your left hand). But by the time I got to college, WASD didn’t work for me anymore:

  • My hands grew and my fingers felt very cramped.
  • The W key seemed way too shifted to the left to be comfortable, resulting in my index and ring finger fighting for key space.
  • Pushing my hand so far left on the keyboard resulted in me having access to fewer keys easily.

I spent time thinking of a better keybinding layout. Moving my hand to the middle of the keyboard started to get uncomfortable, and my wrist started to curve in a way that made using an “arrow keys” layout impossible. Here’s what I wanted to accomplish:

  • More comfortable, natural keybinding layout for my hand.
  • A layout that also gave me access to more keys quickly.
  • The new keys that are available need to be used in a way that makes sense.
  • The layout needs to work across multiple genres of games so I am always using the same comfortable binding scheme.

While I was thinking of a new layout, I noticed my hand resting on certain keys of the keyboard, and it hit me. My new layout was EASF. The interesting thing is by putting my hand on these keys, a couple things happen naturally:

  • My pinky finger rests nicely on the shift key (used commonly for walk/run/use) and CTRL becomes easier to hit (which I use for Ventrilo).
  • My thumb rests nicely on the space bar (used commonly for jumping).
  • Instead of just having Q available to my index/ring finger, I now had W as well (I tend to use W for things like Flashlight, which are normally bound to F).
  • R for reload, and G for grenade are much easier to use, and exposes T and 5 as a new easy-access keys.
  • Instead of using C for duck/crouch, I can now use D, which is much closer to the rest of my movement keys.
  • Z, X, C, and V are easier to hit now that my hand isn’t cramped up and can be used for misc stuff (although I use V as push-to-talk in-game voice chat primarily).
  • TAB is still just as easy to hit except now I don’t have to raise my pinky off of shift to get to it.

I tried using RSDG (shifting one key to the right). It’s also pretty comfortable, but I find that hitting TAB becomes annoying, SHIFT is ok but sometimes my pinky hits Z, CTRL is too hard to quickly use, H doesn’t make sense for grenade and T doesn’t make sense for reload, and Q becomes difficult to hit making it useless.

Of course, you need to use what is right for you, but from a strategic standpoint, I found that moving away from WASD made using the keyboard so much easier and more comfortable. Maybe EASF isn’t for you, but I highly recommend experimenting and finding the best keybinding layout for your hand. I’ve been using this layout for 9 years and it hasn’t let me down yet. It’s also really fun to watch people try and play a game on my machine!

HAProxy: Gathering Stats Using `socat`

We use Zabbix to monitor our systems at work. It’s a great open source alternative. One of things I’ve been working on recently is auditing our monitoring system for defunct monitoring points, unmonitored services, and proper triggers and alerts based on our SLA requirements. HAProxy was one of those items.

There are standard monitoring points like PID changes, web interface availability, CPU/Memory usage, etc. But what about monitoring things like MAXCONN and CURCONNS? Turns out there’s a way to get this data from HAProxy using what they call a “stats socket.” This information isn’t found in the haproxy-en.txt file, but in the configuration.txt file. In my installation, it isn’t in /usr/share/doc/haproxy like everything else. I actually found this on the official website. Here’s the interesting bit:

stats socket [{uid | user} ] [{gid | group} ] [mode ]
[level ]

Creates a UNIX socket in stream mode at location . Any previously
existing socket will be backed up then replaced. Connections to this socket
will return various statistics outputs and even allow some commands to be
issued. Please consult section 9.2 “Unix Socket commands” for more details.

An optional “level” parameter can be specified to restrict the nature of
the commands that can be issued on the socket :
– “user” is the least privileged level ; only non-sensitive stats can be
read, and no change is allowed. It would make sense on systems where it
is not easy to restrict access to the socket.

– “operator” is the default level and fits most common uses. All data can
be read, and only non-sensible changes are permitted (eg: clear max
counters).

– “admin” should be used with care, as everything is permitted (eg: clear
all counters).

On platforms which support it, it is possible to restrict access to this
socket by specifying numerical IDs after “uid” and “gid”, or valid user and
group names after the “user” and “group” keywords. It is also possible to
restrict permissions on the socket by passing an octal value after the “mode”
keyword (same syntax as chmod). Depending on the platform, the permissions on
the socket will be inherited from the directory which hosts it, or from the
user the process is started with.

Simple enough. Edit your haproxy.cfg and add this into your “global” section:

global
        daemon
        maxconn 100
        quiet
        user haproxy
        group haproxy
        stats socket    /tmp/haproxy

Reload your HAProxy config and you should now see a socket setup in /tmp (note in the ls output that the “s” at the beginning of the permission set denotes the file type as a socket):

# ls -lah /tmp/haproxy
srwxr-xr-x 1 root root 0 2010-07-14 12:53 /tmp/haproxy
#

Now we can query HAProxy using this socket for some stats. A great way to do this is using socat. If you don’t have it installed, you can compile from source, or use the package management system for your OS (ex: “apt-get install socat” for Ubuntu).

To query for some stats, you can try the following commands:

# echo “show info” | socat unix-connect:/tmp/haproxy stdio
# echo “show stat” | socat unix-connect:/tmp/haproxy stdio
# echo “show errors” | socat unix-connect:/tmp/haproxy stdio
# echo “show sess” | socat unix-connect:/tmp/haproxy stdio

More information on interacting with HAProxy through the stats socket can be found in section “9.2. Unix Socket commands” of the configuration.txt file I linked to above (it’s the last section in the file).