Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

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/ 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.

share|improve this question
Have you checked the auditlog, could be selinux blocking access to the socket. – topdog Sep 14 '12 at 13:57
SELinux it was ¬_¬ Forgot that the old database sever had it disabled. – jreid9001 Sep 14 '12 at 14:03
please post the solution as an answer, not an edit to your question. – voretaq7 Sep 14 '12 at 14:06

Turned out SELinux was blocking access to the socket.

setsebool -P allow_user_postgresql_connect on
share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.