diff --git a/README.md b/README.md index 0f3c2c4..2a54550 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This project is a continuation of the development of the original pgSCV by [Alex Download the archive from [releases](https://github.com/cherts/pgscv/releases). Unpack the archive. Create minimum config file. Start pgSCV systemd service under `postgres` user. ```bash -curl -s -L https://github.com/cherts/pgscv/releases/download/v0.8.4/pgscv_0.8.4_linux_amd64.tar.gz -o - | tar xzf - -C /tmp && \ +curl -s -L https://github.com/cherts/pgscv/releases/download/v0.8.5/pgscv_0.8.5_linux_amd64.tar.gz -o - | tar xzf - -C /tmp && \ mv /tmp/pgscv.yaml /etc && \ mv /tmp/pgscv.service /etc/systemd/system && \ mv /tmp/pgscv.default /etc/default/pgscv && \ diff --git a/README.ru.md b/README.ru.md index cafc86b..4931eb7 100644 --- a/README.ru.md +++ b/README.ru.md @@ -29,7 +29,7 @@ Загрузите архив со страницы [releases](https://github.com/cherts/pgscv/releases). Распакуйте архив. Создайте минимальный файл конфигураации. Запустите pgSCV под пользователем postgres. ```bash -curl -s -L https://github.com/cherts/pgscv/releases/download/v0.8.4/pgscv_0.8.4_linux_amd64.tar.gz -o - | tar xzf - -C /tmp && \ +curl -s -L https://github.com/cherts/pgscv/releases/download/v0.8.5/pgscv_0.8.5_linux_amd64.tar.gz -o - | tar xzf - -C /tmp && \ mv /tmp/pgscv.yaml /etc && \ mv /tmp/pgscv.service /etc/systemd/system && \ mv /tmp/pgscv.default /etc/default/pgscv && \ diff --git a/internal/collector/patroni_common.go b/internal/collector/patroni_common.go index 10c9435..bc9cd7d 100644 --- a/internal/collector/patroni_common.go +++ b/internal/collector/patroni_common.go @@ -463,9 +463,13 @@ func parsePatroniResponse(resp *apiPatroniResponse) (*patroniInfo, error) { running = 1 } - t1, err := time.Parse("2006-01-02 15:04:05.999999Z07:00", resp.PmStartTime) - if err != nil { - return nil, fmt.Errorf("parse patroni postmaster_start_time string '%s' failed: %s", resp.PmStartTime, err) + var PmStartTimeSec float64 + if resp.PmStartTime != "null" && resp.PmStartTime != "" { + t1, err := time.Parse("2006-01-02 15:04:05.999999Z07:00", resp.PmStartTime) + if err != nil { + return nil, fmt.Errorf("parse patroni postmaster_start_time string '%s' failed: %s", resp.PmStartTime, err) + } + PmStartTimeSec = float64(t1.UnixNano()) / 1000000000 } var master, stdleader, replica float64 @@ -523,7 +527,7 @@ func parsePatroniResponse(resp *apiPatroniResponse) (*patroniInfo, error) { version: float64(version), versionStr: resp.Patroni.Version, running: running, - startTime: float64(t1.UnixNano()) / 1000000000, + startTime: PmStartTimeSec, master: master, standbyLeader: stdleader, replica: replica, diff --git a/internal/service/service.go b/internal/service/service.go index 5846e8c..54c005b 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -239,7 +239,7 @@ func attemptRequest(baseurl string) error { return err } - if resp.StatusCode != http.StatusOK { + if (resp.StatusCode != http.StatusOK) && (resp.StatusCode != 503) { return fmt.Errorf("bad response: %s", resp.Status) }