Documentation ¶
Index ¶
Constants ¶
const ( OutputSourceOther = iota + 1 OutputSourceNone OutputSourceNormal OutputSourceBypass OutputSourceBattery OutputSourceBooster OutputSourceReducer )
Output Source Enumeration
Variables ¶
var ( EstimatedMinutesRemaining = Statistic{ Name: "EstimatedMinutesRemaining", Unit: "minutes", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.2.3.0")}, Mapper: snmpvar.Ident, } EstimatedChargeRemaining = Statistic{ Name: "EstimatedChargeRemaining", Unit: "%", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.2.4.0")}, Mapper: snmpvar.Ident, } BatteryVoltage = Statistic{ Name: "BatteryVoltage", Unit: "volts (DC)", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.2.5.0")}, Mapper: snmpvar.Div(10), } BatteryTemperature = Statistic{ Name: "BatteryTemperature", Unit: "°C", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.2.7.0")}, Mapper: snmpvar.Ident, } InputVoltage = Statistic{ Name: "InputVoltage", Unit: "volts", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.3.3.1.3.1")}, Mapper: snmpvar.Ident, } InputCurrent = Statistic{ Name: "InputCurrent", Unit: "volts", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.3.3.1.4.1")}, Mapper: snmpvar.Ident, } OnBattery = Statistic{ Name: "OnBattery", Unit: "yes/no", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.4.1.0")}, Mapper: snmpvar.Match(OutputSourceBypass), } OutputVoltage = Statistic{ Name: "OutputVoltage", Unit: "volts", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.4.4.1.2.1")}, Mapper: snmpvar.Ident, } OutputCurrent = Statistic{ Name: "OutputCurrent", Unit: "amps", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.4.4.1.3.1")}, Mapper: snmpvar.Div(10), } OutputPower = Statistic{ Name: "OutputPower", Unit: "watts", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.4.4.1.4.1")}, Mapper: snmpvar.Ident, } OutputPercentLoad = Statistic{ Name: "OutputPercentLoad", Unit: "%", OID: snmpgo.Oids{snmpgo.MustNewOid("1.3.6.1.2.1.33.1.4.4.1.5.1")}, Mapper: snmpvar.Ident, } )
Preconfigured power management statistics
var ( ErrNoSuchInstance = errors.New("not supported (no such instance)") ErrNoSuchObject = errors.New("not supported (no such object)") )
SNMP errors
var ( DefaultCommunity = "public" DefaultPort = 161 DefaultRetries = uint(1) )
Default source configuration
Functions ¶
func IsNotSupported ¶
IsNotSupported returns true if the error indicates an unsupported SNMP object type.
func RegisterRecipientType ¶
func RegisterRecipientType(parser RecipientParser, names ...string)
RegisterRecipientType registers the given recipient type for name.
Name is case insensitive.
Types ¶
type ErrorHandler ¶
ErrorHandler is a recipient that handles query errors.
type Recipient ¶
type Recipient interface {
Send(Value)
}
Recipient is something to which a power management value can be sent.
func ParseRecipient ¶
ParseRecipient parses the given string as a recipient definition in one of the following forms:
type type:address
The format of address depends on the value of type.
func ParseRecipients ¶
ParseRecipients takes the given set of strings and attempts to parse each one as a recipient.
type RecipientParser ¶
RecipientParser is capable of parsing a given recipient address.
type Source ¶
type Source struct { Name string Host string Port string Community string // SNMP community name Retries uint }
Source describes a source of power statists data. It holds the necessary information to perform an SNMP query.
Sources are queried to produce statistics, which are then fed to destinations.
func ParseSource ¶
ParseSource parses the given string as a power source description.
The address is expected to be in one of these forms:
community@host:port~name community@host~name host:port~name host~name community@host:port community@host host:port host
func ParseSources ¶
ParseSources takes the given set of strings and attempts to parse each one as a power source description.
type SourceHandler ¶
SourceHandler is a recipient that performs processing for each source.
type Statistic ¶
type Statistic struct { Name string // Name of statistic Unit string // Unit of measurement OID snmpgo.Oids // One or more possible OID values for this statistic Mapper snmpvar.Float64 // SNMP value mapper }
Statistic describes a single power management statistic.
func ParseStatistic ¶
ParseStatistic parses a statistic in string format and returns the parsed value.
The statistic string format is a comma-separated list of optional elements, with a well-known statistic key followed by a series of property/value pairs:
KEY,name:NAME,oid:OID,unit:UNIT
The format is intended to meet three goals:
1. Easy use of well known statistics with preconfigured values 2. Overriding properties in preconfigured values with custom variations 3. Specification of custom, proprietary or otherwise unspported statistics
Examples:
"EstimatedMinutesRemaining" "name:WidgetDuration,oid:OID" "EstimatedMinutesRemaining,name:ZomboMinutes,oid:OID,unit:Unit"
func ParseStatistics ¶
ParseStatistics takes the given set of strings and attempts to parse each one as a power statistic.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package snmpvar maps SNMP variables to float64 values.
|
Package snmpvar maps SNMP variables to float64 values. |