studiodebian

My work laptop has been running Windows 7 for a year. The funny thing is I never really used the OS for work. My development environment resides in a Virtualbox vm. The harddisk is a Samsung PM800 ssd and has been crawling to a halt since a couple of weeks. It has trim support and the firmware should support it(i checked it last year) but the write performance is … bad.. really REALLY bad. Unworkable. So I checked if a new firmware was available that deals with this issue..and yes!

So my ssd got wiped yesterday for the sake of speed. A good moment to evaluate one year of Windows 7. I decided to turn things around and run Debian as host and Windows varieties (when i need them) as vm guests.

Of course some issues (like broadcom drivers and some videocard stuff) but generally it runs fine.

Monitoring multiple tcp-ports at once in Nagios

During the last two months I have been setting up Nagios as a side project. We have a lot of new customers coming in and we need to have a tight grip on our systems to satisfy service levels. So as I set up a Debian host to run Nagios on and was making progress in adding systems, I encountered several issues.

One of them was the fact that I need to monitor several tcp ports that are utilized in the applications we are running in a JBoss container. The default script in Nagios to monitor a tcp-port works well and I have used it to create a custom plugin to monitor several ports sequentially.

I have defined a service for this in Nagios and you can see this service is applied to a particular host group:

define service {   
    hostgroup_name  dme−servers 
    service groups DME_DIENSTVERLENING 
    service_description check_tcp_ports 
    check_command check_tcp_multiport!1098,1099,4444,5011,5021 
    use generic−service 
}

Below is the code I have put in
/usr/lib/nagios/plugins/check_tcp_multiport.pl

#!/usr/bin/perl -w
use strict;
use Getopt::Long;

my ($plugin_home,$hostname,$ports);
$plugin_home = "/usr/lib/nagios/plugins/";
getoptions();

sub getoptions
{
      my @ports;
      my $error_count = 0;
      my $error_ports ="";
      my $result=GetOptions
      (
              "h|host=s"=>\$hostname,
              "p|port=s" => sub
              {
                      $ports = pop,
                      @ports = split(/,/,$ports)
              },
      );
      foreach my $port (@ports)
      {
        my $output = `$plugin_home/check_tcp -H $hostname -p $port`;
        my $exit_code = $?;
        chomp($output);
        if  ($exit_code != 0)
        {
            $error_count++;
            $error_ports .= "$port,";
        }
      }
      if ( $error_count == 0)
      {
              print "All ports are OK on $hostname\n";
              exit 0;
      }
      chop($error_ports);
      print "There are $error_count errors on $hostname: $error_ports\n";
      exit 2;
}

Hello world!

Welcome to my renewed site. I used to blog in the past, and I’d like to share some things again. This time, most of my ramblings will be work related. I hope I can help/inspire/amuse my readers!