Skip to content
ravenclaw900 edited this page Dec 30, 2021 · 4 revisions

The public API of the dashboard/DietPi system is exposed through a WebSocket connection to your.IP:5252/ws. Currently, it is meant to be used with the pages of the dashboard, and some of the terms used when sending messages back and forth reflect that. All the messages are in JSON. If login is enabled, you will need to get a token from /login, and use it in the token field with all communications.

Statistics page

Send:

{
  "page": "/"
}

Receive: Repeating stream of statistics, coming approximately every second.

{
  "cpu": 0.0,
  "ram": {
    "used": 0,
    "total": 0,
    "percent": 0.0
  },
  "swap": {
    "used": 0,
    "total": 0,
    "percent": 0.0
  },
  "disk": {
    "used": 0,
    "total": 0,
    "percent": 0.0
  },
  "network": {
    "sent": 0,
    "recieved": 0
  }
}
  • cpu: percentage of CPU used
  • ram/swap/disk:
    • used: used amount, in bytes
    • total: total amount, in bytes
    • percent: usage percent, used/total*100
  • network:
    • sent: number of sent bytes since last recieved
    • received: number of received bytes since last recieved

Process page

Send:

{
  "page": "/process"
}

Receive: Repeating stream of process data, coming approximately every second.

{
  "processes": [
    {
      "pid": 0,
      "name": "",
      "cpu": 0.0,
      "ram": 0,
      "status": ""
    },
  ]
}
  • processes: list of processes
    • pid: process ID
    • name: process name
    • cpu: process CPU usage
    • ram: process RAM usage
    • status: process status, one of "running", "idle", "stopped", "zombie", "dead", or "unknown"

Process control

While on process page:
Send:

{
  "cmd": "terminate/kill/suspend/resume",
  "args": ["pid (as string)"]
}

Receive: N/A

Performs the action on the process.

Clone this wiki locally