nutclient

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 6 Imported by: 0

README

nutclient for Golang

About

Network UPS Tools (NUT) client module for Go.

Examples

View inside example directory.

Functions (depends on nut server configuration and ups capabilities)

  • Dial(address)
  • StartTLS(tlsconfig)
  • Auth("login","password")
  • Login("upsname")
  • Close()
  • GetUpsModel()
  • Logout()
  • IsOnline()
  • IsOnBattery()
  • IsLowBattery()
  • BatteryCharge()
  • BatteryChargeLow()
  • BatteryChargeWarning()
  • BatteryChargeRestart()
  • BatteryRuntime()
  • BatteryRuntimeLow()
  • BatteryRuntimeRestart()
  • GetServerInfo()
  • GetServerVersion()
  • UpsLoad()
  • UpsTemperature()
  • UpsApparentPower()
  • UpsActivePower()
  • InputVoltage()
  • InputCurrent()
  • OutputVoltage()
  • OutputCurrent()
  • OutputFrequency()
  • InputFrequency()
  • GetUpsModel()
  • GetUpsSerial()
  • GetServerUpsList()
  • GetUpsVars()
  • GetData(varname)

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) GetServerUpsList added in v1.0.1

func (c *Client) GetServerUpsList() ([]string, error)

Return configured UPS list

func (*Client) GetServerVersion

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

Return Server Version

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) GetUpsVars added in v1.0.1

func (c *Client) GetUpsVars() ([]string, error)

Return ups vars avaible

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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