more abstraction and simple dashboard for processes
All checks were successful
Build Process Supervisor / build (amd64, .exe, windows) (push) Successful in 2m24s
Build Process Supervisor / build (amd64, , linux) (push) Successful in 2m36s
Build Process Supervisor / build (arm, 6, , linux) (push) Successful in 2m19s
Build Process Supervisor / build (arm64, , linux) (push) Successful in 2m14s

This commit is contained in:
Adrian Zürcher
2025-08-06 13:57:34 +02:00
parent e188813adf
commit 9f262c4a55
17 changed files with 428 additions and 564 deletions

58
htop/models/process.go Normal file
View File

@@ -0,0 +1,58 @@
package models
import (
"fmt"
ps "github.com/shirou/gopsutil/v3/process"
)
type Process struct {
PID string
User string
Cmd string
CPU float64
Memory uint64
}
func GetProcesses() ([]Process, error) {
processes, err := ps.Processes()
if err != nil {
return nil, err
}
var result []Process
for _, p := range processes {
pid := p.Pid
name, err := p.Name()
if err != nil {
continue
}
user, err := p.Username()
if err != nil {
user = "unknown"
}
cpu, err := p.CPUPercent()
if err != nil {
cpu = 0
}
memInfo, err := p.MemoryInfo()
if err != nil {
continue
}
result = append(result, Process{
PID: fmt.Sprintf("%d", pid),
User: user,
Cmd: name,
CPU: cpu,
Memory: memInfo.RSS,
})
}
return result, nil
}