nux

package
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 16 Imported by: 6

README

nux

*nux metric collector

Documentation

Overview

Package ntp provides a simple mechanism for querying the current time from a remote NTP server. This package only supports NTP client mode behavior and version 4 of the NTP protocol. See RFC 5905. Approach inspired by go-nuts post by Michael Hofmann: https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/FlcdMU5fkLQ

Index

Constants

View Source
const (
	BITS_PER_BYTE = 8
	MILLION_BIT   = 1000000
)

Variables

View Source
var FSFILE_PREFIX_IGNORE = []string{
	"/dev",
	"/sys",
	"/net",
	"/misc",
	"/proc",
	"/lib",
}
View Source
var FSSPEC_IGNORE = map[string]struct{}{
	"none":  struct{}{},
	"nodev": struct{}{},
	"tmpfs": struct{}{},
	"shm":   struct{}{},
	"proc":  struct{}{},
}
View Source
var FSTYPE_IGNORE = map[string]struct{}{
	"cgroup":     struct{}{},
	"debugfs":    struct{}{},
	"devtmpfs":   struct{}{},
	"rpc_pipefs": struct{}{},
	"rootfs":     struct{}{},
}
View Source
var Multi uint64 = 1024
View Source
var WANT = map[string]struct{}{
	"Buffers:":      struct{}{},
	"Cached:":       struct{}{},
	"MemTotal:":     struct{}{},
	"MemFree:":      struct{}{},
	"MemAvailable:": struct{}{},
	"SwapTotal:":    struct{}{},
	"SwapFree:":     struct{}{},
}

Functions

func CpuMHz

func CpuMHz() (mhz string, err error)

func IgnoreFsFile

func IgnoreFsFile(fs_file string) bool

func KernelAllocateFiles

func KernelAllocateFiles() (ret uint64, err error)

func KernelHostname

func KernelHostname() (string, error)

func KernelMaxFiles

func KernelMaxFiles() (uint64, error)

func KernelMaxProc

func KernelMaxProc() (uint64, error)

func ListMountPoint

func ListMountPoint() ([][3]string, error)

return: [][$fs_spec, $fs_file, $fs_vfstype]

func ListeningPorts

func ListeningPorts() ([]int64, error)

ListeningPorts 为了兼容老代码

func Netstat

func Netstat(ext string) (ret map[string]uint64, err error)

@param ext e.g. TcpExt or IpExt

func NtpTime

func NtpTime(host string, timeout ...int64) (time.Time, error)

Time returns the "receive time" from the remote NTP server specifed as host. NTP client mode version 4 is used.

func NtpTimeV

func NtpTimeV(host string, version byte, timeout ...int64) (time.Time, error)

TimeV returns the "receive time" from the remote NTP server specifed as host. Use the NTP client mode with the requested version number (2, 3, or 4).

func NtpTwoTime

func NtpTwoTime(host string, timeout ...int64) (time.Time, time.Time, error)

Time returns the "receive time" from the remote NTP server specifed as host. NTP client mode version 4 is used.

func NumCpu

func NumCpu() int

func ReadName

func ReadName(path string) (name string, err error)

func Snmp

func Snmp(title string) (ret map[string]int64, err error)

func SocketStatSummary

func SocketStatSummary() (m map[string]uint64, err error)

func SystemUptime

func SystemUptime() (days, hours, mins int64, err error)

func TcpPorts

func TcpPorts() ([]int64, error)

func UdpPorts

func UdpPorts() ([]int64, error)

Types

type CpuUsage

type CpuUsage struct {
	User    uint64 // time spent in user mode
	Nice    uint64 // time spent in user mode with low priority (nice)
	System  uint64 // time spent in system mode
	Idle    uint64 // time spent in the idle task
	Iowait  uint64 // time spent waiting for I/O to complete (since Linux 2.5.41)
	Irq     uint64 // time spent servicing  interrupts  (since  2.6.0-test4)
	SoftIrq uint64 // time spent servicing softirqs (since 2.6.0-test4)
	Steal   uint64 // time spent in other OSes when running in a virtualized environment (since 2.6.11)
	Guest   uint64 // time spent running a virtual CPU for guest operating systems under the control of the Linux kernel. (since 2.6.24)
	Total   uint64 // total of all time fields
}

