mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 11:44:51 +00:00
turn process monitoring events into structured objects
This commit is contained in:
@@ -1,13 +1,33 @@
|
||||
package psscanner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type PSScanner struct{}
|
||||
|
||||
type PSEvent struct {
|
||||
UID int
|
||||
PID int
|
||||
CMD string
|
||||
}
|
||||
|
||||
func (evt PSEvent) String() string {
|
||||
uid := strconv.Itoa(evt.UID)
|
||||
if evt.UID == -1 {
|
||||
uid = "???"
|
||||
}
|
||||
|
||||
return fmt.Sprintf("UID=%-4s PID=%-6d | %s", uid, evt.PID, evt.CMD)
|
||||
}
|
||||
|
||||
func NewPSScanner() *PSScanner {
|
||||
return &PSScanner{}
|
||||
}
|
||||
|
||||
func (p *PSScanner) Run(triggerCh chan struct{}) (chan string, chan error) {
|
||||
eventCh := make(chan string, 100)
|
||||
func (p *PSScanner) Run(triggerCh chan struct{}) (chan PSEvent, chan error) {
|
||||
eventCh := make(chan PSEvent, 100)
|
||||
errCh := make(chan error)
|
||||
pl := make(procList)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user