[Pkg-nagios-devel] Bug#288705: nagios-pgsql: check_nagios_db is incompatible with PostgreSQL
Marcus Better
Marcus Better <marcus@better.se>, 288705@bugs.debian.org
Wed, 5 Jan 2005 10:21:44 +0100
Package: nagios-pgsql
Version: 2:1.3-0+pre6
Severity: important
The included check_nagios_db script for MySQL needs to be modified for
PostgreSQL. Without it, the CGI scripts will not detect a running
Nagios and will not allow executing commands.
The attached patch will fix this.
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.9-custom
Locale: LANG=sv_SE.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Versions of packages nagios-pgsql depends on:
ii libc6 2.3.2.ds1-18 GNU C Library: Shared libraries an
ii libgd2-noxpm 2.0.33-1.1 GD Graphics Library version 2 (wit
ii libjpeg62 6b-9 The Independent JPEG Group's JPEG
ii libpng12-0 1.2.8rel-1 PNG library - runtime
ii libpq3 7.4.6-5 PostgreSQL C client library
ii nagios-common 2:1.3-0+pre6 A host/service/network monitoring
ii zlib1g 1:1.2.2-3 compression library - runtime
-- no debconf information
===File /etc/nagios/check_nagios_db.patch===================
--- check_nagios_db
+++ check_nagios_db 2005-01-05 10:13:47.000000000 +0100
@@ -11,10 +11,10 @@
use DBI;
# Change this to Pg if you use postgresql.
-my $driver = "mysql";
+my $driver = "Pg";
my $CFG_DEF = "/etc/nagios/cgi.cfg";
-my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;";
+my $QUERY = "select *, extract(epoch from last_update) as ut from programstatus;";
my $EXPIRE_DEF = 5; ## expressed in minutes
my $PROCCNT = 0;
@@ -51,7 +51,7 @@
# print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
-my $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport";
+my $dsn = "DBI:$driver:dbname=$dbname;host=$dbhost";
my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
my $sth = $dbh->prepare($QUERY);
@@ -92,7 +92,7 @@
if ( $STAT == OK ) {
print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n";
} else {
- print "Nagios problem: no processus found";
+ print "Nagios problem: no processes found\n";
exit 1;
}
============================================================