datasources

package
v0.0.0-...-c5a7534 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBtrfs

func GetBtrfs(ch chan<- SourceReturn, conf *Conf)

GetBtrfs gets btrfs filesystem used and total space by reading files in /sys

func GetCPUTemp

func GetCPUTemp(ch chan<- SourceReturn, conf *Conf)

GetCPUTemp returns CPU core temps using gopsutil or parsing sensors output

func GetDiskTemps

func GetDiskTemps(ch chan<- SourceReturn, conf *Conf)

GetDiskTemps returns disk temperatures using hddtemp daemon or drivetemp kernel driver

func GetDocker

func GetDocker(ch chan<- SourceReturn, conf *Conf)

GetDocker docker container status using the API

func GetPodman

func GetPodman(ch chan<- SourceReturn, conf *Conf)

GetPodman podman container status by parsing cli output

func GetSysInfo

func GetSysInfo(ch chan<- SourceReturn, conf *Conf)

GetSysInfo various stats about the host Linux OS (kernel, distro, load and more)

func GetSystemd

func GetSystemd(ch chan<- SourceReturn, conf *Conf)

GetSystemd gets systemd unit status using dbus

func GetUpdates

func GetUpdates(ch chan<- SourceReturn, conf *Conf)

GetUpdates reads cached updates file and formats it

func GetZFS

func GetZFS(ch chan<- SourceReturn, conf *Conf)

GetZFS runs `zpool list -Ho name,alloc,size,health` and parses the output

func RunSources

func RunSources(runList []string, c *Conf) ([]string, map[string]SourceReturn)

RunSources runs data sources in runList, the names are validated and returned as the first value

Types

type Conf

type Conf struct {
	ConfGlobal `yaml:"global"`
	BTRFS      ConfBtrfs    `yaml:"btrfs"`
	CPU        ConfTempCPU  `yaml:"cpu"`
	Disk       ConfTempDisk `yaml:"disk"`
	Docker     ConfDocker   `yaml:"docker"`
	Podman     ConfPodman   `yaml:"podman"`
	SysInfo    ConfSysInfo  `yaml:"sysinfo"`
	Systemd    ConfSystemd  `yaml:"systemd"`
	Updates    ConfUpdates  `yaml:"updates"`
	ZFS        ConfZFS      `yaml:"zfs"`
}

Conf is the combined config struct, defines YAML file

func NewConfFromFile

func NewConfFromFile(path string, debug bool) (c Conf, err error)

func (*Conf) Init

func (c *Conf) Init()

Init a config with sane default values

type ConfBase

type ConfBase struct {
	// Override global setting
	WarnOnly *bool `yaml:"warnings_only,omitempty"`
	// 2-element array defining padding for header (title)
	PadHeader []int `yaml:"pad_header,flow"`
	// 2-element array defining padding for content (details)
	PadContent []int `yaml:"pad_content,flow"`
	// contains filtered or unexported fields
}

ConfBase is the common type for all modules

Custom modules should respect these options

func (*ConfBase) Init

func (c *ConfBase) Init()

Init sets `PadHeader` and `PadContent` to [0, 0]

func (*ConfBase) MaybePad

func (c *ConfBase) MaybePad(header string, content string) (string, string)

