0

I am trying to set up Munin to collect stats on a server with postgresql 9.1 and 9.2 (the server is currently running 9.1, have tested on a fresh VM with 9.2 to rule out some weird problem on the running server. I had to patch some of the plugins for 9.2 due to renamed columns (e.g. procpid to pid), but that's no problem).

Munin is installed from the EPEL repos, postgres from the official one. Both up to date.

When I try to run munin-node-configure --suggest, I get this output:

# The following plugins caused errors:
# postgres_bgwriter:
#   Junk printed to stderr
# postgres_cache_:
#   Junk printed to stderr
# postgres_checkpoints:
#   Junk printed to stderr
# postgres_connections_:
#   Junk printed to stderr
# postgres_connections_db:
#   Junk printed to stderr
# postgres_locks_:
#   Junk printed to stderr
# postgres_querylength_:
#   Junk printed to stderr
# postgres_scans_:
#   Junk printed to stderr
# postgres_size_:
#   Junk printed to stderr
# postgres_transactions_:
#   Junk printed to stderr
# postgres_tuples_:
#   Junk printed to stderr
# postgres_users:
#   Junk printed to stderr
# postgres_xlog:
#   Junk printed to stderr

After a lot of searching around, I edited /etc/munin/plugin-conf.d/munin-node and added the following:

[postgres*]
user postgres

This stops munin-node-configure complaining about stderr and lets me add the plugins, but when I telnet to the server on 4949 and try to fetch the stats, I just get "Bad exit". When I run the plugin individually via munin-run (e.g. munin-run postgres_size_ALL ), it works completely fine. Looking at /var/log/munin/munin-node.log, this is the output:

Error output from postgres_size_ALL:
    DBI connect('dbname=template1','',...)failed: could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"? at /usr/share/perl5/vendor_perl/Munin/Plugin/Pgsql.pm line 377
Service 'postgres_size_ALL exited with status 1/0.

I am now out of ideas... the socket definitely exists, and pg_hba.conf is set to allow all users/databases from localhost with trust.

voretaq7
  • 79,879
  • 17
  • 130
  • 214
jreid9001
  • 161
  • 2
  • 6

2 Answers2

1

Turned out SELinux was blocking access to the socket.

setsebool -P allow_user_postgresql_connect on
jreid9001
  • 161
  • 2
  • 6
0

I just had that issue as well but I don't use SELinux. On my system (Gentoo Linux) the PostgreSQL UNIX socket is protected by group permissions, all users that want to access that socket have to be in group postgres. My user munin already was a member of postgres (thus everything worked well from a shell) but as it turned out, Munin is one of those programs that do not implicitely apply user groups. Setting both user munin and group postgres in the plugin configuration file solved the issue for me.

Energiequant
  • 111
  • 4