Archive for October, 2009

Geek T-Shirt Collection #18 – sick PWNAGE!

Monday, October 26th, 2009

Geekshirt #18 - Sick PWNAGE! - MyBloop.com (front)

After working with Fitim and the crew at MyBloop, them being avid Starcraft, Diablo, WOW, Warhammer and many other RPG style games, they instilled in me the phrase “To Pwn” or “Pwnage” whenever we did something difficult in terms of programming or linux hacking when working on MyBloop.com. It was a way to say that we’d be superior to other developers who had no clue about the shit we were pulling off on that bare-bones-cheap-custom-hardware-file-server-cluster-web-app of ours.

Geekshirt #18 - Sick PWNAGE! - MyBloop.com (back)

When something was over the top we’d say “Sick Pnwage”. If we’d be coding during the weekend we’d say “I’ll be Pwning this weekend”, and so on.

I liked the phrase so much that had to make a t-shirt to commemorate it for years to come.

See the Previous T-Shirt

See the Next T-Shirt

Book Attention Deficit Disorder

Wednesday, October 21st, 2009

After I started working from home, and not commuting I realized the best time I had to read every day was the subway ride to and back from work.

I guess it was sort of a guilty pleasure to sometimes wish for the subway train to not arrive so early so you could read a little more before you got to work.

Now, between work, marathon training and life, I barely have any time left to read and I sometimes feel guilty to take the time to read. Usually I do so right before I go to bed, and I can only keep my eyes open for maybe 10 minutes so I’m not progressing in any of these very much.

I guess public transit commuting wasn’t so bad after all.

What do you advise? Should I read one by one? take a whole weekend and do nothing but read? How do you fight sleepiness?

Quick N Dirty way to Map Commands to remote servers via ssh

Saturday, October 10th, 2009

You may be running several independent but similar servers at the same time and wasting time by executing commands in all of them one by one.

Wouldn’t it be nice to send a command to all of them at once? or to monitor all of them at once.

The following script can be used as a building block to more complex automation tasks for a small size set of servers. (If you’re managing over 50 servers, I’d probably consider looking a different way to arrange servers (map/reduce cluster), but if you’re doing something below that number this might suffice)

#!/usr/bin/python                                                                                                                                                                                                                                                      

#########################################################
# Author: Angel Leon (gubatron@gmail.com) - October 2009
#
# Invokes a command locally and invokes the same command
# in all machines under the specified username, servers
#
# Requirement: Have a public ssh_key for that user on all
# the other machines so you don't have to authenticate
# on all the other machines.
#########################################################
import sys
import os

# set the username that has access to all the machines here
user='safeuser'

# add all your server names here
servers=['server1.mydomain.com','server2.mydomain.com','server3.mydomain.com']

if __name__ == "__main__":
  if len(sys.argv) < 2:
    print "Usage: ssh_map_command "
    sys.exit(0)

  cmd= ' '.join(sys.argv[1:])

  #Execute locally first
  print cmd
  os.system(cmd)

  #Execute for all the servers in the list
  for server in servers:
    remote_cmd="ssh %s@%s %s" % (user,server,cmd)
    print remote_cmd
    os.system(remote_cmd)
    print

Save as ssh_map_command and chmod +x it.

Sample uses
Check the average load of all machines at once (then use output to mitigate high load issues)

$ ssh_map_command uptime

Send HUP signal to all your web servers (put it in an alias or other script… and that’s how you start building more complex scripts)

$ ssh_map_command ps aux | grep [l]ighttpd | kill -HUP `awk {'print $2'}`

Check if processes are alive, check memory usage on processes across different machines, grep remote all logs at once, svn up on all machines, rsync from one to many, hey, you can even tail -f and grep all the logs at once, you can go nuts with this thing. Depends on what you need to do.

Requirements

Security Advisory
Make sure only the desired user has read/write/execute access to it and keep your private ssh keys safe (preferably only read and execute for the owner, and no permissions whatsoever to anybody else chmod 500 ssh_mod_map), if possible change them as often as possible, for it may become a big security whole if an attacker can manage to write code on this script, specially if you have cronjobs invoking it. Your attacker would only need to change code here to mess up all of your machines.

Disclaimer and Call for Knowledge
Please, if someone knows of a standard way to map commands to multiple servers, please let me know in the comment section, in my case I needed a solution and I wrote a quick and dirty python script and tried to secure it as best as I could, by no means I’m saying that this is the best solution to mapping commands, in fact I believe it might be the least efficient way, however it works good enough for my personal needs.

Ubuntu/Debian Quick Reference: How To Change Your Server’s UTC Timezone on the command line

Saturday, October 10th, 2009

Just Type…
sudo dpkg-reconfigure tzdata

…and follow the instructions on screen.

The process should look something like the following:


Select your Region


Select a city on your time zone


You’re done.

Tip
You can always check the status of your configuration using
sudo debconf-show tzdata

You could for example map that command via ssh to several machines and grep for “*”, that way you could easily spot servers with wrong timezones very quickly.

Unboxing and PhotoReview of Macbook PRO 15-inch

Tuesday, October 6th, 2009

Click here to see and read the rest. Check out the descriptions and mouse over the images to learn the details.

Geek T-Shirt Collection #17 – error_reporting(E_STRICT)

Saturday, October 3rd, 2009

I made this one when I was at the peak of my PHP fever. It was an homage to perl’s “use strict”

See the previous T-Shirt

See the next T-Shirt