0

I am using the check_postgres.pl plugin for Nagios. I am trying to monitor how long since the last checkpoint has been run using the check_postgres_checkpoint option. When I run the command from CLI as root I am getting the output but I am not able to get the output in the Nagios web interface. The error which it shows is,

ERROR: pg_controldata could not read the given data directory: "/opt/PostgreSQL/9.1/data"

It is trying to access the pg_control file in the 'global' directory present beneath the data directory which has only read access to the postgres user.

Can anyone please suggest me how this can be resolved ?

Thanks.

4 Answers 4

1

The best way to do this, in my opinion, is via sudo, as Khaled suggests.

Run 'visudo' and add a line like this:

nagios ALL=NOPASSWD:/path/to/check_postgres.pl

Then, change the command def to run the plugin through sudo. Oh, and be sure to make sure 'requiretty' isn't set (also via visudo), or it will fail.

Alternatively, you could make a new group containing nagios + postgres, and make /opt/PostgreSQL/9.1/data owned by postgres:postnag (or whatever), but you'd need to make sure that all new files are also group 'postnag' (via chmod g+s, for example). This is a much more complicated solution, but doesn't involve sudo (some people seem to dislike using sudo like this...?).

1
  • I run several Postgres and 3Ware host/service checks this (sudo) way.
    – Kendall
    Dec 29, 2011 at 1:00
0
  • Run your check script as the postgres user.

or

  • Run your check script as root

or

  • Run your check as one of the above users via cron, and have it write the data somewhere check_postgres can read it

or

  • …… I'm sure you can come up with more of these kinds of options on your own :-)
0

This can be solved by granting sudo right for nagios user to execute this plugin without requiring a password.

0

Give pg_controldata seutuid privileges. It is the easiest and safier than sudo mangling:

chmod u+s /usr/lib/postgresql/9.0/bin/pg_controldata

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .