@@ -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 {
@@ -204,14 +205,23 @@ func DecodeServiceClass(serviceClass string) (p function.ServiceClass) {
204205func GetServerStatus (c echo.Context ) error {
205206 node .Resources .RLock ()
206207 defer node .Resources .RUnlock ()
208+
207209 portNumber := config .GetInt ("api.port" , 1323 )
208210 url := fmt .Sprintf ("http://%s:%d" , utils .GetIpAddress ().String (), portNumber )
211+
212+ loadAvg , err := loadavg .Parse ()
213+ loadAvgValues := []float64 {- 1.0 , - 1.0 , - 1.0 }
214+ if err == nil {
215+ loadAvgValues = []float64 {loadAvg .LoadAverage1 , loadAvg .LoadAverage5 , loadAvg .LoadAverage10 }
216+ }
217+
209218 response := registration.StatusInformation {
210- Url : url ,
211- AvailableMemMB : node .Resources .AvailableMemMB ,
212- AvailableCPUs : node .Resources .AvailableCPUs ,
213- DropCount : node .Resources .DropCount ,
214- Coordinates : * registration .Reg .Client .GetCoordinate (),
219+ Url : url ,
220+ AvailableWarmContainers : node .WarmStatus (),
221+ AvailableMemMB : node .Resources .AvailableMemMB ,
222+ AvailableCPUs : node .Resources .AvailableCPUs ,
223+ Coordinates : * registration .Reg .Client .GetCoordinate (),
224+ LoadAvg : loadAvgValues ,
215225 }
216226
217227 return c .JSON (http .StatusOK , response )
0 commit comments