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
- Variables
- func CpuMHz() (mhz string, err error)
- func IgnoreFsFile(fs_file string) bool
- func KernelAllocateFiles() (ret uint64, err error)
- func KernelHostname() (string, error)
- func KernelMaxFiles() (uint64, error)
- func KernelMaxProc() (uint64, error)
- func ListMountPoint() ([][3]string, error)
- func ListeningPorts() ([]int64, error)
- func Netstat(ext string) (ret map[string]uint64, err error)
- func NtpTime(host string, timeout ...int64) (time.Time, error)
- func NtpTimeV(host string, version byte, timeout ...int64) (time.Time, error)
- func NtpTwoTime(host string, timeout ...int64) (time.Time, time.Time, error)
- func NumCpu() int
- func ReadName(path string) (name string, err error)
- func Snmp(title string) (ret map[string]int64, err error)
- func SocketStatSummary() (m map[string]uint64, err error)
- func SystemUptime() (days, hours, mins int64, err error)
- func TcpPorts() ([]int64, error)
- func UdpPorts() ([]int64, error)
- type CpuUsage
- type DeviceUsage
- type DiskStats
- type Loadavg
- type Mem
- type NetIf
- type Proc
- type ProcStat
Constants ¶
const ( BITS_PER_BYTE = 8 MILLION_BIT = 1000000 )
Variables ¶
var FSFILE_PREFIX_IGNORE = []string{
"/dev",
"/sys",
"/net",
"/misc",
"/proc",
"/lib",
}
var FSSPEC_IGNORE = map[string]struct{}{
"none": struct{}{},
"nodev": struct{}{},
"tmpfs": struct{}{},
"shm": struct{}{},
"proc": struct{}{},
}
var FSTYPE_IGNORE = map[string]struct{}{
"cgroup": struct{}{},
"debugfs": struct{}{},
"devtmpfs": struct{}{},
"rpc_pipefs": struct{}{},
"rootfs": struct{}{},
}
var Multi uint64 = 1024
var WANT = map[string]struct{}{
"Buffers:": struct{}{},
"Cached:": struct{}{},
"MemTotal:": struct{}{},
"MemFree:": struct{}{},
"MemAvailable:": struct{}{},
"SwapTotal:": struct{}{},
"SwapFree:": struct{}{},
}
Functions ¶
func IgnoreFsFile ¶
func KernelAllocateFiles ¶
func KernelHostname ¶
func KernelMaxFiles ¶
func KernelMaxProc ¶
func ListMountPoint ¶
return: [][$fs_spec, $fs_file, $fs_vfstype]
func NtpTime ¶
Time returns the "receive time" from the remote NTP server specifed as host. NTP client mode version 4 is used.
func NtpTimeV ¶
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 ¶
Time returns the "receive time" from the remote NTP server specifed as host. NTP client mode version 4 is used.
func SocketStatSummary ¶
func SystemUptime ¶
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 }
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 ¶
type Mem ¶
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 }