stats

package
v0.0.0-...-d60b765 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MEGABYTE float64 = 1024 * 1024

Variables

View Source
var (
	ProcPath          string
	SharedStatsPeriod StatsPeriod = NewStatsPeriod()
	SignalChannel     chan uint32 = make(chan uint32)
)

Functions

func CollectStatsSamples

func CollectStatsSamples(secondsInterval time.Duration)

Types

type JSONStats

type JSONStats struct {
	Type         string               `json:"type"`
	Hostname     string               `json:"hostname"`
	BasicStats   *LinuxBasicStats     `json:"basic"`
	Vmstat       *LinuxVMStats        `json:"vmstat"`
	NetworkStats *LinuxNetworkStats   `json:"network"`
	Processes    []*LinuxProcessStats `json:"processes"`
	Disks        []*LinuxDiskStats    `json:"disks"`
}

func NewJSONStats

func NewJSONStats() *JSONStats

func (*JSONStats) GetStats

func (jsonstats *JSONStats) GetStats() (string, error)

type LinuxBasicStats

type LinuxBasicStats struct {
	Processors      []*ProcessorStats `json:"processors"`
	AllProcessors   *ProcessorStats   `json:"allProcessors"`
	Processes       uint64            `json:"processes"`
	ContextSwitches uint64            `json:"contextSwitches"`
	Interrupts      uint64            `json:"interrupts"`
}

func NewLinuxBasicStats

func NewLinuxBasicStats() *LinuxBasicStats

type LinuxDiskStats

type LinuxDiskStats struct {
	Name             string `json:"name"`
	ReadIOs          uint64 `json:"read_io"`
	WriteIOs         uint64 `json:"write_io"`
	ReadMerges       uint64 `json:"read_io_merged"`
	WriteMerges      uint64 `json:"write_io_merged"`
	IOTicks          uint64 `json:"io_ticks"`
	QueueSize        uint64 `json:"queue_size"`
	TimeInQueue      uint64 `json:"time_in_queue"`
	ReadMBPerSecond  uint64 `json:"read_mbps"`
	WriteMBPerSecond uint64 `json:"write_mbps"`
}

*

  • All fields except field 9 are cumulative since boot. Field 9 should
  • go to zero as I/Os complete; all others only increase (unless they
  • overflow and wrap). Yes, these are (32-bit or 64-bit) unsigned long
  • (native word size) numbers, and on a very busy or long-lived system they
  • may wrap. *
  • https://www.kernel.org/doc/Documentation/iostats.txt

func NewLinuxDisksStats

func NewLinuxDisksStats() []*LinuxDiskStats

type LinuxNetworkStats

type LinuxNetworkStats struct {
	// IP
	IpForwarding    uint64 `json:"ip_forwarding"`
	IpForwDatagrams uint64 `json:"ip_forwarded"`
	IpInReceives    uint64 `json:"ip_in_received"`
	IpInHdrErrors   uint64 `json:"ip_in_header_errors"`
	IpInAddrErrors  uint64 `json:"ip_in_addr_errors"`
	IpInDiscards    uint64 `json:"ip_in_discarded"`
	// Discarded because of an unknown or unsupported protocol
	IpInUnknownProtos uint64 `json:"ip_in_unknown"`
	IpInDelivers      uint64 `json:"ip_in_delivered"`
	// Does not include any of the IpForwDatagrams
	IpOutRequests uint64 `json:"ip_out_requests"`
	IpOutNoRoutes uint64 `json:"ip_out_noroute"`
	IpOutDiscards uint64 `json:"ip_out_discarded"`
	// TCP
	TcpRtoMax  uint64 `json:"tcp_rto_max"`
	TcpMaxConn uint64 `json:"tcp_max_connections"`
	/**
		 * The number of times TCP connections have made a
	   * direct transition to the SYN-SENT state from the
	   * CLOSED state.
	*/
	TcpActiveOpens uint64 `json:"tcp_active_opened"`
	/**
		 * The number of times TCP connections have made a
	   * direct transition to the SYN-RCVD state from the
	   * LISTEN state.
	*/
	TcpPassiveOpens uint64 `json:"tcp_active_opened"`
	/**
	 * TCP connections for which the current state is
	 * either ESTABLISHED or CLOSE-WAIT
	 */
	TcpCurrEstab   uint64 `json:"tcp_current_established"`
	TcpEstabResets uint64 `json:"tcp_established_reset"`
	TcpRetransSegs uint64 `json:"tcp_retransmited_seg"`
	TcpInSegs      uint64 `json:"tcp_in_seg"`
	TcpOutSegs     uint64 `json:"tcp_out_seg"`
	TcpInErrs      uint64 `json:"tcp_in_error"`
	TcpOutRsts     uint64 `json:"tcp_out_rst"`
	/**
	 * I'm summarizing in a single field all the receive and transmit
	 * queues from all sockets.
	 *
	 * https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt
	 */
	TotalTCPSockets uint64 `json:"total_tcp_sockets"`
	TotalTCPRxQueue uint64 `json:"total_tcp_rx_queue"`
	TotalTCPTxQueue uint64 `json:"total_tcp_tx_queue"`
}

