Problems with nagios-plugins on FreeBSD

Olafur Osvaldsson oli at isnic.is
Mon Mar 1 17:23:51 CET 2004


Hi,
I'm using nagios-plugins v1.3.1 from the FreeBSD ports tree and
got into a few problems using the check_procs plugin.
It was fixed by altering the configure.in file by moving the
FreeBSD part before the "ps -weo" check like had been done with
the OpenBSD check.
If you need more info or patch just let me know.

I also made a few changes to the contrib/check_nagios_db.pl script
so it would support PostgreSQL databases and got rid of an anoying
error.
The diff to that file is attached.

/Oli

-- 
Olafur Osvaldsson
Systems Administrator
Internet a Islandi hf.
Tel:   +354 525-5291
Email: oli at isnic.is
-------------- next part --------------
--- contrib/check_nagios_db.pl.orig	Mon Mar  1 16:19:04 2004
+++ contrib/check_nagios_db.pl	Mon Mar  1 16:21:24 2004
@@ -13,7 +13,13 @@
 my $driver = "mysql";
 
 my $CFG_DEF = "/opt/nagios/etc/cgi.cfg";
-my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;";
+my $QUERY;
+if ($driver eq 'Pg') {
+  $QUERY = "SELECT *, EXTRACT(EPOCH FROM last_update) AS ut FROM programstatus;";
+}
+else {
+  $QUERY = "SELECT *, UNIX_TIMESTAMP(last_update) AS ut FROM programstatus;";
+}
 my $EXPIRE_DEF = 5; ## expressed in minutes
 my $PROCCNT = 0;
 
@@ -50,7 +56,14 @@
 
 # print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
 
-my $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport";
+my $dsn;
+
+if ($driver eq 'Pg') {
+  $dsn = "DBI:$driver:dbname=$dbname;host=$dbhost;port=$dbport";
+}
+else {
+  $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport";
+}
 my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
 
 my $sth = $dbh->prepare($QUERY);
@@ -86,4 +99,7 @@
 if ( $STAT == OK ) {
         print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n";
 }
+
+$sth->finish;
+$dbh->disconnect  or warn $dbh->errstr;
 


More information about the Users mailing list