xamfy / x-server-stats

A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems.
https://crates.io/crates/x-server-stats
Apache License 2.0
12 stars 4 forks source link

Create a stats GET API endpoint to fetch stats data over REST #5

Closed xamfy closed 2 years ago

xamfy commented 2 years ago

TODO:

ChellappanRajan commented 2 years ago

Hi @xamfy I would like to take this issue, Could you please assign it to me and explain little more about this issue.

xamfy commented 2 years ago

Assigned it to you.

Basically we want to do the same thing that we talked about in the websocket task, but here it's just a GET API endpoint, to fetch the server stats (like cpu usage, memory usage, cpu load). We can start with these three first and then take it from there at a later point or discuss in the PR.

The response will be JSON. If you're familiar with react, you can even showcase the response in form of a dashboard, I can setup a separate repo for that, which will basically act as a frontend for x-server-stats(for REST API responses, websocket and server sent event responses).

Sample response:

{
  "result": true,
  "data": {
    "cpuLoad": "XYZ",
    "memoryUsage": "XYZ",
    "loadAverage": "XYZ"
  }
}

Result will be false, if any error occurred, and true in case of success. We want to wrap the logic of success and data in two objects namely result and data to maintain consistency in API reponses.