{"id":16810029,"url":"https://github.com/cyberdem0n/bg_mon","last_synced_at":"2025-09-08T18:31:03.010Z","repository":{"id":29434593,"uuid":"32970629","full_name":"CyberDem0n/bg_mon","owner":"CyberDem0n","description":"Background worker for monitoring PostgreSQL","archived":false,"fork":false,"pushed_at":"2024-07-01T08:53:40.000Z","size":262,"stargazers_count":70,"open_issues_count":4,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T04:33:54.736Z","etag":null,"topics":["background-worker","json","monitoring","postgresql"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyberDem0n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-27T06:05:08.000Z","updated_at":"2025-03-04T06:33:59.000Z","dependencies_parsed_at":"2023-12-13T11:38:51.662Z","dependency_job_id":"db5936fd-94c8-42dd-b11d-535a7d86def3","html_url":"https://github.com/CyberDem0n/bg_mon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CyberDem0n/bg_mon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberDem0n%2Fbg_mon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberDem0n%2Fbg_mon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberDem0n%2Fbg_mon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberDem0n%2Fbg_mon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyberDem0n","download_url":"https://codeload.github.com/CyberDem0n/bg_mon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberDem0n%2Fbg_mon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274229367,"owners_count":25245187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-worker","json","monitoring","postgresql"],"created_at":"2024-10-13T10:14:25.827Z","updated_at":"2025-09-08T18:31:02.674Z","avatar_url":"https://github.com/CyberDem0n.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/CyberDem0n/bg_mon/actions/workflows/tests.yaml/badge.svg)](https://github.com/CyberDem0n/bg_mon/actions/workflows/tests.yaml) [![Coverage Status](https://coveralls.io/repos/github/CyberDem0n/bg_mon/badge.svg?branch=master)](https://coveralls.io/github/CyberDem0n/bg_mon?branch=master)\n\nBackground worker for monitoring PostgreSQL\n===========================================\n\nbg\\_mon is a contrib module compatible with PostgreSQL starting from version 9.3\nIt 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.\n\nMonitoring is being done from the [Background Worker Process](http://www.postgresql.org/docs/9.3/static/bgworker.html) and results are exposed by embeded webserver implemented with the help of [libevent](http://libevent.org/) library.\n\nBy default webserver listen on `127.0.0.1:8080` and statistics is collected every second. Optionally, if compiled with libbrotli, the worker will keep statistics in the aggregated format for the past `history_buckets` minutes in memory. Brotli compression is used because the compression ratio is very efficient and most of the modern browsers support it out of the box.\n\nList of available GUC variables\n-------------------------------\n\n**bg\\_mon.listen\\_address** = **'0.0.0.0'** # listen on all available interfaces (default value: 127.0.0.1)\n\n**bg\\_mon.port** = **8888** # listen on port 8888 (default value: 8080)\n\n**bg\\_mon.naptime** = **10** # collect statistics every 10 seconds (default value: 1)\n\n**bg\\_mon.history\\_buckets** = **60** # keep one-minute aggregated statistics in memory for 60 minutes (default value: 20)\n\nHow to build and install:\n-------------------------\n\n1. You have to install `libevent-dev` and optionally `libbrotli-dev` packages\n2. $ USE\\_PGXS=1 make\n3. $ sudo USE\\_PGXS=1 make install\n\nHow to run it:\n--------------\n1. Add `shared_preload_libraries = 'bg_mon'` to your postgresql.conf\n2. If you want to change default values of `bg_mon.listen_address`, `bg_mon.port`, `bg_mon.naptime`, or `bg_mon.history_buckets` - just add them to the postgresql.conf\n3. restart postgresql\n\nIf you did everything right, go to you browser and type following URLs to see results:\n\n`http://\u003cbg_mon.listen_address\u003e:\u003cbg_mon.port\u003e/` -- expose collected statistics in a JSON format.\n\n`http://\u003cbg_mon.listen_address\u003e:\u003cbg_mon.port\u003e/X` -- get aggregated statistics from the bucket X, where X is between **0** and **history\\_buckets**, **unixtime**, **time**, or **timestamp** in any format supported by postgres (if the timezone is not specified it is assumed to be UTC). The array with the current bucket might be not yet closed.\n\n`http://\u003cbg_mon.listen_address\u003e:\u003cbg_mon.port\u003e/ui` -- simple web page which fetches statistics from server every second and renders it in a simple html format.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberdem0n%2Fbg_mon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyberdem0n%2Fbg_mon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberdem0n%2Fbg_mon/lists"}