*

func NewLinuxNetworkStats

func NewLinuxNetworkStats() *LinuxNetworkStats

type LinuxProcessStats

type LinuxProcessStats struct {
	CmdLine                     string `json:"cmdline"`
	Pid                         uint64 `json:"pid"`
	State                       string `json:"state"`
	MemVirtSize                 uint64 `json:"mem_virtual_size"`
	MemRssSize                  uint64 `json:"mem_rss_size"`
	MemLockSize                 uint64 `json:"mem_lock_size"`
	MemSwapSize                 uint64 `json:"mem_swap_size"`
	Threads                     uint64 `json:"threads"`
	FDUsed                      uint64 `json:"fd_used"`
	SignalsIgnored              uint64 `json:"sig_ignored"`
	SignalsCaught               uint64 `json:"sig_caught"`
	VoluntaryContextSwitches    uint64 `json:"voluntary_contextswitches"`
	NonVoluntaryContextSwitches uint64 `json:"nonvoluntary_contextswitches"`
	IOReadBytes                 uint64 `json:"io_read_bytes"`
	IOWriteBytes                uint64 `json:"io_write_bytes"`
	UserCpuUsage                uint64 `json:"user_cpu_usage"`
	SystemCpuUsage              uint64 `json:"system_cpu_usage"`
}

func NewLinuxProcessesStats

func NewLinuxProcessesStats() []*LinuxProcessStats

type LinuxVMStats

type LinuxVMStats struct {
	PgFree           uint64 `json:"pgfree"`
	PgpgIn           uint64 `json:"pgpgin"`
	PgpgOut          uint64 `json:"pgpgout"`
	PswpIn           uint64 `json:"pswpin"`
	PswpOut          uint64 `json:"pswpout"`
	PgFault          uint64 `json:"pgfault"`
	PgMajFault       uint64 `json:"pgmajfault"`
	NrMLock          uint64 `json:"nr_mlock"`
	NrShMem          uint64 `json:"nr_shmem"`
	NrDirty          uint64 `json:"nr_dirty"`
	NrPageTablePages uint64 `json:"nr_page_table_pages"`
	NrSlab           uint64 `json:"nr_slab"`
	NrMapped         uint64 `json:"nr_mapped"`
	NrFreePages      uint64 `json:"nr_free_pages"`
	NrAnonPages      uint64 `json:"nr_anon_pages"`
}

func NewLinuxVMStats

func NewLinuxVMStats() *LinuxVMStats

type ProcessorStats

type ProcessorStats struct {
	Cpu            string `json:"cpu"`
	User           uint64 `json:"user"`
	Nice           uint64 `json:"nice"`
	System         uint64 `json:"system"`
	IOWait         uint64 `json:"iowait"`
	PercentageUtil uint64 `json:"percentageUtil"`
}

type StatsPeriod

type StatsPeriod struct {
	// contains filtered or unexported fields
}

func NewStatsPeriod

func NewStatsPeriod() StatsPeriod

func (*StatsPeriod) AddStatsSample

func (statsPeriod *StatsPeriod) AddStatsSample(stats StatsSample)

func (*StatsPeriod) GetStatsSamples

func (statsPeriod *StatsPeriod) GetStatsSamples() (previous, current StatsSample)

func (*StatsPeriod) HasPreviousSamples

func (statsPeriod *StatsPeriod) HasPreviousSamples() bool

func (*StatsPeriod) WaitForSamples

func (statsPeriod *StatsPeriod) WaitForSamples()

type StatsSample

type StatsSample struct {
	// contains filtered or unexported fields
}

func NewStatsSample

func NewStatsSample() (statsSample StatsSample, err error)

Jump to

Keyboard shortcuts

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