memory

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package memory tracks the memory usage of the host.

Index

Constants

View Source
const (
	EventKeyUnixSeconds = "unix_seconds"
	EventKeyLogLine     = "log_line"
)
View Source
const (
	StateKeyVirtualMemory = "virtual_memory"

	StateKeyTotalBytes         = "total_bytes"
	StateKeyTotalHumanized     = "total_humanized"
	StateKeyAvailableBytes     = "available_bytes"
	StateKeyAvailableHumanized = "available_humanized"
	StateKeyUsedBytes          = "used_bytes"
	StateKeyUsedHumanized      = "used_humanized"
	StateKeyUsedPercent        = "used_percent"
	StateKeyFreeBytes          = "free_bytes"
	StateKeyFreeHumanized      = "free_humanized"

	StateKeyVMAllocTotalBytes     = "vm_alloc_total_bytes"
	StateKeyVMAllocTotalHumanized = "vm_alloc_total_humanized"
	StateKeyVMAllocUsedBytes      = "vm_alloc_used_bytes"
	StateKeyVMAllocUsedHumanized  = "vm_alloc_used_humanized"
	StateKeyVMAllocUsedPercent    = "vm_alloc_used_percent"

	StateKeyBPFJITBufferBytes     = "bpf_jit_buffer_bytes"
	StateKeyBPFJITBufferHumanized = "bpf_jit_buffer_humanized"
)

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context) (_ any, e error)

func New

Types

type Config

type Config struct {
	Query query_config.Config `json:"query"`
}

func ParseConfig

func ParseConfig(b any, dbRW *sql.DB, dbRO *sql.DB) (*Config, error)

func (Config) Validate

func (cfg Config) Validate() error

type Output

type Output struct {
	TotalBytes     uint64 `json:"total_bytes"`
	TotalHumanized string `json:"total_humanized"`

	AvailableBytes     uint64 `json:"available_bytes"`
	AvailableHumanized string `json:"available_humanized"`

	UsedBytes     uint64 `json:"used_bytes"`
	UsedHumanized string `json:"used_humanized"`

	UsedPercent string `json:"used_percent"`

	FreeBytes     uint64 `json:"free_bytes"`
	FreeHumanized string `json:"free_humanized"`

	VMAllocTotalBytes     uint64 `json:"vm_alloc_total_bytes"`
	VMAllocTotalHumanized string `json:"vm_alloc_total_humanized"`
	VMAllocUsedBytes      uint64 `json:"vm_alloc_used_bytes"`
	VMAllocUsedHumanized  string `json:"vm_alloc_used_humanized"`
	VMAllocUsedPercent    string `json:"vm_alloc_used_percent"`

	// Represents the current BPF JIT buffer size in bytes.
	// ref. "cat /proc/vmallocinfo | grep bpf_jit | awk '{s+=$2} END {print s}'"
	BPFJITBufferBytes     uint64 `json:"bpf_jit_buffer_bytes"`
	BPFJITBufferHumanized string `json:"bpf_jit_buffer_humanized"`
}

func ParseOutputJSON

func ParseOutputJSON(data []byte) (*Output, error)

func ParseStateKeyVirtualMemory

func ParseStateKeyVirtualMemory(m map[string]string) (*Output, error)

func ParseStatesToOutput

func ParseStatesToOutput(states ...components.State) (*Output, error)

func (Output) GetUsedPercent

func (o Output) GetUsedPercent() (float64, error)

func (*Output) JSON

func (o *Output) JSON() ([]byte, error)

func (*Output) States

func (o *Output) States() ([]components.State, error)

Directories

Path Synopsis
Package id provides the ID of the memory component.
Package id provides the ID of the memory component.
Package metrics implements the memory metrics collection and reporting.
Package metrics implements the memory metrics collection and reporting.

Jump to

Keyboard shortcuts

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