[Pkg-nagios-devel] Bug#287324: nagios_check_db does not work with postgresql
Klaus Schiwinsky
Klaus.Schiwinsky@uni-koeln.de, 287324@bugs.debian.org
Mon, 27 Dec 2004 00:31:55 +0100
Package: nagios-common
Version: 1.3-0+pre6
Hi,
Has nagios_check_db been tested with postgresql?
If you set
# Change this to Pg if you use postgresql.
my $driver = "Pg";
and start nagios you get an error:
rechner:/etc/nagios# /etc/init.d/nagios start
Starting nagios: DBI
connect('database=nagios;host=localhost;port=5432','nagios',...) failed:
invalid connection option "database" at
/usr/lib/nagios/plugins/check_nagios_db line 55
nagios.
This is due to the fact that DBD::Pg requires "dbname=" instead of
"database=". (nagios starts anyway.) If you modify the following line
#my $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport";
my $dsn = "DBI:$driver:dbname=$dbname;host=$dbhost;port=$dbport";
you get another error:
rechner:/etc/nagios# /etc/init.d/nagios start
Starting nagios: DBD::Pg::st execute failed: ERROR: function
unix_timestamp(timestamp without time zone) does not exist at
/usr/lib/nagios/plugins/check_nagios_db line 61.
DBD::Pg::st execute failed: ERROR: function unix_timestamp(timestamp
without time zone) does not exist at
/usr/lib/nagios/plugins/check_nagios_db line 61.
nagios.
This time we have to deal with the fact that postgresql does not
know unix_timestamp(). The following query will be understood:
#my $QUERY = "select *, EXTRACT(EPOCH FROM last_update) as ut from
programstatus;";
my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from
programstatus;";
With these changes applied /etc/init.d/nagios will run without
complaining.
Greetings
Klaus Schiwinsky