diff --git a/apps/nextcloud.go b/apps/nextcloud.go index a940e77..8c21cd5 100644 --- a/apps/nextcloud.go +++ b/apps/nextcloud.go @@ -2,17 +2,24 @@ package apps import ( "encoding/json" + "fmt" "net/http" + "os" "github.com/prometheus/client_golang/prometheus" ) type apiResponse struct { - version string + Version string `json:"version"` } func Nextcloud(m Metrics) { - var resp, err = http.Get("http://localhost:9000/status.php") + hostname, err := os.Hostname() + if err != nil { + return + } + + resp, err := http.Get(fmt.Sprintf("https://%s/status.php", hostname)) if err != nil { return } @@ -21,5 +28,5 @@ func Nextcloud(m Metrics) { var res = apiResponse{} json.NewDecoder(resp.Body).Decode(&res) - m.Nextcloud.With(prometheus.Labels{"version": res.version}).Set(1) + m.Nextcloud.With(prometheus.Labels{"version": res.Version}).Set(1) }