-
Notifications
You must be signed in to change notification settings - Fork 5
/
pgpoolmgr.sh
executable file
·71 lines (60 loc) · 1.01 KB
/
pgpoolmgr.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
#
# pgpool-II replication manager
#
# Interfaces with pgpool's pcp command-line tools to provide access to common functions for managing
# load-balancing and failover.
#
. lib/pgpool.sh
#
# Attaches the specified node to the pool
#
attach()
{
_attach $1
}
#
# Detaches the specified node from the pool
#
detach()
{
_detach $1
}
#
# Recovers the specified node (restores it from current master and re-attaches)
#
recover()
{
_recover $1
}
#
# Prints out the status of all pgpool nodes in human readable form.
#
status()
{
# Get total number of nodes
nodes=$(_get_node_count)
if [ $? -gt 0 ]; then
echo "ERROR: Failed getting node count: $nodes" >&2
exit 1
fi
c=0
# Loop through each node to retrieve info
while [ $c -lt $nodes ]; do
_get_node_status $c
let c=c+1
done
}
# Run function
if [ ! "$(type -t $1)" ]; then
echo "Usage $0 <option>" >&2
echo "" >&2
echo "Available options:" >&2
echo "$(compgen -A function |grep -v '^_')" >&2
exit 99
else
cmd=$1
shift
$cmd $*
exit $?
fi