feat: use hostname to query nextcloud version
All checks were successful
Build package / typos (push) Successful in 1m40s
All checks were successful
Build package / typos (push) Successful in 1m40s
This commit is contained in:
parent
009f07e0af
commit
15b78c2f0c
1 changed files with 10 additions and 3 deletions
|
@ -2,17 +2,24 @@ package apps
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type apiResponse struct {
|
type apiResponse struct {
|
||||||
version string
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Nextcloud(m Metrics) {
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -21,5 +28,5 @@ func Nextcloud(m Metrics) {
|
||||||
var res = apiResponse{}
|
var res = apiResponse{}
|
||||||
json.NewDecoder(resp.Body).Decode(&res)
|
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue