fd

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package fd tracks the number of file descriptors used on the host.

Index

Constants

View Source
const (
	EventNameErrorVFSFileMaxLimitReached = "error_vfs_file_max_limit_reached"

	EventKeyErrorVFSFileMaxLimitReachedUnixSeconds = "unix_seconds"
	EventKeyErrorVFSFileMaxLimitReachedLogLine     = "log_line"
)
View Source
const (
	StateNameFileDescriptors = "file_descriptors"

	// The number of file descriptors currently allocated on the host (not per process).
	StateKeyAllocatedFileHandles = "allocated_file_handles"
	// The number of running PIDs returned by https://pkg.go.dev/github.com/shirou/gopsutil/v4/process#Pids.
	StateKeyRunningPIDs = "running_pids"

	StateKeyUsage = "usage"
	StateKeyLimit = "limit"

	StateKeyAllocatedFileHandlesPercent = "allocated_file_handles_percent"
	StateKeyUsedPercent                 = "used_percent"

	StateKeyThresholdAllocatedFileHandles        = "threshold_allocated_file_handles"
	StateKeyThresholdAllocatedFileHandlesPercent = "threshold_allocated_file_handles_percent"
	StateKeyThresholdRunningPIDs                 = "threshold_running_pids"
	StateKeyThresholdRunningPIDsPercent          = "threshold_running_pids_percent"

	// Set to true if the file handles are supported.
	StateKeyFileHandlesSupported = "file_handles_supported"
	// Set to true if the file descriptor limit is supported.
	StateKeyFDLimitSupported = "fd_limit_supported"
)
View Source
const DefaultThresholdAllocatedFileHandles = 900000

DefaultThresholdAllocatedFileHandles is some high number, in case the system is under high file descriptor usage.

View Source
const DefaultThresholdRunningPIDs = 900000

DefaultThresholdRunningPIDs is some high number, in case fd-max is unlimited

Variables

This section is empty.

Functions

func CreateGet

func CreateGet(cfg Config) query.GetFunc

func New

Types

type Config

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

	// ThresholdAllocatedFileHandles is the number of file descriptors that are currently allocated,
	// at which we consider the system to be under high file descriptor usage.
	ThresholdAllocatedFileHandles uint64 `json:"threshold_allocated_file_handles"`

	// ThresholdRunningPIDs is the number of running pids at which
	// we consider the system to be under high file descriptor usage.
	// This is useful for triggering alerts when the system is under high load.
	// And useful when the actual system fd-max is set to unlimited.
	ThresholdRunningPIDs uint64 `json:"threshold_running_pids"`
}

func ParseConfig

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

func (*Config) Validate

func (cfg *Config) Validate() error

type Output

type Output struct {
	AllocatedFileHandles uint64 `json:"allocated_file_handles"`
	RunningPIDs          uint64 `json:"running_pids"`
	Usage                uint64 `json:"usage"`
	Limit                uint64 `json:"limit"`

	// AllocatedFileHandlesPercent is the percentage of file descriptors that are currently allocated,
	// based on the current file descriptor limit and the current number of file descriptors allocated on the host (not per process).
	AllocatedFileHandlesPercent string `json:"allocated_file_handles_percent"`
	// UsedPercent is the percentage of file descriptors that are currently in use,
	// based on the current file descriptor limit on the host (not per process).
	UsedPercent string `json:"used_percent"`

	ThresholdAllocatedFileHandles        uint64 `json:"threshold_allocated_file_handles"`
	ThresholdAllocatedFileHandlesPercent string `json:"threshold_allocated_file_handles_percent"`

	ThresholdRunningPIDs        uint64 `json:"threshold_running_pids"`
	ThresholdRunningPIDsPercent string `json:"threshold_running_pids_percent"`

	// Set to true if the file handles are supported.
	FileHandlesSupported bool `json:"file_handles_supported"`
	// Set to true if the file descriptor limit is supported.
	FDLimitSupported bool `json:"fd_limit_supported"`

	Errors []string `json:"errors,omitempty"`
}

func ParseOutputJSON

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

func ParseStateFileDescriptors

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

func ParseStatesToOutput

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

func (Output) GetAllocatedFileHandlesPercent added in v0.3.1

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

func (Output) GetThresholdAllocatedFileHandlesPercent added in v0.3.1

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

func (Output) GetThresholdRunningPIDsPercent added in v0.3.1

func (o Output) GetThresholdRunningPIDsPercent() (float64, 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 defines the component ID for the file descriptor component.
Package id defines the component ID for the file descriptor component.
Package metrics implements the file descriptor metrics collection and reporting.
Package metrics implements the file descriptor metrics collection and reporting.

Jump to

Keyboard shortcuts

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