1
0
Fork 0
mirror of https://github.com/Luzifer/promcertcheck.git synced 2024-11-09 16:30:04 +00:00

Introduce /httpStatus endpoint

which will respond with HTTP200 if everything is fine or HTTP500 if one
or more certificates are broken

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-06-26 15:08:54 +02:00
parent c3f86a29f0
commit 357693db38
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 12 additions and 0 deletions

11
http.go
View file

@ -26,6 +26,17 @@ func htmlHandler(res http.ResponseWriter, r *http.Request) {
}, res)
}
func httpStatusHandler(res http.ResponseWriter, r *http.Request) {
httpStatus := http.StatusOK
for _, mon := range probeMonitors {
if mon.Status != certificateOK {
httpStatus = http.StatusInternalServerError
}
}
res.WriteHeader(httpStatus)
}
func jsonHandler(res http.ResponseWriter, r *http.Request) {
res.Header().Set("Content-Type", "application/json")
json.NewEncoder(res).Encode(probeMonitors)

View file

@ -61,6 +61,7 @@ func main() {
r := mux.NewRouter()
r.Handle("/metrics", prometheus.Handler())
r.HandleFunc("/", htmlHandler)
r.HandleFunc("/httpStatus", httpStatusHandler)
r.HandleFunc("/results.json", jsonHandler)
http.ListenAndServe(":3000", r)
}