Archive for March, 2008

Perl - Text::Diff

Friday, March 14th, 2008

As I stated in my About page I am not a programmer by trade but I can and do code when the need arises. One of my favorite languages to code in is Perl as it provides a ton of functionality thanks to CPAN, is platform-indepandant, and at times very natural and easy going for most tasks I need to accomplish. The thing about Perl though is its Perl and it can be very intimidating at times. Luckily what I needed to do earlier today was not one of those times. Theres always something new to discover using Perl and I’m always glad when I find something new in Perl that is useful or any other language for that matter and today I came across a module that I had never used before so I’d figured I’d share even though it may be a household module for the hardcore perl monks out there.

So my problem was I needed to diff two files and determine if they were identical in order to apply logic based on the output of the diff. Now I do this all the time on the command line using the GNU diff utility but I needed its functionality within Perl. At first I was thinking I could execute a system or exec function but I figured there has to be a better way right? This is Perl after all surely this functionality is available. Well it wasn’t hard to find Text::Diff with a simple search and and after a few minutes of reading the documentation it is exactly what I needed. First things first though. I need to install the module first either via CPAN or my package manager.

Installing on OpenBSD via pkg manager was a snap as long as you have exported the PKG_PATH first.

#export PKG_PATH="ftp://ftp.openbsd.org/pub/OpenBSD/pub/4.2/packages/i386/"
#pkg_add -v p5-Text-Diff

If your on Debian it should be as simple as
#apt-get install libtext-diff-perl

…or from the CPAN shell

cpan>install Text::Diff

With that installed now I just needed the code in my script…

use Text::Diff

my $diff = diff "file1.txt", "file2.txt", { STYLE => "Context" };

if($diff) {
#files are different
...
}
else{
# files are the same.
...
}

…and there it is. I will be sharing the script where I needed this functionality in the near future as part of a feature article I plan to write once my project is near completion. I hope someone may find this to be useful in the meantime.

Nagios 3 Released!

Thursday, March 13th, 2008

Nagios 3 was quietly released today! The beta and release canadates have been out for some time with a lot of new features, changes, optimizations, and bug fixes which is probably why there wasn’t a whole lot of fuss about todays release.

Now I must say I havent spent a whole lot of time with Nagios lately but hopefully this will give me a reason to get my hands dirty again. There has been a ton of work done on this release, so I won’t even begin to list them off here but I will point you the the whats new documentation so you can take a look for yourself. I really cant wait to get into it.

I also want to send my congrats to the Nagios developers who were involved in this milestone. As a long time part of the Nagios community your work is much appreciated.

The right software on the wrong platform…

Tuesday, March 11th, 2008

Now, Im one of those admins who despises running certain open source software packages on Windows. It just bugs me. Just because a certain application runs on Windows, or is reported to run on Windows (if you follow the 101 step procedure to the t and don’t stumble on any gotchas because your trying to accomplish something slightly different then what is documented), doesn’t mean that it should be run on Windows, especially for production applications. Take the LAMP stack for example Apache HTTP Server, PHP/PERL, MySQL. All these run on the Windows platform and thats great and all. It makes it very convenient to set up a development environment on windows machines. But in my very humble opinion, these projects were made to be ran in a *nix environment. Just look at the configuration files and you can easily see the developers have intended these to be run under a *nix platform. Installation is usually a breeze with these apps under *nix. Now I must admit that the Apache Group, MySQl, and ActiveState have done a very great job with there windows installation packages, but have you ever installed PHP on IIS? Tell me that wasn’t a headache the first time you tried that? Didn’t it seem kind of hackish? And the performance, how was it for you? Now, I haven’t tried the PHP “friendly” IIS 7 but I’m hoping this has improved some. Now, the lamp stack is just my example, but theres a multitude of open source software out there that just should not be run under windows. Installation and configuration usually involve some sort of two-bit hack and integration and/or troubleshooting is typically dreadful and time-consuming. And it goes both ways. I would never try to install IIS or MSSQL on a *nix platform but good luck to you if you dare! Let me know how that goes for you. And did someone say emulators? Yah, I “hear” wine has made some great strides in the past few years, especially thanks to the folks at google, but if your gonna run linux as your desktop, cant you make the full commitment and just run OpenOffice or Gimp? And please don’t even mention the word “cygwin” to me!

But “business requirements” are “business requirements” after all, aren’t they.