aouyar / PyMunin

Python Module for developing Munin Multigraph Monitoring Plugins. Multigraph Plugins for Apache Web Server, Apache Tomcat, APC PHP Cache, PHP FPM (Fast Process Manager), Asterisk, FreeSWITCH, Lighttpd, Memcached, MySQL Database, Nginx, NTP, PostgreSQL Database, CPU Utilization, Memory Utilization, Disk Usage, Disk I/O, Network Interfaces, Network Connections, Processes and Threads, etc.

Home Page:http://aouyar.github.io/PyMunin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pymunin-pgstats cannot connect to PostgreSQL

cwells opened this issue · comments

Scientific Linux 6.1
munin installed via EPEL repo.
pymunin installed via pip.

pg_hba.conf is set to "trust" all local connections.

Running the module from the command line works fine:

$ user=freeswitch ./pymunin-pgstats 
multigraph pg_connections
freeswitch.value 3
postgres.value 0
template0.value 0
template1.value 0
total.value 3
max_conn.value 1000

multigraph pg_diskspace
freeswitch.value 3896710928
postgres.value 5537796

(output trimmed)

However, munin-node log shows the following:

2012/02/26-21:10:07 [2877] Error output from pymunin-pgstats:
2012/02/26-21:10:07 [2877]      EXCEPTION: could not connect to server: Permission denied
2012/02/26-21:10:07 [2877]              Is the server running locally and accepting
2012/02/26-21:10:07 [2877]              connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2012/02/26-21:10:07 [2877] Service 'pymunin-pgstats' exited with status 1/0.

I've tried using localhost/port rather than the unix domain socket with the same result.

Interestingly, munin-run works:

$ munin-run pymunin-pgstats config
multigraph pg_connections
graph_title PostgreSQL - Active Connections
graph_category PostgreSQL Sys
graph_info Active connections for PostgreSQL Database Server.
graph_args --base 1000 --lower-limit 0
freeswitch.label freeswitch
freeswitch.type GAUGE
freeswitch.draw AREASTACK
freeswitch.info Active connections to database freeswitch.
postgres.label postgres
postgres.type GAUGE
postgres.draw AREASTACK
postgres.info Active connections to database postgres.
template0.label template0
template0.type GAUGE
template0.draw AREASTACK

(output trimmed)

Issue appears SELinux-related (gasp). Disabling SELinux resolves it.

Hi Cliff,

This does not seem to be a problem with the plugin script. You should really follow the general troubleshooting procedure for Munin Plugins to identify and fix the problem.

First of all you should be testing the plugin by executing munin-run with the root user in order to emulate the environment that munin-node will be using in when running the plugin script.

The most probable cause for the problem is that the user the plugin is executing with, does not have access to UNIX domain socket. You should have a configuration file in
/etc/munin/plugin-conf.d to implement either of the following configurations:

  • Run the plugin with the correct user.
  • Specify host, port, user and/or password parameters to connect to the database using a TCP socket.

In RHEL6 another possible source of issues is SELINUX. You could try disabling SELINUX temporarily to see if it is blocking the munin user from accesing the sockets.

Good luck,
Ali

Hi Cliff,

I had not seen that you had already closed the issue after discovering that the problem was caused by SELINUX.

Closing the issue,
Thanks,
Ali