fd

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	StateNameFileDescriptors = "file_descriptors"

	// 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"
	StateKeyUsedPercent          = "used_percent"
	StateKeyFDLimitSupported     = "fd_limit_supported"
	StateKeyThresholdLimit       = "threshold_limit"
	StateKeyThresholdUsedPercent = "threshold_used_percent"
)
View Source
const DefaultThresholdLimit = 1048576

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

View Source
const Name = "file-descriptor"

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"`

	// ThresholdLimit is the number of file descriptor limit 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.
	ThresholdLimit uint64 `json:"threshold_limit"`
}

func ParseConfig

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

func (*Config) Validate

func (cfg *Config) Validate() error

type Output

type Output struct {
	RunningPIDs uint64 `json:"running_pids"`
	Usage       uint64 `json:"usage"`

	Limit uint64 `json:"limit"`
	// 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"`

	// Set to true if the max file descriptor is supported (e.g., /proc/sys/fs/file-max exists on linux).
	FDLimitSupported bool `json:"fd_limit_supported"`

	ThresholdLimit uint64 `json:"threshold_limit"`
	// ThresholdUsedPercent is the percentage of file descriptors that are currently in use,
	// based on the threshold file descriptor limit.
	ThresholdUsedPercent string `json:"threshold_used_percent"`

	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) GetThresholdUsedPercent

func (o Output) GetThresholdUsedPercent() (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 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