summaryrefslogtreecommitdiffstats
path: root/widgets/proc_freebsd.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/proc_freebsd.go')
-rw-r--r--widgets/proc_freebsd.go66
1 files changed, 0 insertions, 66 deletions
diff --git a/widgets/proc_freebsd.go b/widgets/proc_freebsd.go
deleted file mode 100644
index ac3e73f..0000000
--- a/widgets/proc_freebsd.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package widgets
-
-import (
- "encoding/json"
- "fmt"
- "log"
- "os/exec"
- "strconv"
- "strings"
-
- "github.com/xxxserxxx/gotop/utils"
-)
-
-type processList struct {
- ProcessInformation struct {
- Process []struct {
- Pid string `json:"pid"`
- Comm string `json:"command"`
- Cpu string `json:"percent-cpu" `
- Mem string `json:"percent-memory" `
- Args string `json:"arguments" `
- } `json:"process"`
- } `json:"process-information"`
-}
-
-func getProcs() ([]Proc, error) {
- output, err := exec.Command("ps", "-axo pid,comm,%cpu,%mem,args", "--libxo", "json").Output()
- if err != nil {
- return nil, fmt.Errorf("failed to execute 'ps' command: %v", err)
- }
-
- list := processList{}
- err = json.Unmarshal(output, &list)
- if err != nil {
- return nil, fmt.Errorf("failed to unmarshal json. %s", err)
- }
- procs := []Proc{}
-
- for _, process := range list.ProcessInformation.Process {
- if process.Comm == "idle" {
- continue
- }
- pid, err := strconv.Atoi(strings.TrimSpace(process.Pid))
- if err != nil {
- log.Printf("failed to convert first field to int: %v. split: %v", err, process)
- }
- cpu, err := strconv.ParseFloat(utils.ConvertLocalizedString(process.Cpu), 32)
- if err != nil {
- log.Printf("failed to convert third field to float: %v. split: %v", err, process)
- }
- mem, err := strconv.ParseFloat(utils.ConvertLocalizedString(process.Mem), 32)
- if err != nil {
- log.Printf("failed to convert fourth field to float: %v. split: %v", err, process)
- }
- proc := Proc{
- Pid: pid,
- CommandName: process.Comm,
- Cpu: cpu,
- Mem: mem,
- FullCommand: process.Args,
- }
- procs = append(procs, proc)
- }
-
- return procs, nil
-}