[check_postgres] Using sudo -u postgres check_postgres --action=checkpoint returns "Failed to run pg_controldata - is it the correct version?"
James Skaggs
skaggs.james at gmail.com
Tue Jan 15 19:24:31 UTC 2013
Greg -
I appreciate check_postgres and use it a lot.
I think I found an interaction between sudo, pg_controldata, and
check_postgres. There is a proposed fix at the bottom.
check_postgres: Version 2.19.0
postgresql: 8.4.15
[nagios at cyclonus ~]$ PGBINDIR=/usr/pgsql-8.4/bin/
[nagios at cyclonus ~]$ export PGBINDIR
[nagios at cyclonus ~]$ sudo -u postgres
/usr/bin/check_postgres.pl--assume-standby-mode --datadir
/pgdata/coverity/data/ --action=checkpoint
*ERROR: Failed to run pg_controldata - is it the correct version?*
In the perl debugger, we see extraneous output from pg_controldata....BTW,
his does not happen when run directly from the "postgres" user.
DB<3> p $COM
/usr/pgsql-8.4/bin//pg_controldata "/pgdata/coverity/data/"
3181: if ($res !~ /^pg_control.+\d+/) {
DB<7> p $res
*could not change directory to "/var/log/nagios"*
pg_control version number: 843
Catalog version number: 200904091
Database system identifier: 5805897768012068846
Database cluster state: in archive recovery
pg_control last modified: Mon 14 Jan 2013 03:54:30 PM MST
Latest checkpoint location: F0/109D8900
Prior checkpoint location: F0/74AE670
Latest checkpoint's REDO location: F0/ABBED08
Latest checkpoint's TimeLineID: 1
Latest checkpoint's NextXID: 0/121770964
Latest checkpoint's NextOID: 426392
Latest checkpoint's NextMultiXactId: 4420942
Latest checkpoint's NextMultiOffset: 11062935
Time of latest checkpoint: Mon 14 Jan 2013 03:46:22 PM MST
Minimum recovery ending location: F0/2BFFFFD0
Maximum data alignment: 8
Database block size: 8192
Blocks per segment of large relation: 131072
WAL block size: 8192
Bytes per WAL segment: 16777216
Maximum length of identifiers: 64
Maximum columns in an index: 32
Maximum size of a TOAST chunk: 1996
Date/time type storage: 64-bit integers
Float4 argument passing: by value
Float8 argument passing: by value
DB<8> v
3178: if ($res =~ /WARNING: Calculated CRC checksum/) {
3179: ndie msg('checkpoint-badver', $dir);
3180 }
3181==> if ($res !~ /^pg_control.+\d+/) {
3182: ndie msg('checkpoint-badver2');
3183 }
3184
The extra output breaks the regex at line 3181. Adding a "m" option lets
it match at the beginning of any line, not just the first.
3181c3181
< if ($res !~ /^pg_control.+\d+/) {
---
> if ($res !~ /^pg_control.+\d+/*m*) {
BTW, using sudo had it's own difficulties....mostly about sudo requiring a
tty by default, something that that nrpe does not provide.
diff ... /etc/sudoers
24a25
> Cmnd_Alias NAGIOS_CMDS = /usr/bin/check_postgres.pl,
/var/lib/pgsql/check_posgres_checkpoint, /usr/pgsql-8.4/bin/pg_controldata
59a61,62
> # This is so nagios can use sudo to posgress to check the database
> *Defaults:nagios !requiretty*
114a118
> nagios ALL=(postgres) NOPASSWD: NAGIOS_CMDS
Regards,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.endcrypt.com/pipermail/check_postgres/attachments/20130115/907eb6bd/attachment.html>
More information about the Check_postgres
mailing list