nutclient

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 6 Imported by: 0

README

nutclient-go

About

Network UPS Tools (NUT) client module for Go.

Examples

View inside example directory.

License

Released under the MIT license. See LICENSE.md file for details.

Documentation

Overview

Package nutclient provides a simple client for connecting to UPS NUT daemon

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Text *textproto.Conn
	// contains filtered or unexported fields
}

A Client represents a client connection to a nut server.

func Dial

func Dial(address string) (*Client, error)

The addr must include a port, as in "nutsrv.example.com:3493".

func NewClient

func NewClient(conn net.Conn, host string) (*Client, error)

NewClient returns a new Client instance

func (*Client) Auth

func (c *Client) Auth(login string, password string) error

Perform Auth on nut server

func (*Client) BatteryCharge

func (c *Client) BatteryCharge() (int, error)

Return Battery Charge

func (*Client) BatteryChargeLow

func (c *Client) BatteryChargeLow() (int, error)

Return Battery Charge Low value

func (*Client) BatteryChargeRestart

func (c *Client) BatteryChargeRestart() (int, error)

Return Battery Charge Restart value

func (*Client) BatteryChargeWarning

func (c *Client) BatteryChargeWarning() (int, error)

Return Battery Charge Warning value

func (*Client) BatteryRuntime

func (c *Client) BatteryRuntime() (int, error)

Return Battery runtime (seconds)

func (*Client) BatteryRuntimeLow

func (c *Client) BatteryRuntimeLow() (int, error)

Return Battery runtime low (seconds)

func (*Client) BatteryRuntimeRestart

func (c *Client) BatteryRuntimeRestart() (int, error)

Return Battery runtime restart (seconds)

func (*Client) Close

func (c *Client) Close() error

Close closes the connection.

func (*Client) GetData

func (c *Client) GetData(format string) (string, error)

Get a specific data from current ups

func (*Client) GetServerInfo

func (c *Client) GetServerInfo() (string, error)

Return Server Info

func (*Client) GetServerVersion

func (c *Client) GetServerVersion() (string, error)

Return Server Info

func (*Client) GetUpsModel

func (c *Client) GetUpsModel() (string, error)

Return Ups Model

func (*Client) GetUpsSerial

func (c *Client) GetUpsSerial() (string, error)

Return Ups Serial Number

func (*Client) InputCurrent

func (c *Client) InputCurrent() (int, error)

Return Input Current (A)

func (*Client) InputFrequency

func (c *Client) InputFrequency() (int, error)

Return Input Frequency (Hz)

func (*Client) InputVoltage

func (c *Client) InputVoltage() (int, error)

Return Input Voltage (V)

func (*Client) IsLowBattery

func (c *Client) IsLowBattery() (bool, error)

Return true if current ups status is low battery

func (*Client) IsOnBattery

func (c *Client) IsOnBattery() (bool, error)

Return true if current ups is on battery

func (*Client) IsOnline

func (c *Client) IsOnline() (bool, error)

Return true if current ups is online

func (*Client) Login

func (c *Client) Login(upsName string) error

Perform Login command to select current ups

func (*Client) Logout

func (c *Client) Logout() error

Perform Logout command.

func (*Client) OutputCurrent

func (c *Client) OutputCurrent() (int, error)

Return Output Current (A)

func (*Client) OutputFrequency

func (c *Client) OutputFrequency() (int, error)

Return Output Frequency (Hz)

func (*Client) OutputVoltage

func (c *Client) OutputVoltage() (int, error)

Return Output Voltage (V)

func (*Client) StartTLS

func (c *Client) StartTLS(configtls *tls.Config) error

StartTLS sends the STARTTLS command and encrypts all further communication.

func (*Client) UpsActivePower

func (c *Client) UpsActivePower() (int, error)

Return current active ups power (W)

func (*Client) UpsApparentPower

func (c *Client) UpsApparentPower() (int, error)

Return current apparent ups power (VA)

func (*Client) UpsLoad

func (c *Client) UpsLoad() (int, error)

Return ups load (percent)

func (*Client) UpsTemperature

func (c *Client) UpsTemperature() (int, error)

Return ups load (degrees C)

Jump to

Keyboard shortcuts

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