MaybePad pads header and content (if they aren't empty strings)

type ConfBaseWarn

type ConfBaseWarn struct {
	ConfBase `yaml:",inline"`
	Warn     int `yaml:"warn"`
	Crit     int `yaml:"crit"`
}

ConfBaseWarn extends ConfBase with warning and critical values

func (*ConfBaseWarn) Init

func (c *ConfBaseWarn) Init()

Init sets warning to 70 and critical to 90

type ConfBtrfs

type ConfBtrfs struct {
	ConfBaseWarn `yaml:",inline"`
	// Show free space instead of used space
	ShowFree bool `yaml:"show_free"`
	// Parse btrfs command output
	Exec bool `yaml:"use_exec"`
	// Run btrfs using sudo
	Sudo bool `yaml:"sudo"`
	// Override btrfs command, example `btrfs-us --raw`
	Command string `yaml:"btrfs_cmd"`
}

ConfBtrfs is the configuration for btrfs data

func (*ConfBtrfs) Init

func (c *ConfBtrfs) Init()

Init sets up default alignment

type ConfDocker

type ConfDocker struct {
	ConfBase `yaml:",inline"`
	// Interact directly with the docker CLI, much slower than API
	Exec bool `yaml:"use_exec"`
	// List of container names to ignore
	Ignore []string `yaml:"ignore,omitempty"`
}

ConfDocker extends ConfBase with a list of containers to ignore

func (*ConfDocker) Init

func (c *ConfDocker) Init()

Init sets up default alignment

type ConfGlobal

type ConfGlobal struct {
	// Hide fields which are deemed to be OK
	WarnOnly bool `yaml:"warnings_only"`
	// Order in which to display data sources
	ShowOrder []string `yaml:"show_order,flow,omitempty"`
	// Define how data sources are displayed
	ColDef [][]string `yaml:"col_def,flow,omitempty"`
	// Padding between columns when using col_def
	ColPad int `yaml:"col_pad"`
	// contains filtered or unexported fields
}

ConfGlobal is the config struct for global settings

type ConfInterface

type ConfInterface interface {
	Init()
}

ConfInterface defines the interface for config structs

type ConfPodman

type ConfPodman struct {
	ConfBase `yaml:",inline"`
	// Run podman using sudo, you should have NOPASSWD set for the podman command
	Sudo bool `yaml:"sudo"`
	// Run podman as both root and current user
	IncludeSudo bool `yaml:"include_sudo"`
	// List of container names to ignore
	Ignore []string `yaml:"ignore,omitempty"`
}

ConfPodman extends ConfBase with a list of containers to ignore

func (*ConfPodman) Init

func (c *ConfPodman) Init()

Init sets up default alignment

type ConfSysInfo

type ConfSysInfo struct {
	ConfBase `yaml:",inline"`
}

func (*ConfSysInfo) Init

func (c *ConfSysInfo) Init()

type ConfSystemd

type ConfSystemd struct {
	ConfBase `yaml:",inline"`
	// List of units to track, including extension
	Units []string `yaml:"units,omitempty"`
	// Remove extension when displaying units
	HideExt bool `yaml:"hide_ext"`
	// Consider inactive units OK
	InactiveOK bool `yaml:"inactive_ok"`
	// Get all failed units (in addition manually defined units above)
	ShowFailed bool `yaml:"show_failed"`
}

ConfSystemd extends ConfBase with a list of units to monitor

func (*ConfSystemd) Init

func (c *ConfSystemd) Init()

Init sets ShowFailed to true

type ConfTempCPU

type ConfTempCPU struct {
	ConfBaseWarn `yaml:",inline"`
	// Get CPU temperatures by parsing 'sensors -j' output
	Exec bool `yaml:"use_exec"`
}

ConfTempCPU extends ConfBase with a list of containers to ignore

func (*ConfTempCPU) Init

func (c *ConfTempCPU) Init()

Init sets up default alignment

type ConfTempDisk

type ConfTempDisk struct {
	ConfBaseWarn `yaml:",inline"`
	// List of disks to ignore, as they appear in /dev/
	Ignore []string `yaml:"ignore,omitempty"`
	// Read temperatures from /sys/ directly, requires drivetemp kernel module
	Sys bool `yaml:"use_sys"`
}

ConfTempDisk extends ConfBase with a list of devices to ignore

func (*ConfTempDisk) Init

func (c *ConfTempDisk) Init()

Init sets warning temperature to 40C and critical to 50C

type ConfUpdates

type ConfUpdates struct {
	ConfBase `yaml:",inline"`
	// Show packages that can be upgraded
	Show *bool `yaml:"show,omitempty"`
	// Listen address of go-check-updates, absolute path indicates unix socket, otherwise <addr>:<port>
	Address string `yaml:"address"`
	// File will read the cache file directly
	File string `yaml:"file"`
	// Every defines how often the cache will be asked to update itself
	Every string `yaml:"every"`
	// ShortNames uses short names for time durations (1h5m instead of 1 hour, 5 min)
	ShortNames bool `yaml:"short_names"`
}

ConfUpdates extends ConfBase with a show toggle (same as warnOnly), path to file and how often to check

func (*ConfUpdates) Init

func (c *ConfUpdates) Init()

Init sets default alignment and default socket file

type ConfZFS

type ConfZFS struct {
	ConfBaseWarn `yaml:",inline"`
}

func (*ConfZFS) Init

func (c *ConfZFS) Init()

Init sets up default alignment

type ModuleNotAvailable

type ModuleNotAvailable struct {
	Name        string
	ParentError error
}

func (*ModuleNotAvailable) Error

func (m *ModuleNotAvailable) Error() string

func (ModuleNotAvailable) UnavailableError

func (ModuleNotAvailable) UnavailableError()

type SourceReturn

type SourceReturn struct {
	// Datasource output header string
	Header string
	// Datasource output content string
	Content string
	// Error
	Error error
	// Time taken, non-zero only in debug mode
	Time time.Duration
	// contains filtered or unexported fields
}

SourceReturn is the data returned by a datasource through a channel

func NewSourceReturn

func NewSourceReturn(debug bool) *SourceReturn

func (*SourceReturn) MaybePad

func (sr *SourceReturn) MaybePad(c *ConfBase)

func (*SourceReturn) Return

func (sr *SourceReturn) Return(c *ConfBase) SourceReturn

type UnavailableError

type UnavailableError interface {
	error
	UnavailableError()
}

Jump to

Keyboard shortcuts

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