Documentation ¶
Overview ¶
Package PRTG implements the API for PRTG custom sensors. It provides all structs and constants needed to implement your own advanced exe sensor in Go.
Copyright (c) 2019, Paessler AG. All Rights Reserved
Copyright (c) 2019, Paessler AG. All Rights Reserved
Index ¶
- type DecimalModeType
- type Sensor
- type SensorChannel
- func (r *SensorChannel) SetCustomUnit(unit string) *SensorChannel
- func (r *SensorChannel) SetDecimalMode(mode DecimalModeType) *SensorChannel
- func (r *SensorChannel) SetErrLimitMsg(msg string) *SensorChannel
- func (r *SensorChannel) SetMaxErrLimit(limit int) *SensorChannel
- func (r *SensorChannel) SetMaxWarnLimit(limit int) *SensorChannel
- func (r *SensorChannel) SetMinErrLimit(limit int) *SensorChannel
- func (r *SensorChannel) SetMinWarnLimit(limit int) *SensorChannel
- func (r *SensorChannel) SetShowChart(show bool) *SensorChannel
- func (r *SensorChannel) SetShowTable(show bool) *SensorChannel
- func (r *SensorChannel) SetSpeedSize(size SpeedType) *SensorChannel
- func (r *SensorChannel) SetSpeedTime(time TimeType) *SensorChannel
- func (r *SensorChannel) SetToWarning() *SensorChannel
- func (r *SensorChannel) SetUnit(unit UnitType) *SensorChannel
- func (r *SensorChannel) SetValue(val interface{}) *SensorChannel
- func (r *SensorChannel) SetValueLookup(lookup string) *SensorChannel
- func (r *SensorChannel) SetVolumeSize(size SizeType) *SensorChannel
- func (r *SensorChannel) SetWarnLimitMsg(msg string) *SensorChannel
- func (r *SensorChannel) ValueIsDifference() *SensorChannel
- type SensorResponse
- type SensorResults
- type SizeType
- type SpeedType
- type TimeType
- type UnitType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecimalModeType ¶ added in v0.2.0
type DecimalModeType string
const ( OptionAuto DecimalModeType = "Auto" OptionAll DecimalModeType = "All" )
Options for Decimalmode
type Sensor ¶ added in v0.2.0
type Sensor interface { AddChannel(string) *SensorChannel MarshalToString() (string, error) SetSensorText(string) *SensorResults SetError(bool) *SensorResults }
type SensorChannel ¶
type SensorChannel struct { Channel string `json:"channel"` Value string `json:"value"` // Options ValueMode string `json:"mode,omitempty"` Unit string `json:"unit,omitempty"` CustomUnit string `json:"customunit,omitempty"` ValueLookup string `json:"valuelookup,omitempty"` VolumeSize string `json:"volumesize,omitempty"` SpeedSize string `json:"speedsize,omitempty"` SpeedTime string `json:"speedtime,omitempty"` Float string `json:"float,omitempty"` DecimalMode string `json:"decimalmode,omitempty"` ShowChart string `json:"showchart,omitempty"` ShowTable string `json:"showtable,omitempty"` LimitMinWarning string `json:"limitminwarning,omitempty"` LimitMaxWarning string `json:"limitmaxwarning,omitempty"` LimitWarningMsg string `json:"limitwarningmsg,omitempty"` LimitMinError string `json:"limitminerror,omitempty"` LimitMaxError string `json:"limitmaxerror,omitempty"` LimitErrorMsg string `json:"limiterrormsg,omitempty"` LimitMode string `json:"limitmode,omitempty"` Warning string `json:"warning,omitempty"` }
SensorChannel has the channel name and value and options
func (*SensorChannel) SetCustomUnit ¶ added in v0.2.0
func (r *SensorChannel) SetCustomUnit(unit string) *SensorChannel
Sets a custom unit text, that is displayed behind the value.
func (*SensorChannel) SetDecimalMode ¶ added in v0.2.0
func (r *SensorChannel) SetDecimalMode(mode DecimalModeType) *SensorChannel
If value is a float a custom number of decimal places can be set.
func (*SensorChannel) SetErrLimitMsg ¶ added in v0.2.0
func (r *SensorChannel) SetErrLimitMsg(msg string) *SensorChannel
Define an additional message. It will be added to the sensor's message when entering a Down status that is triggered by a limit.
func (*SensorChannel) SetMaxErrLimit ¶ added in v0.2.0
func (r *SensorChannel) SetMaxErrLimit(limit int) *SensorChannel
Define an upper error limit for the channel. If enabled, the sensor will be set to a Down status if this value is overrun.
func (*SensorChannel) SetMaxWarnLimit ¶ added in v0.2.0
func (r *SensorChannel) SetMaxWarnLimit(limit int) *SensorChannel
Define an upper warning limit for the channel. If enabled, the sensor will be set to a Warning status if this value is overrun.
func (*SensorChannel) SetMinErrLimit ¶ added in v0.2.0
func (r *SensorChannel) SetMinErrLimit(limit int) *SensorChannel
Define a lower error limit for the channel. If enabled, the sensor will be set to a Down status if this value is undercut.
func (*SensorChannel) SetMinWarnLimit ¶ added in v0.2.0
func (r *SensorChannel) SetMinWarnLimit(limit int) *SensorChannel
Define an upper error limit for the channel. If enabled, the sensor will be set to a Down status if this value is overrun.
func (*SensorChannel) SetShowChart ¶ added in v0.2.0
func (r *SensorChannel) SetShowChart(show bool) *SensorChannel
Init value for the Show in graphs option. Default is yes.
func (*SensorChannel) SetShowTable ¶ added in v0.2.0
func (r *SensorChannel) SetShowTable(show bool) *SensorChannel
Init value for the Show in tables option. Default is yes.
func (*SensorChannel) SetSpeedSize ¶ added in v0.2.0
func (r *SensorChannel) SetSpeedSize(size SpeedType) *SensorChannel
Speed size used for the display value. For example, if you have a value of 50000 and use KiloBit as size, the display is 50 kiloBits. Default is One (value used as returned).
func (*SensorChannel) SetSpeedTime ¶ added in v0.2.0
func (r *SensorChannel) SetSpeedTime(time TimeType) *SensorChannel
Time size used for the display value. For example, if you have a value of 780 and use Minute as size, the display is 13 Minutes. Default is Second (value used as returned).
func (*SensorChannel) SetToWarning ¶ added in v0.2.0
func (r *SensorChannel) SetToWarning() *SensorChannel
If enabled for at least one channel, the entire sensor is set to "Warning" status. Default is "not set".
func (*SensorChannel) SetUnit ¶ added in v0.2.0
func (r *SensorChannel) SetUnit(unit UnitType) *SensorChannel
The unit of the value. Default is Custom. This is useful for PRTG to be able to convert volumes and times.
func (*SensorChannel) SetValue ¶ added in v0.2.0
func (r *SensorChannel) SetValue(val interface{}) *SensorChannel
Sets a value. All types allowed except complex and uintptr.
func (*SensorChannel) SetValueLookup ¶ added in v0.2.0
func (r *SensorChannel) SetValueLookup(lookup string) *SensorChannel
Define if you want to use a lookup file (for example, to view integer values as status texts). Enter the ID of the lookup file you want to use, or omit this element to not use lookups.
func (*SensorChannel) SetVolumeSize ¶ added in v0.2.0
func (r *SensorChannel) SetVolumeSize(size SizeType) *SensorChannel
Volume size used for the display value. For example, if you have a value of 50000 and use Kilo as size, the display is 50 kilo. Default is One (value used as returned).
func (*SensorChannel) SetWarnLimitMsg ¶ added in v0.2.0
func (r *SensorChannel) SetWarnLimitMsg(msg string) *SensorChannel
Define an additional message. It will be added to the sensor's message when entering a Warning status that is triggered by a limit.
func (*SensorChannel) ValueIsDifference ¶ added in v0.2.0
func (r *SensorChannel) ValueIsDifference() *SensorChannel
Select if the value is an absolute value or counter. Default is "Absolute" set.
type SensorResponse ¶
type SensorResponse struct {
SensorResults SensorResults `json:"prtg"`
}
SensorStatus has the whole JSON object
type SensorResults ¶ added in v0.2.0
type SensorResults struct { SensorChannels []SensorChannel `json:"result"` Text string `json:"text,omitempty"` Error string `json:"error,omitempty"` }
SensorResults has all the channels
func (*SensorResults) AddChannel ¶ added in v0.2.0
func (sr *SensorResults) AddChannel(channelName string) *SensorChannel
Name of the channel as displayed in user interfaces.
func (*SensorResults) MarshalToString ¶ added in v0.2.0
func (sr *SensorResults) MarshalToString() (string, error)
Create a JSON string from the PRTG object
func (*SensorResults) SetError ¶ added in v0.2.0
func (sr *SensorResults) SetError(err bool) *SensorResults
If enabled, the sensor will return an error status. This element can be combined with the SensorText element in order to show an error message. Default is 0.
func (*SensorResults) SetSensorText ¶ added in v0.2.0
func (sr *SensorResults) SetSensorText(text string) *SensorResults
Text the sensor returns in the Message field with every scanning interval. There can be one message per sensor, regardless of the number of channels. Default is OK.
type UnitType ¶ added in v0.2.0
type UnitType string
const ( BytesBandwidth UnitType = "BytesBandwidth" BytesDisk UnitType = "BytesDisk" Temperature UnitType = "Temperature" Percent UnitType = "Percent" TimeResponse UnitType = "TimeResponse" TimeSeconds UnitType = "TimeSeconds" Custom UnitType = "Custom" Count UnitType = "Count" CPU UnitType = "CPU" BytesFile UnitType = "BytesFile" SpeedDisk UnitType = "SpeedDisk" SpeedNet UnitType = "SpeedNet" TimeHours UnitType = "TimeHours" )