[Pkg-nagios-devel] Bug#308564: (Bug#308564: nagios-pgsql: README.pgsql is (slightly) wrong

Turbo Fredriksson Turbo Fredriksson <turbo@debian.org>, 308564@bugs.debian.org
Thu, 12 May 2005 12:54:33 +0200


On Wed, 11 May 2005 19:51:56 -0400, sean finney wrote:
> On Wed, May 11, 2005 at 08:23:36AM +0200, Turbo Fredriksson wrote:
> >   Note that the command THERE is '/etc/nagios/check_nagios_db', NOT
> >   the stated '/usr/lib/nagios/plugins/check_nagios_db'. The former location
> >   is a must (init script etc uses this - which is wrong in it self, it
> >   should extract the 'nagios_check_command' option if set from the config).
> 
> yes, it should.  ideally, check_nagios_db should be in /usr/lib/nagios,
> but unfortunately it has some fields that must be edited for it to be
> of any use,

That assumtion is wrong. There are nothing a user _have_ to change for their
specific host. What to do (which I did in the package I handed over to you)
was to distribute the unpatched script in the mysql package and a patched
version in the pgsql package...

That way, the script is NOT a config file, but a script as any one else
and the init script (etc) can be hardcoded to use it (in /usr/lib/nagios
or wherever - it's a _SCRIPT_ and hence not arch specific and should/could
be located in /usr/share/nagios).

> which is why i imagine this current setup was recommended.
> what we *should* do is seperate out the config into an
> /etc/nagios/check_nagios_db.pm

Just to clarify. There are no configuration in the script, the patch is
very simple/clear:

----- s n i p -----
--- /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);
----- s n i p -----

NOTHING system specific there. Just make it a MySQL script _or_ a PgSQL
script -> two versions, one in each sub-package.
-- 
Rule Psix Clinton strategic Ft. Meade SEAL Team 6 ammunition [Hello to
all my fans in domestic surveillance] spy NORAD KGB nitrate nuclear
critical FBI Ortega
[See http://www.aclu.org/echelonwatch/index.html for more about this]