Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidfetter/pgbouncer_wrapper
SQL wrapper around pgbouncer's console
https://github.com/davidfetter/pgbouncer_wrapper
observability pgbouncer reporting sql
Last synced: about 21 hours ago
JSON representation
SQL wrapper around pgbouncer's console
- Host: GitHub
- URL: https://github.com/davidfetter/pgbouncer_wrapper
- Owner: davidfetter
- License: mit
- Created: 2015-03-31T14:42:30.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-01-27T22:41:52.000Z (almost 2 years ago)
- Last Synced: 2023-03-11T00:23:23.835Z (over 1 year ago)
- Topics: observability, pgbouncer, reporting, sql
- Language: PLpgSQL
- Homepage:
- Size: 45.9 KB
- Stars: 20
- Watchers: 4
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pgbouncer_wrapper
=================This project was originally inspired by Peter Eisentraut's excellent [post](http://peter.eisentraut.org/blog/2015/03/25/retrieving-pgbouncer-statistics-via-dblink/)
If you've ever wanted to run SQL queries against pgbouncer's SHOW output, this
is a handy way to do just that.To build it, just do this:
make
make installBe sure that you have `pg_config` installed and in your path. If you used a
package management system such as RPM to install PostgreSQL, be sure that the
`-devel` package is also installed. If necessary tell the build process where
to find it:env PG_CONFIG=/path/to/pg_config make && make install
Once pgbouncer_wrapper is installed, you can add it to a database like this:
CREATE EXTENSION pgbouncer_wrapper;
You can find how many clients are coming from each address like this:
```sql
SELECT
addr, count(*)
FROM
clients
GROUP BY addr
ORDER BY count(*) DESC;
```You can change pgbouncer settings like this:
```sql
SELECT set('default_pool_size', '300');
```To see whether the current configuration is out of step with `pgbouncer.ini`, you can do:
```sql
SELECT
count(*) > 0 AS "out of step"
FROM
regexp_split_to_table(
pg_read_file('/etc/pgbouncer/pgbouncer.ini'),
E'\n'
) WITH ORDINALITY AS t(l, o)
JOIN
config c
ON (
c.key =
(string_to_array(t.l, ' = '))[1]
)
WHERE
format('%s = %s', key, value) <> l;
```Dependencies
------------
`pgbouncer_wrapper` depends on dblink.Copyright and License
---------------------Copyright (c) 2015-2023 David Fetter .