diagnostic

package
v0.0.0-...-31b9ebf Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error used when parsing the fields of the output of collector.
	ErrInsufficientLines = errors.New("insufficient lines")
	// Error used when parsing the lines of the output of collector.
	ErrInsuficientFields = errors.New("insufficient fields")
	// Error used when given key is not found while parsing KV.
	ErrKeyNotFound = errors.New("key not found")
	// Error used when tehre is no disk volume information available
	ErrNoVolumeFound = errors.New("No disk volume information found")
)

Functions

func RawSystemInformation

func RawSystemInformation(osInfoRaw string, memoryInfoRaw string, fdInfoRaw string, disksRaw string) string

Types

type DiskVolumeInformation

type DiskVolumeInformation struct {
	Name        string `json:"name"`        // represents the filesystem in linux/macos or device name in windows
	SizeMaximum uint64 `json:"sizeMaximum"` // represents the maximum size of the disk in kilobytes
	SizeCurrent uint64 `json:"sizeCurrent"` // represents the current size of the disk in kilobytes
}

func NewDiskVolumeInformation

func NewDiskVolumeInformation(name string, maximum, current uint64) *DiskVolumeInformation

func ParseDiskVolumeInformationOutput

func ParseDiskVolumeInformationOutput(output string, skipLines int, scale float64) ([]*DiskVolumeInformation, error)

type FileDescriptorInformation

type FileDescriptorInformation struct {
	FileDescriptorMaximum uint64
	FileDescriptorCurrent uint64
}

func ParseFileDescriptorInformationFromKV

func ParseFileDescriptorInformationFromKV(
	output string,
	fileDescriptorMaximumKey string,
	fileDescriptorCurrentKey string,
) (*FileDescriptorInformation, error)

func ParseSysctlFileDescriptorInformation

func ParseSysctlFileDescriptorInformation(output string) (*FileDescriptorInformation, error)

type Handler

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

func NewDiagnosticHandler

func NewDiagnosticHandler(
	log *zerolog.Logger,
	timeout time.Duration,
	systemCollector SystemCollector,
) *Handler

func (*Handler) SystemHandler

func (handler *Handler) SystemHandler(writer http.ResponseWriter, request *http.Request)

type MemoryInformation

type MemoryInformation struct {
	MemoryMaximum uint64 // size in KB
	MemoryCurrent uint64 // size in KB
}

func ParseMemoryInformationFromKV

func ParseMemoryInformationFromKV(
	output string,
	memoryMaximumKey string,
	memoryAvailableKey string,
	mapper func(field string) (uint64, error),
) (*MemoryInformation, error)

type OsInfo

type OsInfo struct {
	OsSystem     string
	Name         string
	OsVersion    string
	OsRelease    string
	Architecture string
}

func ParseUnameOutput

func ParseUnameOutput(output string, system string) (*OsInfo, error)

func ParseWinOperatingSystemInfo

func ParseWinOperatingSystemInfo(
	output string,
	architectureKey string,
	osSystemKey string,
	osVersionKey string,
	osReleaseKey string,
	nameKey string,
) (*OsInfo, error)

type SystemCollector

type SystemCollector interface {
	// If the collection is successful it will return `SystemInformation` struct,
	// an empty string, and a nil error.
	// In case there is an error a string with the raw data will be returned
	// however the returned string not contain all the data points.
	//
	// This function expects that the caller sets the context timeout to prevent
	// long-lived collectors.
	Collect(ctx context.Context) (*SystemInformation, string, error)
}

type SystemCollectorImpl

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

func NewSystemCollectorImpl

func NewSystemCollectorImpl(
	version string,
) *SystemCollectorImpl

func (*SystemCollectorImpl) Collect

func (collector *SystemCollectorImpl) Collect(ctx context.Context) (*SystemInformation, string, error)

type SystemInformation

type SystemInformation struct {
	MemoryMaximum         uint64                   `json:"memoryMaximum"`         // represents the maximum memory of the system in kilobytes
	MemoryCurrent         uint64                   `json:"memoryCurrent"`         // represents the system's memory in use in kilobytes
	FileDescriptorMaximum uint64                   `json:"fileDescriptorMaximum"` // represents the maximum number of file descriptors of the system
	FileDescriptorCurrent uint64                   `json:"fileDescriptorCurrent"` // represents the system's file descriptors in use
	OsSystem              string                   `json:"osSystem"`              // represents the operating system name i.e.: linux, windows, darwin
	HostName              string                   `json:"hostName"`              // represents the system host name
	OsVersion             string                   `json:"osVersion"`             // detailed information about the system's release version level
	OsRelease             string                   `json:"osRelease"`             // detailed information about the system's release
	Architecture          string                   `json:"architecture"`          // represents the system's hardware platform i.e: arm64/amd64
	TunnellinkVersion     string                   `json:"tunnellinkVersion"`     // the runtime version of tunnellink
	Disk                  []*DiskVolumeInformation `json:"disk"`
}

func NewSystemInformation

func NewSystemInformation(
	memoryMaximum,
	memoryCurrent,
	filesMaximum,
	filesCurrent uint64,
	osystem,
	name,
	osVersion,
	osRelease,
	architecture,
	tunnellinkVersion string,
	disk []*DiskVolumeInformation,
) *SystemInformation

Jump to

Keyboard shortcuts

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