gopsutil: Index | Files

package net

import ""


Package Files

net.go net_linux.go


const (
    CT_ENTRIES = iota


var TCPStatuses = map[string]string{
    "01": "ESTABLISHED",
    "02": "SYN_SENT",
    "03": "SYN_RECV",
    "04": "FIN_WAIT1",
    "05": "FIN_WAIT2",
    "06": "TIME_WAIT",
    "07": "CLOSE",
    "08": "CLOSE_WAIT",
    "09": "LAST_ACK",
    "0A": "LISTEN",
    "0B": "CLOSING",

func Pids Uses

func Pids() ([]int32, error)

Pids retunres all pids. Note: this is a copy of process_linux.Pids() FIXME: Import process occures import cycle. move to common made other platform breaking. Need consider.

func PidsWithContext Uses

func PidsWithContext(ctx context.Context) ([]int32, error)

func Reverse Uses

func Reverse(s []byte) []byte

Reverse reverses array of bytes.

func ReverseWithContext Uses

func ReverseWithContext(ctx context.Context, s []byte) []byte

type Addr Uses

type Addr struct {
    IP   string `json:"ip"`
    Port uint32 `json:"port"`

Addr is implemented compatibility to psutil

func (Addr) String Uses

func (a Addr) String() string

type ConnectionStat Uses

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 Uses

func Connections(kind string) ([]ConnectionStat, error)

Return a list of network connections opened.

func ConnectionsMax Uses

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 ConnectionsMaxWithContext Uses

func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error)

func ConnectionsPid Uses

func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error)

Return a list of network connections opened by a process.

func ConnectionsPidMax Uses

func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error)

Return up to `max` network connections opened by a process.

func ConnectionsPidMaxWithContext Uses

func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error)

func ConnectionsPidWithContext Uses

func ConnectionsPidWithContext(ctx context.Context, kind string, pid int32) ([]ConnectionStat, error)

func ConnectionsWithContext Uses

func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error)

func (ConnectionStat) String Uses

func (n ConnectionStat) String() string

type ConntrackStat Uses

type ConntrackStat struct {
    Entries       uint32 `json:"entries"`        // Number of entries in the conntrack table
    Searched      uint32 `json:"searched"`       // Number of conntrack table lookups performed
    Found         uint32 `json:"found"`          // Number of searched entries which were successful
    New           uint32 `json:"new"`            // Number of entries added which were not expected before
    Invalid       uint32 `json:"invalid"`        // Number of packets seen which can not be tracked
    Ignore        uint32 `json:"ignore"`         // Packets seen which are already connected to an entry
    Delete        uint32 `json:"delete"`         // Number of entries which were removed
    DeleteList    uint32 `json:"delete_list"`    // Number of entries which were put to dying list
    Insert        uint32 `json:"insert"`         // Number of entries inserted into the list
    InsertFailed  uint32 `json:"insert_failed"`  // # insertion attempted but failed (same entry exists)
    Drop          uint32 `json:"drop"`           // Number of packets dropped due to conntrack failure.
    EarlyDrop     uint32 `json:"early_drop"`     // Dropped entries to make room for new ones, if maxsize reached
    IcmpError     uint32 `json:"icmp_error"`     // Subset of invalid. Packets that can't be tracked d/t error
    ExpectNew     uint32 `json:"expect_new"`     // Entries added after an expectation was already present
    ExpectCreate  uint32 `json:"expect_create"`  // Expectations added
    ExpectDelete  uint32 `json:"expect_delete"`  // Expectations deleted
    SearchRestart uint32 `json:"search_restart"` // Conntrack table lookups restarted due to hashtable resizes

ConntrackStat has conntrack summary info

func ConntrackStats Uses

func ConntrackStats(percpu bool) ([]ConntrackStat, error)

ConntrackStats returns more detailed info about the conntrack table

func ConntrackStatsWithContext Uses

func ConntrackStatsWithContext(ctx context.Context, percpu bool) ([]ConntrackStat, error)

ConntrackStatsWithContext returns more detailed info about the conntrack table

func NewConntrackStat Uses

func NewConntrackStat(e uint32, s uint32, f uint32, n uint32, inv uint32, ign uint32, del uint32, dlst uint32, ins uint32, insfail uint32, drop uint32, edrop uint32, ie uint32, en uint32, ec uint32, ed uint32, sr uint32) *ConntrackStat

func (ConntrackStat) String Uses

func (n ConntrackStat) String() string

type ConntrackStatList Uses

type ConntrackStatList struct {
    // contains filtered or unexported fields

func NewConntrackStatList Uses

func NewConntrackStatList() *ConntrackStatList

func (*ConntrackStatList) Append Uses

func (l *ConntrackStatList) Append(c *ConntrackStat)

func (*ConntrackStatList) Items Uses

func (l *ConntrackStatList) Items() []ConntrackStat

func (*ConntrackStatList) Summary Uses

func (l *ConntrackStatList) Summary() []ConntrackStat

Summary returns a single-element list with totals from all list items.

type FilterStat Uses

type FilterStat struct {
    ConnTrackCount int64 `json:"conntrackCount"`
    ConnTrackMax   int64 `json:"conntrackMax"`

func FilterCounters Uses

func FilterCounters() ([]FilterStat, error)

NetFilterCounters returns iptables conntrack statistics the currently in use conntrack count and the max. If the file does not exist or is invalid it will return nil.

func FilterCountersWithContext Uses

func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error)

type IOCountersStat Uses

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 Uses

func IOCounters(pernic bool) ([]IOCountersStat, error)

NetIOCounters returnes network I/O statistics for every network interface installed on the system. If pernic argument is false, return only sum of all information (which name is 'all'). If true, every network interface installed on the system is returned separately.

func IOCountersByFile Uses

func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error)

func IOCountersByFileWithContext Uses

func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error)

func IOCountersWithContext Uses

func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error)

func (IOCountersStat) String Uses

func (n IOCountersStat) String() string

type InterfaceAddr Uses

type InterfaceAddr struct {
    Addr string `json:"addr"`

NetInterfaceAddr is designed for represent interface addresses

func (InterfaceAddr) String Uses

func (n InterfaceAddr) String() string

type InterfaceStat Uses

type InterfaceStat struct {
    Index        int             `json:"index"`
    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 Uses

func Interfaces() ([]InterfaceStat, error)

func InterfacesWithContext Uses

func InterfacesWithContext(ctx context.Context) ([]InterfaceStat, error)

func (InterfaceStat) String Uses

func (n InterfaceStat) String() string

type ProtoCountersStat Uses

type ProtoCountersStat struct {
    Protocol string           `json:"protocol"`
    Stats    map[string]int64 `json:"stats"`

System wide stats about different network protocols

func ProtoCounters Uses

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. Available protocols:


func ProtoCountersWithContext Uses

func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error)

func (ProtoCountersStat) String Uses

func (n ProtoCountersStat) String() string

Package net imports 14 packages (graph). Updated 2019-11-04. Refresh now. Tools for package owners.