@@ -21,8 +21,9 @@ import (
2121 "github.com/serverledge-faas/serverledge/utils"
2222 "go.opentelemetry.io/otel/attribute"
2323
24- "github.com/serverledge-faas/serverledge/internal/scheduling"
2524 "github.com/labstack/echo/v4"
25+ "github.com/mikoim/go-loadavg"
26+ "github.com/serverledge-faas/serverledge/internal/scheduling"
2627)
2728
2829var requestsPool = sync.Pool {
@@ -209,14 +210,23 @@ func DecodeServiceClass(serviceClass string) (p function.ServiceClass) {
209210func GetServerStatus (c echo.Context ) error {
210211 node .Resources .RLock ()
211212 defer node .Resources .RUnlock ()
213+
212214 portNumber := config .GetInt ("api.port" , 1323 )
213215 url := fmt .Sprintf ("http://%s:%d" , utils .GetIpAddress ().String (), portNumber )
216+
217+ loadAvg , err := loadavg .Parse ()
218+ loadAvgValues := []float64 {- 1.0 , - 1.0 , - 1.0 }
219+ if err == nil {
220+ loadAvgValues = []float64 {loadAvg .LoadAverage1 , loadAvg .LoadAverage5 , loadAvg .LoadAverage10 }
221+ }
222+
214223 response := registration.StatusInformation {
215- Url : url ,
216- AvailableMemMB : node .Resources .AvailableMemMB ,
217- AvailableCPUs : node .Resources .AvailableCPUs ,
218- DropCount : node .Resources .DropCount ,
219- Coordinates : * registration .Reg .Client .GetCoordinate (),
224+ Url : url ,
225+ AvailableWarmContainers : node .WarmStatus (),
226+ AvailableMemMB : node .Resources .AvailableMemMB ,
227+ AvailableCPUs : node .Resources .AvailableCPUs ,
228+ Coordinates : * registration .Reg .Client .GetCoordinate (),
229+ LoadAvg : loadAvgValues ,
220230 }
221231
222232 return c .JSON (http .StatusOK , response )
0 commit comments