Skip to content

UPB-RustWorkshop/web-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Agent

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.

Requirements

  1. Work in teams
  2. Use any way of solving the requests
  • read the /proc manually
  • use additional crates

Routes

/status

Method: GET

{
    "cpus": 2,
    "memory": {
        "total": 100,
        "used": 30
    },
    "uptime": 10,
    "usage": 30
}

/cpus

List the cpus

Method: GET

[
    {
        "model": "cpu model",
        "manufacturer": "cpu manufacturer",
        "speed": 1000,
        "usage": 30
    }
]

/cpus/<cpu_number>

List the information about one cpu

Methods: GET

{
    "model": "cpu model",
    "manufacturer": "cpu manufacturer",
    "speed": 1000,
    "usage": 30
}

/processes

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.

/processes/<pid>

Return information about a process

{
    "command": "....",
    "arguments": ["...", "..."],
    "memory": {
        "vsz": 1000,
        "rss": 300
    }
}

/processes/kill/<pid>

Stop a process

{
    "status": "ok or error",
    "error": 0
}

/processes/start

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published