1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-28 13:48:49 +08:00

48 lines
1.3 KiB
Go
Raw Normal View History

2014-04-23 12:51:28 +09:00
package gopsutil
import (
"encoding/json"
)
2014-04-30 15:32:05 +09:00
type NetIOCountersStat struct {
Name string `json:"name"` // interface name
BytesSent uint64 `json:"bytes_sent"` // number of bytes sent
2014-04-30 15:32:05 +09:00
BytesRecv uint64 `json:"bytes_recv"` // number of bytes received
PacketsSent uint64 `json:"packets_sent"` // number of packets sent
PacketsRecv uint64 `json:"packets_recv"` // number of packets received
Errin uint64 `json:"errin"` // total number of errors while receiving
Errout uint64 `json:"errout"` // total number of errors while sending
Dropin uint64 `json:"dropin"` // total number of incoming packets which were dropped
Dropout uint64 `json:"dropout"` // total number of outgoing packets which were dropped (always 0 on OSX and BSD)
2014-04-23 12:51:28 +09:00
}
type Addr struct {
2014-04-30 16:42:08 +09:00
IP string `json:"ip"`
Port uint32 `json:"port"`
2014-04-23 12:51:28 +09:00
}
2014-04-30 15:32:05 +09:00
type NetConnectionStat struct {
2014-04-30 16:42:08 +09:00
Fd uint32 `json:"fd"`
Family uint32 `json:"family"`
Type uint32 `json:"type"`
Laddr Addr `json:"laddr"`
Raddr Addr `json:"raddr"`
Status string `json:"status"`
Pid int32 `json:"pid"`
2014-04-23 12:51:28 +09:00
}
func (n NetConnectionStat) String() string {
s, _ := json.Marshal(n)
return string(s)
}
func (n NetIOCountersStat) String() string {
s, _ := json.Marshal(n)
return string(s)
}
func (a Addr) String() string {
s, _ := json.Marshal(a)
return string(s)
}