Using Ruby for System Administration

What is Sytem Administration?

System Administration is a specialization in the I.T industry. These are people who handle the “dirty stuff.” Some call them janitors while some call them “gods.” Regardless of these perceptions, I think they play a very important role in the industry. They are not doing low-level stuff for sure. They do not care about cross-browser compatibility or making that wretched star blink in flash but they handle things that could probably matter more than you could imagine like working with enterprise data, network monitoring and handling server security. Of course, in small consulting-type companies, they are not even sought.

I am not a system admin but have performed some system admin tasks which still does not make me a system admin. Setting up a virtual private server and reading a manual is not system administration. Knowing UNIX systems and networking by heart makes up a system administrator. I do not think University education could even make you a system administrator.

Certain developers especially those nomadic creatures like myself are already making efforts in trying to understand System Administration inside-out. I am reading a very interesting book called Practical Ruby for System Administration by André Ben Hamou. It looks pretty daunting so far. Of the books I have read on Ruby, it has the most interesting introduction to Ruby. Check it out.

Where Art Thou System Admin Jobs?

“Freelancing” dissolves specialization. They look for all-around types who can do troubleshooting. And unfortunately, it is assumed to be “part of the package.” This is why the wiser men and women opt for a stable job. Or a “career.” (As a programmer-turned-barber because cutting hair in certain countries pays more). “Nil customers”, they get paid.

Haven’t looked at statistics but I can tell that with the state of the world’s economy now, they are forgetting about specialization and hiring less.

They are no longer looking for developers now. They are looking for rock stars a-la Rick Ellis. DHH is not a real rock star but maybe he can sing.

Using Whenever Gem To Automate Tasks

First checkout the Railscast tutorial.

Download this shell script for backing up a mysql database. It works for multiple domains and multiple projects.

Upload on your server. On a path like ~/scripts

# on schedule.rb
  every 24.hours do
     command "~/scripts/./backup.sh"
  end

And that’s just it. Daily backups may not be right for certain projects. Perhaps every 12 hours is more sensible than every 24 hours. Retrieving the latest files from your production server and retrieving latest database files is something which capistrano sensibly handles but that’s something better googled than blogged about.

Other Useful Plugins for System Administration

For making Unix data human-friendly, there are several ruby gems which can be used not just by system admins. Even, ordinary developers like myself can use them for practical tasks.

Gruff

A Graphing Library, a project to make beautiful graphs with Ruby.

Fastercsv

Another gem for exporting data to csv. Practically, any data regardless of whether it’s ActiveRecord/database data or not, it should work.

There are other plugins and ruby gems on github which you could use to export data on several file formats. Some of them however only work for rails.