apcmetrics

package
v0.0.0-...-d73b53c Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApcCollector

func NewApcCollector(client *ApcClient, timeout time.Duration, logger log.Logger) prometheus.Collector

Types

type ApcClient

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

func NewApcClient

func NewApcClient(address string, logger log.Logger) *ApcClient

func (*ApcClient) Events

func (a *ApcClient) Events(ctx context.Context) ([]ApcEvent, error)

func (*ApcClient) EventsRaw

func (a *ApcClient) EventsRaw(ctx context.Context) ([]string, error)

func (*ApcClient) Status

func (a *ApcClient) Status(ctx context.Context) (*ApcStatus, error)

func (*ApcClient) StatusRaw

func (a *ApcClient) StatusRaw(ctx context.Context) ([]string, error)

type ApcEvent

type ApcEvent struct {
	TimeStamp time.Time `json:"timestamp"`
	Message   string    `json:"message"`
}

func ParseEventsFromLines

func ParseEventsFromLines(lines []string) ([]ApcEvent, error)

type ApcStatus

type ApcStatus struct {
	Hostname string `json:"hostname"`
	Version  string `json:"version"`
	UpsName  string `json:"ups_name"`
	Model    string `json:"model"`
	Driver   string `json:"driver"`
	UpsMode  string `json:"ups_mode"`

	Status                string        `json:"status"`
	TimeLeft              time.Duration `json:"time_left"`
	LoadPercent           Percent       `json:"load_percent"`
	ChargePercent         Percent       `json:"charge_percent"`
	LineVoltage           Voltage       `json:"line_voltage"`
	LowTransferVoltage    Voltage       `json:"low_transfer_voltage"`
	HighTransferVoltage   Voltage       `json:"high_transfer_voltage"`
	BatteryVoltage        Voltage       `json:"battery_voltage"`
	NominalBatteryVoltage Voltage       `json:"nominal_battery_voltage"`
	NominalInputVoltage   Voltage       `json:"nominal_input_voltage"`
	NominalWattage        Wattage       `json:"nominal_wattage"`

	BatteryDate        time.Time `json:"battery_date"`
	LastTimeOnBattery  time.Time `json:"last_time_on_battery"`
	LastTimeOffBattery time.Time `json:"last_time_off_battery"`
	LastSelfTest       time.Time `json:"last_self_test"`
}

func ParseStatusFromLines

func ParseStatusFromLines(lines []string) (*ApcStatus, error)

type Percent

type Percent float64

type Voltage

type Voltage float64

type Wattage

type Wattage float64

Jump to

Keyboard shortcuts

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