diff --git a/net.go b/net.go index 7864bd0..065159d 100644 --- a/net.go +++ b/net.go @@ -31,12 +31,12 @@ type NetConnectionStat struct { Pid int32 `json:"pid"` } -func (n NetConnectionStat) String() string { +func (n NetIOCountersStat) String() string { s, _ := json.Marshal(n) return string(s) } -func (n NetIOCountersStat) String() string { +func (n NetConnectionStat) String() string { s, _ := json.Marshal(n) return string(s) } diff --git a/process_linux.go b/process_linux.go index 96d65c5..943d142 100644 --- a/process_linux.go +++ b/process_linux.go @@ -10,6 +10,7 @@ import ( "strconv" "strings" "syscall" + "encoding/json" ) const ( @@ -26,6 +27,10 @@ type MemoryInfoExStat struct { Data uint64 `json:"data"` // bytes Dirty uint64 `json:"dirty"` // bytes } +func (m MemoryInfoExStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} type MemoryMapsStat struct { Path string `json:"path"` @@ -41,6 +46,13 @@ type MemoryMapsStat struct { Swap uint64 `json:"swap"` } +func (m MemoryMapsStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} + + + // Create new Process instance // This only stores Pid func NewProcess(pid int32) (*Process, error) {