summaryrefslogtreecommitdiff
path: root/process
diff options
context:
space:
mode:
authorPaul Buetow (europa) <paul@buetow.org>2015-05-25 21:57:13 +0100
committerPaul Buetow (europa) <paul@buetow.org>2015-05-25 21:57:13 +0100
commitb41d48ef0817025251ce080578168fd85cab15f9 (patch)
tree6c9f11e599d4c1f02274efe16f6bdc378ad20ae5 /process
parent10074fefc76404a1be7bddcc2b9d18bc0ee44056 (diff)
store prev results into a process map
Diffstat (limited to 'process')
-rw-r--r--process/process.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/process/process.go b/process/process.go
index 5e8366f..dade966 100644
--- a/process/process.go
+++ b/process/process.go
@@ -8,13 +8,16 @@ import (
"regexp"
"strconv"
"strings"
+ "time"
)
type Process struct {
- Pid int
- Cmdline string
- Count map[string]int
- debug string
+ Id string
+ Timestamp int32
+ Pid int
+ Cmdline string
+ Count map[string]int
+ debug string
}
func new(pidstr string) (Process, error) {
@@ -23,7 +26,8 @@ func new(pidstr string) (Process, error) {
return Process{}, err
}
- p := Process{Pid: pid}
+ timestamp := int32(time.Now().Unix())
+ p := Process{Pid: pid, Timestamp: timestamp}
var rawIo string
if err = utils.Slurp(&rawIo, fmt.Sprintf("/proc/%d/io", pid)); err != nil {
@@ -35,6 +39,7 @@ func new(pidstr string) (Process, error) {
}
err = utils.Slurp(&p.Cmdline, fmt.Sprintf("/proc/%d/cmdline", pid))
+ p.Id = pidstr + " " + p.Cmdline
return p, err
}
@@ -69,6 +74,7 @@ func (self *Process) String() string {
str += fmt.Sprintf("PID: %d\n", self.Pid)
str += fmt.Sprintf("Cmdline: %s\n", self.Cmdline)
+ str += fmt.Sprintf("Timestamp: %s\n", self.Timestamp)
for key, val := range self.Count {
str += fmt.Sprintf("%s=%d\n", key, val)
}