[Pkg-nagios-devel] nagios README.pgsql,NONE,1.1 changelog,1.31,1.32 nagios-common.docs,1.2,1.3

seanius@haydn.debian.org seanius@haydn.debian.org


Update of /cvsroot/pkg-nagios/nagios
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv3890

Modified Files:
	changelog nagios-common.docs 
Added Files:
	README.pgsql 
Log Message:
README.pgsql


--- NEW FILE: README.pgsql ---
INSTALLING AND CONFIGURING NAGIOS/POSTGRESQL

   Author: Ricky Ng-Adam, rngadam@yahoo.com, January 2005

= Introduction =

   Tested on Apache 1.3.33-2, nagios-pgsql 1.3-0+pre6, PostgreSQL 7.4.6-5 on Debian
   Sarge (testing); all packages from Debian repositories

= Installation =

   Install the Debian package:

# su
# apt-get install nagios-pgsql

   Next, we will setup the PostgreSQL database:

# gunzip /usr/share/doc/nagios-pgsql/create_pgsql.gz
# su postgres
# createdb nagios
# psql nagios < /usr/share/doc/nagios-pgsql/create_pgsql
# createuser -A -D nagios
# createlang plpgsql nagios
# psql nagios

   copy/paste the following in psql (alternatively, do each individual
   grant):

-- pgx_grant(PRIVILEGE, TABLES, USER)
--  Grants PRIVILEGE to USER on objects like TABLES%
--  Grants to tables, views and sequences.
--
CREATE FUNCTION pgx_grant(text,text,text) returns int4 as '
DECLARE
  priv ALIAS FOR $1;
  patt ALIAS FOR $2;
  user ALIAS FOR $3;
  obj  record;
  num  integer;
BEGIN
  num:=0;
  FOR obj IN SELECT relname FROM pg_class
  WHERE relname LIKE patt || \'%\' AND relkind in (\'r\',\'v\',\'S\') LOOP
    EXECUTE \'GRANT \' || priv || \' ON \' || obj.relname || \' TO \' || user;
    num := num + 1;
  END LOOP;
  RETURN num;
END;
' language 'plpgsql';

   (continued)

select pgx_grant('ALL','host%','nagios');
select pgx_grant('ALL','service%','nagios');
select pgx_grant('ALL','program%','nagios');
ALTER USER nagios PASSWORD 'USER_DESIRED_PASSWORD';

= Configuration =

   First, create a copy of the check_nagios_db script:

cp /usr/share/doc/nagios-pgsql/check_nagios_db /usr/lib/nagios/plugins/

   Apply these changes to /usr/lib/nagios/plugins/check_nagios_db:

--- /usr/share/doc/nagios-pgsql/check_nagios_db 2004-11-13 18:56:19.000000000 -0500
+++ /usr/lib/nagios/plugins/check_nagios_db     2004-12-31 09:16:16.000000000 -0500
@@ -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 *, date_part('epoch',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;port=$dbport";
 my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});

 my $sth = $dbh->prepare($QUERY);

   Test it standalone:

/usr/lib/nagios/plugins/check_nagios_db

   vi /etc/nagios/resource.cfg

:%s/somehost/localhost/g
:%s/somedatabase/nagios/g
:%s/someuser/nagios/g
:%s/somepassword/USER_DESIRED_PASSWORD/g
:%s/#x/x/g
:%s/someport/5432/g

   Repeat same for /etc/nagios/cgi.cfg.

   In the same file, change the check command:

nagios_check_command=/usr/lib/nagios/plugins/check_nagios_db

   Check and restart:

# nagios -v /etc/nagios/nagios.cfg
# /etc/init.d/nagios restart
# apachectl graceful

   You can now edit /etc/nagios/*.cfg files to add your own checks.

= Testing =

   http://localhost/cgi-bin/nagios/summary.cgi
   http://localhost/cgi-bin/nagios/tac.cgi

= Debugging =

   To look at the most interesting logs:

# tail -f /var/log/nagios/nagios.log /var/log/apache/* /var/log/postgresql/

   Remember that the Nagios CGI config (cgi.cfg) is separate and
   autonomous from nagios configuration.

= References =

     * http://arstechnica.com/columns/linux/linux-20040601.ars
     * http://www.xach.com/aolserver/mysql-to-postgresql.html
     * http://www.archonet.com/pgdocs/grant-all.html

Index: changelog
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/changelog,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- changelog	17 Jan 2005 18:34:52 -0000	1.31
+++ changelog	18 Jan 2005 06:40:04 -0000	1.32
@@ -24,6 +24,11 @@
       should resolve issues with nagios packages not accessing hostextinfo
       as they should.  thanks to Roy Bonser <rbonser@spyder-monkey.com> 
       for pointing out these symptoms (closes: #290681).
+    - now include a README.pgsql, which was provided by 
+      Ricky Ng-Adam <rngadam@yahoo.com>.  this should clear up many
+      issues that postgresql users were having with lacking documentation.
+      thanks also to Marcus Better and Klaus Schiwinsky for their reports
+      (closes: #287324, #288705).
 
  -- Sean Finney <seanius@debian.org>  Mon, 10 Jan 2005 15:13:21 -0800
 

Index: nagios-common.docs
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/nagios-common.docs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- nagios-common.docs	11 Nov 2004 00:01:50 -0000	1.2
+++ nagios-common.docs	18 Jan 2005 06:40:04 -0000	1.3
@@ -1,6 +1,7 @@
 README
 UPGRADING
 debian/README.mysql
+debian/README.pgsql
 contrib/database/create_mysql
 contrib/database/create_pgsql
 debian/check_nagios_db