Implement a web agent service that monitors a server.
Use asynchronous IO with tokio. Read the tutorial before starting the server.
Integrate Tokio Console for an overview of your tasks.
- Work in teams
- Use any way of solving the requests
- read the
/proc
manually - use additional crates
Method: GET
{
"cpus": 2,
"memory": {
"total": 100,
"used": 30
},
"uptime": 10,
"usage": 30
}
List the cpus
Method: GET
[
{
"model": "cpu model",
"manufacturer": "cpu manufacturer",
"speed": 1000,
"usage": 30
}
]
List the information about one cpu
Methods: GET
{
"model": "cpu model",
"manufacturer": "cpu manufacturer",
"speed": 1000,
"usage": 30
}
Return the list of processes
[
{
"pid": 2100,
"ppid": 1000,
"command": "....",
"arguments": ["...", "..."],
"memory": {
"vsz": 1000,
"rss": 300
}
},
]
A query string might be supplied specifying the parameters to show. Ex: "?pid=true&memory=true" returns only the pid and command. Hint: Use
Option
in the structure.
Return information about a process
{
"command": "....",
"arguments": ["...", "..."],
"memory": {
"vsz": 1000,
"rss": 300
}
}
Stop a process
{
"status": "ok or error",
"error": 0
}
Method POST
{
"command": "command to run",
"arguments": ["argument1", "argument2"],
"environment" {
"variable1": "value",
"variable2": "value",
"variable3": "value"
}
}
Response
{
"status": "ok or error",
"stdout": "",
"stderr": ""
"error": 0
}
Modify the route to start the process and immediately return and add another route that ca verify the status of the process and return the partial output and error streams.