views:

2380

answers:

12

I am starting a new project to provide monitoring and control services for a number of unix (Linux and FreeBSD) servers (think munin, monit, mrtg, etc). The reason I'm not considering using an already existing monitoring solution is that I need to do checks for custom APIs (like post a specific HTTP request and parse the answer body for a status or send a dummy request with a proprietary protocol)

Until now I've done most of my development in Perl, but I'm willing to consider other languages which I'm familiar with: Lua, Python and Ruby (in alphabetical order).

Which one would be the best match for system automation?

+14  A: 

This is not answering your question, but I think that with many of the existing solutions you actually can leverage all the monitoring logic (which is not trivial) and code specific tests for proprietary protocols or for specific answers for HTTP requests.

At least I'm certain that you can do it in Nagios, using its plugin system.

As for answering your question, any language is perfectly capable. I think Perl is a great choice in your case, because you are already familiar with it and it has a boatload of libraries related to systems administration (and even Nagios itself!). I think that especially Lua would suffer from lack of libraries you'd end up missing in the development of such a system.

Vinko Vrsalovic
+1 for Nagios. Most of our Nagios service monitors are custom plugins written in Python, there's little more to it than a return code and some lines of text.
Colonel Sponsz
Latest plugin API developer guidelines: http://nagios.sourceforge.net/docs/3_0/pluginapi.html
Colonel Sponsz
draegtun
@Vinko: Ruby lacks libraries? I know it's not perfect or complete, but which missing ones did you have in mind?
Pistos
@Pistos: Been doing a bit of searching and it seems that my knowledge is outdated, there is a good amount libraries by now. They seem to be a bit disperse though (RubyForge considered).
Vinko Vrsalovic
+13  A: 

Use the language you are most familiar with. Perl is a very good choice. (as would the others be).

Ali A
+1  A: 

Take Python it allows you easily to connect to databases, LDAP, ... It has a big community and a growing extensions pool.

FerranB
Also, take your cue from Red Hat inc. Their add-on tools lean heavily toward Python.
S.Lott
You didn't mention anything in your comment that separates Python from any other language in the list. They can all easily connect to databases, LDAP. Ruby and Perl have very large communities and Perl has one of the largest extensions pools in existence with the CPAN.
mpeters
I agree with mpeters. Your argument is nonsense.
Leon Timmermans
+3  A: 

There is a book about using Python for systems administration. It might be helpful if you want to try out Python.

"Python for Unix and Linux System Administration" http://www.amazon.com/Python-Unix-Linux-System-Administration/dp/0596515820

Table of contents: http://oreilly.com/catalog/9780596515829/toc.html

codeape
+5  A: 

Perl ships on all versions of Linux and UNIX.

Perl has CPAN

Perl allows you to get your job done in only a few lines of code.

JDrago
A: 

I still do not think there is really a need to write your won monitoring system, I have used nagios before in the monitoring space and you can right all kind of custom scripts.

I have written scripts that test e.g 1) the http server availability, server load, mysql connection, monitoring mysql slow queries and ftp monitoring....

The beauty behind a system like nagios is start you can write your scripts e.g php(How I did) and you can then decide what the output is and how nagios should threat it. send you an email or sms...

Ronald Conco
A: 

I'm a Lua fan, and use it for many tasks, however I personally wouldn't use it for Admin work, but there is no particular reason besides the fact that there are few to no admin scripts written in Lua. If I had to choose I'd likely use Perl, as its the most common language for such tasks, and I'm pretty sure my successors won't curse my name, as much ;)

Robert Gould
+2  A: 

Perl or Python.

Ruby has not caught on in the System Admin community. Lua is too new and doesn't have the userbase. I've written stuff in Ruby before because I do personally like the Ruby language better than perl, but that stuff all wound up being orphaned.

I write mostly in Perl and Perl has been the language to learn to script system admin tasks for the past 10 years or so. The other big language to know/learn is C, but not for scripting tasks.

The kids these days seem to want to get into Python. However, at my work I've written 20,000 lines of Perl and I'm surrounded by system admins who don't write a line a code, think perl is ugly and aren't interested in learning anything other than Python. Maybe I'm just getting old, I dunno...

And, IMO its useless to debate religious issues about the language. You can write clear code or ugly code in any language. You can get the job done in any language. Different languages are elegant for different things which religious zealots will point out. The real question is what gets the job done today and in the future (with emphasis on future maintainability). If you know Perl and you have other people around you with Perl knowledge and are hiring more Perl people, use Perl. If you've got Python resources around you and are hiring and growing more Python people, use Python.

(and actually that goes to Lua as well -- if you do have an Lua-focused shop with lots of clever people playing around with it, and you're willing to hire only people who know or who are willing and able to quickly learn Lua then use that -- but understand the costs to future hiring and scalability of your organization that you're buying there).

And YMMV.

+1  A: 

You already got lots of answers but I'd like to push Ruby forward a bit. I'm a former Perl programmer (used to port/maintain 5.0nn on 386BSD & FreeBSD for a while) but I jumped on Ruby back in 2000 like a drowning man find something to grip on. I've since rewritten most of my Perl scripts in Ruby and it is very suited to sysadmin tasks. Lua is probably better for the embedded stuff though.

Keltia
+1  A: 

Perl was written to be a Unix system administration language. The creator of Perl, Larry Wall, has said Perl is the distillation of Unix culture. So even though I prefer programming in other languages, I'd recommend Perl for Unix administrators.

John D. Cook
+2  A: 

Ruby is actually a fine language to use for unix systems administration. There are quite a few resources popping up that can get you started.

There is a book called "Practical Ruby for System Administration" (http://www.amazon.com/gp/product/1590598210?ie=UTF8&tag=sheeptrader-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1590598210) that does a good job describing by Ruby is well suited. There is a review of this book at http://hans.fugal.net/blog/2007/07/26/practical-ruby-for-system-administration.

IBM wrote an article about Ruby for system administration (http://www.ibm.com/developerworks/aix/library/au-rubysysadmin/)

Additionally, an excellent automation framework for managing large networks of unix servers called Puppet was written in Ruby, and is in some ways similar to CFengine, allowing you to manage and enforce system configurations, perform actions/patches/upgrades/installations/reports across many servers, etc. Linux Journal wrote an article about it at http://www.linuxjournal.com/article/10046. Puppet is really quite amazing. You can get Puppet here.

Capistrano, a Ruby gem (a module or plugin essentially) commonly known for deploying Rails applications, is written in Ruby, and can deploy almost any kind of application (even those not written in Ruby) to remote servers, including custom tasks, migrations, database maintenance, etc. It's incredibly flexible. If you're building, troubleshooting, or maintaining development environments, this works very well, and yes, even for those still on J2EE environments.

The reason many people likely don't recommend it, is that they fear that not enough of their Systems Administrator teams know Ruby, making it less maintainable over time. Most Senior Systems Administrators should have Perl and shell scripting abilities, which makes those languages more immediately desired. I'd have to make a strong argument though, that a real Senior SA should be able to pick up almost any scripting language, even OOP-based, since most of the concepts transfer well. Those claiming that they do not have these abilities are very likely not really Senior after all.

Good luck, and I hope you take an opportunity to check Ruby out.

-Kevin

Kevin Elliott
+1  A: 

I was debating the same question until I realized a simple fact. Most of the Unix systems I work on have perl installed on them (because the unix admin teams and Info Sec teams use perl scripts to do their stuff), but no python exists. This made my choice really easy. I have worked for quite a few companies, and this holds true in general in my area. So, I chose Perl.

aMoLk