apcupsd

package module
v0.0.0-...-c606dcb Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2018 License: MIT Imports: 11 Imported by: 0

README

apcupsd Build Status GoDoc Report Card

Package apcupsd provides a client for the apcupsd Network Information Server (NIS). MIT Licensed.

Documentation

Overview

Package apcupsd provides a client for the apcupsd Network Information Server (NIS).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for the apcupsd Network Information Server (NIS).

func Dial

func Dial(network string, addr string) (*Client, error)

Dial dials a connection to an NIS using the address on the named network, and creates a Client with the connection.

Typically, network will be one of: "tcp", "tcp4", or "tcp6".

func DialContext

func DialContext(ctx context.Context, network, address string) (*Client, error)

DialContext takes a context and dials a connection to an NIS using the address on the named network, and creates a Client with the connection.

The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.

Typically, network will be one of: "tcp", "tcp4", or "tcp6".

func New

func New(rwc io.ReadWriteCloser) *Client

New wraps an existing io.ReadWriteCloser to create a Client for communication with an NIS. Client's Close method will close the io.ReadWriteCloser when called.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to an NIS.

func (*Client) Status

func (c *Client) Status() (*Status, error)

Status retrieves the current UPS status from the NIS.

type Status

type Status struct {
	APC                         string
	Date                        time.Time
	Hostname                    string
	Version                     string
	UPSName                     string
	Cable                       string
	Driver                      string
	UPSMode                     string
	StartTime                   time.Time
	Model                       string
	Status                      string
	LineVoltage                 float64
	LoadPercent                 float64
	BatteryChargePercent        float64
	TimeLeft                    time.Duration
	MinimumBatteryChargePercent float64
	MinimumTimeLeft             time.Duration
	MaximumTime                 time.Duration
	Sense                       string
	LowTransferVoltage          float64
	HighTransferVoltage         float64
	AlarmDel                    time.Duration
	BatteryVoltage              float64
	LastTransfer                string
	NumberTransfers             int
	XOnBattery                  time.Time
	TimeOnBattery               time.Duration
	CumulativeTimeOnBattery     time.Duration
	XOffBattery                 time.Time
	LastSelftest                time.Time
	Selftest                    bool
	StatusFlags                 string
	SerialNumber                string
	BatteryDate                 time.Time
	NominalInputVoltage         float64
	NominalBatteryVoltage       float64
	NominalPower                int
	Firmware                    string
	EndAPC                      time.Time
	InternalTemp                float64
	OutputVoltage               float64
	LineFrequency               float64
}

Status is the status of an APC Uninterruptible Power Supply (UPS), as returned by a NIS.

Jump to

Keyboard shortcuts

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