status.log, cgi, and database support

Tom Fischer tom.fischer at ebuz.de
Wed Feb 11 20:02:11 CET 2004


On Wed, 11 Feb 2004 08:46:22 -0600
"Marc Powell" <marc at ena.com> wrote:

> Tom Fischer <mailto:tom.fischer at ebuz.de> wrote:
> > Hi,
> > 
> > i have compiled nagios with support for postgresql data and it
> > stored it's status data for host and services in it. Works fine. The
> > cgi tells me that the nagios process is probably not running, the
> > standard check for the cgi looks at status.log ;) Ok, the cgi is
> > right from his view ;) there is no status.log. So i tried to let it
> > check the nagios.log but this seems to be not updated frequently
> > enough. What can i do to solve this?      
> > 
> > 
> You'll need to replace your nagios check command specified in cgi.cfg
> with check_nagios_db.pl which is located in the plugins contrib
> directory.  

I installed it with the packetmanager from my linux distribution
(gentoo), so there was no check_nagios_db. Thanks for the hint, after a
little modification it runs fine with postgres. Maybe someone could need
it.

Tom

--- /usr/nagios/libexec/check_nagios_db.pl      2004-02-11
17:36:00.000000000 +0100+++
/usr/src/nagios-plugins-1.4.0alpha1/contrib/check_nagios_db.pl     
2002-08-14 21:01:58.000000000 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/local/bin/perl -w
 
 use strict;
 $|++;
@@ -10,10 +10,10 @@
 use Getopt::Std;
 use DBI;
 
-my $driver = "Pg";
+my $driver = "mysql";
 
-my $CFG_DEF = "/etc/nagios/cgi.cfg";
-my $QUERY = "select *, extract(epoch from last_update) as ut from
programstatus;";+my $CFG_DEF = "/opt/nagios/etc/cgi.cfg";
+my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from
programstatus;"; my $EXPIRE_DEF = 5; ## expressed in minutes
 my $PROCCNT = 0;
 
@@ -48,9 +48,9 @@
 }
 close(F);
 
-#print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
+# print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
 
-my $dsn = "DBI:$driver:dbname=$dbname;host=$dbhost;port=$dbport";
+my $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport";
 my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
 
 my $sth = $dbh->prepare($QUERY);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20040211/a8c63a79/attachment.sig>


More information about the Users mailing list