2024-10-31 20:42:28 +01:00
|
|
|
package apps
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2024-12-05 14:40:50 +01:00
|
|
|
"fmt"
|
2024-10-31 20:42:28 +01:00
|
|
|
"net/http"
|
2024-12-05 14:40:50 +01:00
|
|
|
"os"
|
2024-10-31 20:42:28 +01:00
|
|
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
type apiResponse struct {
|
2024-12-05 14:40:50 +01:00
|
|
|
Version string `json:"version"`
|
2024-10-31 20:42:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func Nextcloud(m Metrics) {
|
2024-12-05 14:40:50 +01:00
|
|
|
hostname, err := os.Hostname()
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := http.Get(fmt.Sprintf("https://%s/status.php", hostname))
|
2024-10-31 20:42:28 +01:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var res = apiResponse{}
|
|
|
|
json.NewDecoder(resp.Body).Decode(&res)
|
|
|
|
|
2024-12-05 14:40:50 +01:00
|
|
|
m.Nextcloud.With(prometheus.Labels{"version": res.Version}).Set(1)
|
2024-10-31 20:42:28 +01:00
|
|
|
}
|