Do not use port 8618, it's a leftover from a time when we had two binaries.

Should fix 378 but needs testing from users having the problem since couldn't reproduce it here yet.
This commit is contained in:
Eugene Bujak
2018-10-17 18:55:27 +03:00
parent bdfb141d36
commit 5437a9d3a6
5 changed files with 22 additions and 196 deletions

View File

@@ -227,7 +227,7 @@ func (h *histogram) Collect(ch chan<- prometheus.Metric) {
// -----
// stats
// -----
func handleStats(w http.ResponseWriter, r *http.Request) {
func HandleStats(w http.ResponseWriter, r *http.Request) {
const numHours = 24
histrical := generateMapFromStats(&statistics.PerHour, 0, numHours)
// sum them up
@@ -299,7 +299,7 @@ func generateMapFromStats(stats *periodicStats, start int, end int) map[string]i
return result
}
func handleStatsHistory(w http.ResponseWriter, r *http.Request) {
func HandleStatsHistory(w http.ResponseWriter, r *http.Request) {
// handle time unit and prepare our time window size
now := time.Now()
timeUnitString := r.URL.Query().Get("time_unit")
@@ -378,6 +378,16 @@ func handleStatsHistory(w http.ResponseWriter, r *http.Request) {
}
}
func HandleStatsReset(w http.ResponseWriter, r *http.Request) {
purgeStats()
_, err := fmt.Fprintf(w, "OK\n")
if err != nil {
errortext := fmt.Sprintf("Couldn't write body: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
}
}
func clamp(value, low, high int) int {
if value < low {
return low