func (*CpuUsage) String

func (this *CpuUsage) String() string

type DeviceUsage

type DeviceUsage struct {
	FsSpec            string
	FsFile            string
	FsVfstype         string
	BlocksAll         uint64
	BlocksUsed        uint64
	BlocksFree        uint64
	BlocksUsedPercent float64
	BlocksFreePercent float64
	InodesAll         uint64
	InodesUsed        uint64
	InodesFree        uint64
	InodesUsedPercent float64
	InodesFreePercent float64
}

func BuildDeviceUsage

func BuildDeviceUsage(_fsSpec, _fsFile, _fsVfstype string) (*DeviceUsage, error)

func (*DeviceUsage) String

func (this *DeviceUsage) String() string

type DiskStats

type DiskStats struct {
	Major             int
	Minor             int
	Device            string
	ReadRequests      uint64 // Total number of reads completed successfully.
	ReadMerged        uint64 // Adjacent read requests merged in a single req.
	ReadSectors       uint64 // Total number of sectors read successfully.
	MsecRead          uint64 // Total number of ms spent by all reads.
	WriteRequests     uint64 // total number of writes completed successfully.
	WriteMerged       uint64 // Adjacent write requests merged in a single req.
	WriteSectors      uint64 // total number of sectors written successfully.
	MsecWrite         uint64 // Total number of ms spent by all writes.
	IosInProgress     uint64 // Number of actual I/O requests currently in flight.
	MsecTotal         uint64 // Amount of time during which ios_in_progress >= 1.
	MsecWeightedTotal uint64 // Measure of recent I/O completion time and backlog.
	TS                time.Time
}

func ListDiskStats

func ListDiskStats() ([]*DiskStats, error)

func (*DiskStats) String

func (this *DiskStats) String() string

type Loadavg

type Loadavg struct {
	Avg1min  float64
	Avg5min  float64
	Avg15min float64
}

func LoadAvg

func LoadAvg() (*Loadavg, error)

func (*Loadavg) String

func (this *Loadavg) String() string

type Mem

type Mem struct {
	Buffers      uint64
	Cached       uint64
	MemTotal     uint64
	MemFree      uint64
	MemAvailable uint64
	SwapTotal    uint64
	SwapUsed     uint64
	SwapFree     uint64
}

func MemInfo

func MemInfo() (*Mem, error)

func (*Mem) String

func (this *Mem) String() string

type NetIf

type NetIf struct {
	Iface          string
	InBytes        int64
	InPackages     int64
	InErrors       int64
	InDropped      int64
	InFifoErrs     int64
	InFrameErrs    int64
	InCompressed   int64
	InMulticast    int64
	OutBytes       int64
	OutPackages    int64
	OutErrors      int64
	OutDropped     int64
	OutFifoErrs    int64
	OutCollisions  int64
	OutCarrierErrs int64
	OutCompressed  int64
	TotalBytes     int64
	TotalPackages  int64
	TotalErrors    int64
	TotalDropped   int64
	SpeedBits      int64
	InPercent      float64
	OutPercent     float64
}

func NetIfs

func NetIfs(onlyPrefix []string) ([]*NetIf, error)

Inter-| Receive | Transmit

face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
 eth0: 1990350    2838    0    0    0     0          0         0   401351    2218    0    0    0     0       0          0
   lo:   26105     286    0    0    0     0          0         0    26105     286    0    0    0     0       0          0

func (*NetIf) String

func (this *NetIf) String() string

type Proc

type Proc struct {
	Pid     int
	Name    string
	Cmdline string
}

func AllProcs

func AllProcs() (ps []*Proc, err error)

func (*Proc) String

func (this *Proc) String() string

type ProcStat

type ProcStat struct {
	Cpu          *CpuUsage
	Cpus         []*CpuUsage
	Ctxt         uint64
	Processes    uint64
	ProcsRunning uint64
	ProcsBlocked uint64
}

func CurrentProcStat

func CurrentProcStat() (*ProcStat, error)

func (*ProcStat) String

func (this *ProcStat) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL