Valentin Doreau
15b78c2f0c
All checks were successful
Build package / typos (push) Successful in 1m40s
32 lines
534 B
Go
32 lines
534 B
Go
package apps
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type apiResponse struct {
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
func Nextcloud(m Metrics) {
|
|
hostname, err := os.Hostname()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
resp, err := http.Get(fmt.Sprintf("https://%s/status.php", hostname))
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
var res = apiResponse{}
|
|
json.NewDecoder(resp.Body).Decode(&res)
|
|
|
|
m.Nextcloud.With(prometheus.Labels{"version": res.Version}).Set(1)
|
|
}
|