Geek T-Shirt Collection #18 – sick PWNAGE!

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

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

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)

[code lang=”python”]
#!/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 <cmd>"
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
[/code]

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)
[code lang=”shell”]$ ssh_map_command uptime[/code]

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)
[code lang=”shell”]$ ssh_map_command ps aux | grep [l]ighttpd | kill -HUP `awk {‘print $2’}`[/code]

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

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.

Why I couldn’t go back once I had a Mac

Whenever I try to explain why I’m now a Mac user and why I certainly don’t intend to buy anything different than a Mac (unless something really superior comes along) and even though you could probably get a super duper machine with cheaper parts, I always say that it’s all in the details, and they’re so many that I can’t really answer people which are.

The purpose of this post, is to keep track of those “a-ha” details as I come across them. I’ll update this post as more details come along on my day to day.

  • The Power Adapter of the Mac is magnetically shielded. You can put it on top of your computer while it’s still on and you won’t be afraid of loosing data. Not IBM’s Thinkpad’s power adapters are magnetically shielded
  • The Ethernet port on the Macbook PRO makes regular ethernet cables work like Cross-over ethernet cables. This really comes in handy if you have another computer next to you and there’s not an ethernet switch nearby. You can just connect directly to that machine, share your internet, transfer files, no need to ask anybody for a cross over cable. This has been this way for years (at least since 2006), I’m not sure if HP or other laptops have these super duper ethernet cards in them.
  • Back-lit keyboard. A blessing when coding in the darkness for those of us that sometimes need to look down for a special key. Oh and it will light up when it’s actually dark, freaking awesome.
  • Multi touch touchpad (way before many other laptops started implementing it). Double finger tap for right click? can’t live without it
  • Awesome battery life, and this is a pretty known fact about macbooks
  • I haven’t had my OS crash in … I can’t remember last time it crashed fully
  • Very quiet fan
  • The power adapter connector has that little magnet, people can trip over it and it won’t pull your laptop to the floor

  • The power adapter is modular, basically you can decide whether or not to carry with you a long ass cable or keep the adapter with the smaller patch cord that goes to your computer. Also you can switch it’s connector to the European style connector which comes with the computer. It seems apple knows its user base might travel abroad sometime

  • The power adapter has these two ears which can open and close. Their purpose is to let you wrap the thinner cable that goes to the computer. It’s great if you don’t want to have too much cable laying around or when you’re on the go and you need to wrap up things inside your bag. Kudos to the designers of the Power Adapter

  • As for the OS goes, I consider it a Linux where everything works right off
  • In Mac OSX everything just works as expected or better. Some good examples of things that work better than in other OSes are Wireless configuration, Internet Sharing, Multiple Display configuration is amazingly intuitive to set up
  • My last Macbook PRO I’ve been using it for almost 3 years and there’s no real need to get a new one, it’s still pretty fast after 2 major Mac OSX upgrades
  • The Sleep and Wake up functionality actually work, I can’t say the same for my Alienware and Vista, where sometimes it will never wake up, or it won’t really be sleeping and it’ll get all hot and kill the battery
  • If you ever open the Macbook, it’s a like a “work of art” inside. The way they’ve arranged everything, changing a hardrive or the keyboard is very easy and quite fun
  • The native tool for screen shots is really convenient, not only for all the different ways in which you can snap your screen, but it’s also a nice pixel measuring tool for web developers and graphic designers
  • Having a console, which comes with all the standard linux tool makes you remember windows and it’s cmd.exe and laugh about how arcaic it is
  • Being able to have the Automator to Visually Script things like Resizing a Bunch of Pictures and copying them somewhere else once you’ve downloaded big resolution images from your camera and you want to upload them to flickr… priceless
  • /Applications/Utilities/Console.app – a debugging blessing to find out why things might be going wrong with a specific process. I should probably not brag about the software since that’s getting into Mac OSX realm and that’s a whole different subject of why you can’t go back, again Linux that works right off, or Linux for Dummies.
  • Pressing Space bar over files on the Finder brings that super fast preview for Images, PDFs, Videos and even audio files
  • Being able to Customize the Finder adding and removing buttons to simplify or specialize it (equivalent of Windows Explorer)
  • Burning CD/DVDs is amazingly simple, no need for 3rd party software
  • Typing on a Mac keyboard is addicting, feels really good on the finger tips, the sound of it is music to my ears
  • No more viruses to fear, or antiviruses to slow you down

[buzz href=”http://www.google.com/buzz/gubatron2/gmt5cXWcr9P/Why-I-couldnt-go-back-once-I-had-a-Mac-http-www” liked=”25″]