Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Friday, August 15, 2008

PoopTag = Social Defecation

(It's not as gross as it sounds!)

Everybody poops. Every U.S. president. Every Jonas Brother. Every Olympic athlete. Even Michael Phelps. Actually, at 12,000 calories a day, he poops a LOT!

And so while you're pooping, have you ever wondered who else is pooping at exactly the same time? Really? Me, too!

So with the help of some friends, I created PoopTag, a sort of game that strives to be both encouraging and enlightening. It's easy to play: you simply notify PoopTag whenever you poop. You do this by sending a direct message to the pooptag account on Twitter using your mobile device. PoopTag will then determine whether anyone else is pooping at that time. If they are, you will have successfully "tagged" them, and PoopTag will notify its followers of this happy event.

And in response to your direct message, whether you successfully tag anyone or not, you will receive a random pithy reply. That's the "encouraging and enlightening" part.

There are two modes of play: public and covert. You decide which way to play each time you poop.
  • Public (send more than one character):
    d pooptag This text will be broadcast to all PoopTaggers

  • Covert (send any single character):
    d pooptag !

Obviously, the public notification makes it easy for someone to tag you, though they must be pooping in order to do so.

Eventually, we'll publish statistics at pooptag.com, enabling services like Poop Cycle Compatibility Matching, prospective home-buyer bathroom sizing tools, and life-saving medical history to present to your doctor, among other things.

Come join the fun!

UPDATE 9/20/08: Changed covert pooping method from an empty message to one containing only punctuation due to Twitter no longer delivering blank direct messages.
UPDATE 10/13/08: Covert pooping now triggered by a message containing only a single character (letter, number, punctuation, whatever)

Saturday, August 09, 2008

Create

I'm big on creativity. You know, building stuff. Putting things where nothing was before. I think it's both the secret to happiness and the meaning of life. I think it's what humans are SUPPOSED TO DO.

Create. Re-create. Recreation. Play, especially at work.

I follow why the lucky stiff on Twitter. His tweets are usually funny and clever. And once in a while, he'll write something like this:

when you don't create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create.

Very cool.

Friday, May 11, 2007

Remote Monitoring with Ruby and sshfs

At work I've been doing some performance analysis as of late. Specifically, I've been combing JBoss server.log files recording the time it takes various transactions to complete. Admittedly, I'm fighting a little with Werner Heisenberg because configuring the app to produce the log messages on which I depend will affect performance, but my interest is in relative rather than overall performance, i.e. I'm looking for potential bottlenecks.

Still, I don't want to take up any more resources from the app server's CPU than absolutely necessary. The Ruby script that processes the log files obviously makes much use of regular expressions. Here's an example of a Request object from my script.

Request.new("Typical request") { |request|
request.expect /Processing Request/
request.expect /No existing Session found/
request.reject /ERROR/
request.reject /reaping required/
request.expect /Processing message took \d+ millis/
}

Here's an example of a line from the server.log:
2007-05-09 16:28:51,511 INFO  [UDPListener] (Thread-16) UDPListener thread running

The Ruby script organizes the log messages by thread id. If it finds matches for each expected regular expression in the correct order without finding any it should reject, it records the total time for the Request. When finished, it reports various statistics (average, mean, stddev, etc) for each type of Request it found in the log.

Ideally, I would run that script on a log after a particular load test was performed, but hey that's no fun! I'd rather see how the server is doing in realtime, monitoring its performance while it's running. Here comes sshfs to the rescue!

With sshfs, I can mount the file system of the app server on a remote machine running my Ruby script. The app server doesn't need Samba or NFS installed, only ssh, and what respectable app server wouldn't have sshd running?

With the server.log mounted via sshfs, far fewer CPU resources are taken up by the analysis script, no more than if you were "tailing the log" yourself while the app server was running.

Installing sshfs is very simple on modern Debian-based distros:
  $ sudo apt-get install sshfs

Depending on the distro, you may need to add your user to the 'fuse' group or modprobe fuse, or chmod /dev/fuse, or some other such minor detail, but once installed, remote, realtime log file analysis is a breeze:

$ sshfs appsrvr:/ /mnt/appsrvr
$ cd /mnt/appsrvr/usr/local/jboss/server/default/log
$ tail -f server.log | statistics.rb
So you use local CPU resources to parse a remote log file. Cool, huh?