Skip to content

Commit

Permalink
check cpu-load api
Browse files Browse the repository at this point in the history
  • Loading branch information
babos77 committed Dec 16, 2020
1 parent 27f047b commit e3b8615
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions api/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,33 @@ func StartAPI() {
// $ref: '#/definitions/OutputError'
e.POST("/check/memory-usage", checkMemoryUsage)

// swagger:operation POST /check/cpu-load check checkCpuLoad
// ---
// summary: Read out the cpu load of a device.
// consumes:
// - application/json
// - application/xml
// produces:
// - application/json
// - application/xml
// parameters:
// - name: body
// in: body
// description: Request to process.
// required: true
// schema:
// $ref: '#/definitions/CheckCpuLoadRequest'
// responses:
// 200:
// description: Returns the response.
// schema:
// $ref: '#/definitions/CheckCpuLoadResponse'
// 400:
// description: Returns an error with more details in the body.
// schema:
// $ref: '#/definitions/OutputError'
e.POST("/check/cpu-load", checkCpuLoad)

// swagger:operation POST /check/metrics check checkMetrics
// ---
// summary: Prints all available metrics for a device as performance data.
Expand Down Expand Up @@ -517,6 +544,18 @@ func checkMemoryUsage(ctx echo.Context) error {
return returnInFormat(ctx, http.StatusOK, resp)
}

func checkCpuLoad(ctx echo.Context) error {
r := request.CheckCPULoadRequest{}
if err := ctx.Bind(&r); err != nil {
return err
}
resp, err := handleAPIRequest(&r, &r.BaseRequest.DeviceData.IPAddress)
if err != nil {
return handleError(ctx, err)
}
return returnInFormat(ctx, http.StatusOK, resp)
}

func checkMetrics(ctx echo.Context) error {
r := request.CheckMetricsRequest{}
if err := ctx.Bind(&r); err != nil {
Expand Down

0 comments on commit e3b8615

Please sign in to comment.