Set session host

Add ping to L2 router
This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-08-08 10:10:52 -03:00
parent ed7cefcf9c
commit 0e9716d5b0
9 changed files with 76 additions and 61 deletions

View File

@@ -1,23 +1,6 @@
package handlers
import (
"log"
"net/http"
"github.com/play-with-docker/play-with-docker/config"
"github.com/shirou/gopsutil/load"
)
import "net/http"
func Ping(rw http.ResponseWriter, req *http.Request) {
// Get system load average of the last 5 minutes and compare it against a threashold.
a, err := load.Avg()
if err != nil {
log.Println("Cannot get system load average!", err)
} else {
if a.Load5 > config.MaxLoadAvg {
log.Printf("System load average is too high [%f]\n", a.Load5)
rw.WriteHeader(http.StatusInsufficientStorage)
}
}
}