Background worker for monitoring PostgreSQL
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.travis.yml
LICENSE
Makefile
README.md
bg_mon.c
bg_mon.html
disk_stats.c
disk_stats.h
net_stats.c
net_stats.h
postgres_stats.c
postgres_stats.h
system_stats.c
system_stats.h
test.sh

README.md

Build Status Coverage Status

Background worker for monitoring PostgreSQL

bg_mon is a contrib module compatible with PostgreSQL starting from version 9.3 It collects per-process statistics combined with pg_stat_activity for the processes that have the rows there, global system stats, per-partition information and the memory stats.

Monitoring is being done from the Background Worker Process and results are exposed by embeded webserver implemented with the help of libevent library.

By default webserver listen on 127.0.0.1:8080 and statistics is collected every second. These values can be overriden with followin GUC variables:

bg_mon.listen_address = '0.0.0.0' # listen on all available interfaces (default value: 127.0.0.1)

bg_mon.port = 8888 # listen on port 8888 (default value: 8080)

bg_mon.naptime = 10 # collect statistics every 10 seconds (default value: 1)

How to build and install:

  1. You have to install libevent-dev package
  2. $ USE_PGXS=1 make
  3. $ sudo USE_PGXS=1 make install

How to run it:

  1. Add shared_preload_libraries = 'bg_mon' to your postgresql.conf
  2. If you want to change default values of bg_mon.listen_address, bg_mon.port or bg_mon.naptime - just add them to the postgresql.conf
  3. restart postgresql

If you did everything right, go to you browser and type following URLs to see results:

http://<bg_mon.listen_address>:<bg_mon.port>/ -- expose collected statistics in a JSON format.

http://<bg_mon.listen_address>:<bg_mon.port>/ui -- simple web page which fetches statistics from server every second and renders it in a simple html format.

License

Apache 2.0