{"id":25619357,"url":"https://github.com/thumbtack/pgdoctor","last_synced_at":"2026-01-23T00:56:37.644Z","repository":{"id":24347697,"uuid":"27745735","full_name":"thumbtack/pgdoctor","owner":"thumbtack","description":"Simple, lightweight web service to perform health checks on PostgreSQL instances","archived":false,"fork":false,"pushed_at":"2019-09-06T19:25:46.000Z","size":87,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-03-27T14:52:30.611Z","etag":null,"topics":["c","database","health-check","loadbalancing","postgres","postgresql","postgresql-monitoring"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thumbtack.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}},"created_at":"2014-12-09T02:28:30.000Z","updated_at":"2025-03-19T16:23:26.000Z","dependencies_parsed_at":"2022-08-22T07:10:24.285Z","dependency_job_id":null,"html_url":"https://github.com/thumbtack/pgdoctor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thumbtack%2Fpgdoctor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thumbtack%2Fpgdoctor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thumbtack%2Fpgdoctor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thumbtack%2Fpgdoctor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thumbtack","download_url":"https://codeload.github.com/thumbtack/pgdoctor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804459,"owners_count":21164125,"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","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":["c","database","health-check","loadbalancing","postgres","postgresql","postgresql-monitoring"],"created_at":"2025-02-22T06:17:00.845Z","updated_at":"2026-01-23T00:56:37.636Z","avatar_url":"https://github.com/thumbtack.png","language":"C","funding_links":[],"categories":["服务端测试"],"sub_categories":["服务端监控"],"readme":"pgDoctor\n========\n\nSimple, lightweight, web service used to define and run custom health checks on PostgreSQL \ninstances.\n\n\n## Dependencies\n* Header files for `libpq5` (PostgreSQL library)\n* GNU `libmicrohttpd`\n* `check`, a unit test framework for C\n  \nOn a Debian-based system, these can easily be installed by running\n  \n`sudo apt-get install libpq-dev libmicrohttpd-dev check`\n\n  \n## Build and install\n\n* Running tests (optional):\n  \n  The default configuration parameters for running tests rely on a local PostgreSQL instance \n  listening on port 5432. Connections will be established with the `postgres` user and no \n  password.\n  \n  If this does not match the system you're using, simply edit the relevant `pg_*` parameters\n  on `tests/pgdoctor.cfg`.\n  \n  To actually run the tests all we need to do is execute \n  \n    `make check`\n    \n  If the last line of the output shows something like `100%: Checks: X, Failures: 0, Errors: 0`,\n  where `X` is the number of checks performed, all is good.\n\n* Building:\n  \n    `make`\n\n* Installing\n\n    `sudo make install`\n\n\n## Configuration\nA default [configuration file](https://github.com/thumbtack/pgdoctor/blob/master/pgdoctor.cfg)\nis created under `/etc/pgdoctor.cfg`. Each setting is preceded by a comment describing it briefly.\n\n\n### Runtime settings\n| Parameter        | Description           | Default  |\n| ------------- |-------------|-----|\n| `http_port`      | Port to listen on | 8071 |\n| `syslog_facility` | Syslog facility (local) to messages log to | `local7` |\n\n### Target PostgreSQL instance\n| Parameter        | Description           | Default  |\n| ------------- |-------------|-----|\n| `pg_host` | Host name of the instance pgDoctor will connect to | `localhost` |\n| `pg_port` | Port on which the target server is listening | 5432 |\n| `pg_user` | User to connect with | `postgres` |\n| `pg_password` | Password to use with `pg_user` | *empty* |\n| `pg_database` | Name of the database to connect to | `postgres` |\n\n### Health checks\n| Parameter        | Description           | Default  |\n| ------------- |-------------|-----|\n| `pg_connection_timeout` | Timeout (seconds) when connecting to PostgreSQL | 3 |\n| `pg_max_replication_lag` | Maximum acceptable delay (seconds) on streaming replication | -1 (disabled) |\n\n#### Custom health checks\npgDoctor supports the definition of custom health checks in the form of arbitrary SQL queries \u0026mdash; one\ncheck per line.\n\nThese may be defined in two forms: \n* a plain SQL query, and the health check is considered successful if and only if it is executed without\nany errors;\n* a SQL query (must return exactly one field) **and** a condition, in which case the health check \nis considered successful when the query is executed without and errors *and* the condition \nevaluates to `true`.\n\nConditional checks are of the form\n```\n\"QUERY\" comparion_operator \"VALUE\"\n```\nwhere `comparison_operator` is one of `\u003c`, `\u003e`, or `=`. `QUERY` is any valid SQL command \n(surrounded by double-quotes), and `VALUE` (also surrounded by double-quotes) is the expected \nresult from `QUERY`. \n\nWhen using `=`, a string comparison is performed. For both `\u003c` and `\u003e` floating point values are\nused. \n\n---\n\n*Simple examples \u0026mdash; each health check passes iff the query runs without any errors*\n* `\"SELECT 1\"`\n* `\"SELECT NOW()\"`\n\n*Conditional example \u0026mdash; successful iff `on_rotation` equals `1`* \n* `\"SELECT on_rotation FROM maintenance WHERE hostname = 'production-replica3'\" = \"1\"`\n\n## Contact\n* [pgdoctor](https://groups.google.com/forum/#!forum/pgdoctor) group \u0026mdash; general discussion list.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthumbtack%2Fpgdoctor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthumbtack%2Fpgdoctor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthumbtack%2Fpgdoctor/lists"}