refactor: prefer pg_config in place of psql for postgres version

This commit is contained in:
Valentin Doreau 2024-11-02 19:11:59 +01:00
parent 4e72d46ef4
commit b0cf387655
Signed by: vdoreau
GPG key ID: F3E456CF9A14098B

View file

@ -9,13 +9,13 @@ import (
)
func Postgres(m Metrics) {
out, err := exec.Command("psql", "--version").Output()
out, err := exec.Command("pg_config", "--version").Output()
if err != nil {
log.Printf(">> WARN: Unable to get Postgres version: %v", err)
return
}
version := strings.Split(string(out), " ")[2]
version := strings.Split(string(out), " ")[1]
m.Postgres.With(prometheus.Labels{"version": version}).Set(1)
}