PDA

View Full Version : Informix


denolfd
2nd February 2007, 13:25
Hi,

Does somebody have a check_informix plugin?
I have found something at http://sourceforge.net/mailarchive/message.php?msg_id=6062958 but it seems the plugin can't be downloaded :(

Thanks

philarete
5th April 2007, 19:30
Here's a quick and dirty one I wrote in Perl. (You'll need DBD::Informix, of course.) It assumes that you're connecting to database "test" as user "nagios" with password "nagios". The one argument sets the value of INFORMIXSERVER.

This is the first plugin I've written, so feel free to suggest improvements.

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Std;
use DBI;
use vars qw( $opt_h $opt_H );

use lib '/usr/lib/nagios/plugins/';
use utils qw( %ERRORS );

getopt('H');

usage() if $opt_h;
usage() if !$opt_H;

$ENV{INFORMIXSERVER} = $opt_H;
$ENV{INFORMIXCONTIME} = 10;

my $ifxuser = 'nagios';
my $ifxpass = 'nagios';
my $database = 'test';

my $dbh = DBI->connect("DBI:Informix:$database", $ifxuser, $ifxpass,
{ RaiseError => 0, PrintError => 0,
HandleError => \&error });
$dbh->disconnect;

print "Informix OK: Connection successful.\n";
exit($ERRORS{'OK'});

sub usage {
print "Usage: $0 -H sqlhost\n";
exit(1);
}

sub error {
print "Informix CRITICAL: $DBI::errstr\n";
exit($ERRORS{'CRITICAL'});
}