Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
Adding pid_file config option
Browse files Browse the repository at this point in the history
(If you have several running pgpool process on your server then "wait" and "idle" params will show incorrect values)
  • Loading branch information
mangust404 committed Feb 4, 2015
1 parent d2cdab4 commit 3d256ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -20,7 +20,7 @@ If `env.pcppath` is not specified, the plugin executes `/usr/bin/pcp_pool_path`.
env.user pooladm
env.userpwd foobar123
env.pcppath /path/to/pcp_pool_status

env.pid_file /var/run/pgpool/pgpool.pid

# Requirements

Expand Down Expand Up @@ -51,3 +51,6 @@ We then just count the number of occurrences and plot the value.

This works just as the above plugin, but we look for the string "idle in transaction".

Note that you should give a+r access rights to pgpool PID file

chmod a+x /var/run/pgpool/pgpool.pid
10 changes: 8 additions & 2 deletions pgpool_connections
Expand Up @@ -14,6 +14,12 @@ user = os.environ['user']
userpwd = os.environ['userpwd']
timeout = 5
pcppath = os.environ.get( 'pcppath', '/usr/bin/pcp_pool_status' )
pid_file = os.environ.get( 'pid_file', '' )
parent_pid = 0

if ( pid_file != '' ):
from subprocess import call
parent_pid = int(open(pid_file, 'r').read().split(b'\0',1)[0])

if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
print 'yes'
Expand All @@ -38,9 +44,9 @@ else:
pl = psutil.process_iter()

for item in pl:
if ("wait for connection request" in str(item) and not "PCP" in str(item)):
if ((item.ppid == parent_pid or parent_pid == 0) and "wait for connection request" in str(item) and not "PCP" in str(item)):
waitCount += 1
elif ("idle in transaction" in str(item) and not "PCP" in str(item)):
elif ((item.ppid == parent_pid or parent_pid == 0) and "idle in transaction" in str(item) and not "PCP" in str(item)):
idleCount += 1

if sys.version_info < ( 2, 7, 0 ):
Expand Down

0 comments on commit 3d256ba

Please sign in to comment.