package net
import "github.com/shirou/gopsutil/net"
Index ¶
- type Addr
- type ConnectionStat
- func Connections(kind string) ([]ConnectionStat, error)
- func ConnectionsMax(kind string, max int) ([]ConnectionStat, error)
- func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error)
- func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error)
- func (n ConnectionStat) String() string
- type FilterStat
- type IOCountersStat
- func IOCounters(pernic bool) ([]IOCountersStat, error)
- func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error)
- func (n IOCountersStat) String() string
- type InterfaceAddr
- type InterfaceStat
- type ProtoCountersStat
Types ¶
type Addr ¶
Addr is implemented compatibility to psutil
func (Addr) String ¶
type ConnectionStat ¶
type ConnectionStat struct { Fd uint32 `json:"fd"` Family uint32 `json:"family"` Type uint32 `json:"type"` Laddr Addr `json:"localaddr"` Raddr Addr `json:"remoteaddr"` Status string `json:"status"` Uids []int32 `json:"uids"` Pid int32 `json:"pid"` }
func Connections ¶
func Connections(kind string) ([]ConnectionStat, error)
Return a list of network connections opened.
func ConnectionsMax ¶
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error)
Return a list of network connections opened returning at most `max` connections for each running process.
func ConnectionsPid ¶
func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error)
Return a list of network connections opened by a process.
func ConnectionsPidMax ¶
func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error)
Return up to `max` network connections opened by a process.
func (ConnectionStat) String ¶
func (n ConnectionStat) String() string
type FilterStat ¶
type FilterStat struct { ConnTrackCount int64 `json:"conntrackCount"` ConnTrackMax int64 `json:"conntrackMax"` }
func FilterCounters ¶
func FilterCounters() ([]FilterStat, error)
type IOCountersStat ¶
type IOCountersStat struct { Name string `json:"name"` // interface name BytesSent uint64 `json:"bytesSent"` // number of bytes sent BytesRecv uint64 `json:"bytesRecv"` // number of bytes received PacketsSent uint64 `json:"packetsSent"` // number of packets sent PacketsRecv uint64 `json:"packetsRecv"` // 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) Fifoin uint64 `json:"fifoin"` // total number of FIFO buffers errors while receiving Fifoout uint64 `json:"fifoout"` // total number of FIFO buffers errors while sending }
func IOCounters ¶
func IOCounters(pernic bool) ([]IOCountersStat, error)
example of `netstat -ibdnW` output on yosemite Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop lo0 16384 <Link#1> 869107 0 169411755 869107 0 169411755 0 0 lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - - lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - -
func IOCountersByFile ¶
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error)
NetIOCountersByFile is an method which is added just a compatibility for linux.
func (IOCountersStat) String ¶
func (n IOCountersStat) String() string
type InterfaceAddr ¶
type InterfaceAddr struct { Addr string `json:"addr"` }
NetInterfaceAddr is designed for represent interface addresses
func (InterfaceAddr) String ¶
func (n InterfaceAddr) String() string
type InterfaceStat ¶
type InterfaceStat struct { MTU int `json:"mtu"` // maximum transmission unit Name string `json:"name"` // e.g., "en0", "lo0", "eth0.100" HardwareAddr string `json:"hardwareaddr"` // IEEE MAC-48, EUI-48 and EUI-64 form Flags []string `json:"flags"` // e.g., FlagUp, FlagLoopback, FlagMulticast Addrs []InterfaceAddr `json:"addrs"` }
func Interfaces ¶
func Interfaces() ([]InterfaceStat, error)
func (InterfaceStat) String ¶
func (n InterfaceStat) String() string
type ProtoCountersStat ¶
type ProtoCountersStat struct { Protocol string `json:"protocol"` Stats map[string]int64 `json:"stats"` }
System wide stats about different network protocols
func ProtoCounters ¶
func ProtoCounters(protocols []string) ([]ProtoCountersStat, error)
NetProtoCounters returns network statistics for the entire system If protocols is empty then all protocols are returned, otherwise just the protocols in the list are returned. Not Implemented for Darwin
func (ProtoCountersStat) String ¶
func (n ProtoCountersStat) String() string
Source Files ¶
net.go net_darwin.go net_unix.go
- Version
- v2.16.12+incompatible
- Published
- Dec 24, 2016
- Platform
- darwin/amd64
- Imports
- 10 packages
- Last checked
- 13 hours ago –
Tools for package owners.