Documentation
¶
Index ¶
- Constants
- Variables
- type AddDeviceResponse
- type Client
- func (c *Client) AddDevice(ip string) (deviceID int, err error)
- func (c *Client) FindPortForIP(ip string) (port Port, err error)
- func (c *Client) GetDevice(deviceID int) (LibreDevice, error)
- func (c *Client) GetDeviceByIP(ip string) (device LibreDevice, err error)
- func (c *Client) GetIPs() (ipList []IP, err error)
- func (c *Client) GetPort(portID int) (port Port, err error)
- func (c *Client) GetPortsForDevice(id int) (ports []Port, err error)
- func (c *Client) LoadIPs() error
- type IP
- type IPResponse
- type LibreAlert
- type LibreDevice
- type LibreDeviceResponse
- type LibreErrorResponse
- type Port
- type PortResponse
- type PortSearchResponse
Constants ¶
const ( AlertFiring = 1 AlertCleared = 0 )
Variables ¶
var ErrNotFound = errors.New("the request object was not found")
Functions ¶
This section is empty.
Types ¶
type AddDeviceResponse ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddDevice ¶
AddDevice adds the given IP to LibreNMS to monitor. Returns the device ID assigned in LibreNMS
func (*Client) GetDevice ¶
func (c *Client) GetDevice(deviceID int) (LibreDevice, error)
GetDevice returns the device with the corresponding ID
func (*Client) GetDeviceByIP ¶
func (c *Client) GetDeviceByIP(ip string) (device LibreDevice, err error)
func (*Client) GetPortsForDevice ¶
GetPortsForDevice returns all of the ports for the given device. If the number of ports returned is zero an ErrNotFound is returned
type IPResponse ¶
type LibreAlert ¶
type LibreAlert struct { DeviceID int `json:"device_id"` Host string `json:"host"` ID string `json:"id"` IP string `json:"ip"` Location string `json:"location"` Runbook string `json:"runbook"` Severity string `json:"severity"` State int `json:"state"` Subject string `json:"subject"` SysName string `json:"sysName"` Timestamp string `json:"timestamp"` UID string `json:"uid"` }
LibreAlert represents an API alert from LibreNMS. Transport configuration should look like this:
Transport Headers: Content-type=application/json Transport Body: ``` {"device_id": {{ $device_id }}, "timestamp": "{{ $timestamp }}", "subject": "{{ $title }}", "host": "{{ $hostname }}", "sysName": "{{ $sysName }}", "location": "{{ $location }}", "ip": "{{ $ip }}", "state": {{ $state }}, "severity": "{{ $severity }}", "id": "{{ $id }}", "uid": "{{ $uid }}", "runbook": "{{ $proc }}" } ```
type LibreDevice ¶
type LibreDevice struct { Community *string `json:"community"` DeviceID int `json:"device_id"` DisableNotify int `json:"disable_notify"` Disabled int `json:"disabled"` Display *string `json:"display"` Features interface{} `json:"features"` Hardware *string `json:"hardware"` Hostname string `json:"hostname"` IP string `json:"ip"` Ignore int `json:"ignore"` IgnoreStatus int `json:"ignore_status"` Lat *float32 `json:"lat"` Lng *float32 `json:"lng"` Location string `json:"location"` LocationID int `json:"location_id"` MaxDepth int `json:"max_depth"` Notes *string `json:"notes"` Os string `json:"os"` PollerGroup int `json:"poller_group"` Port int `json:"port"` PortAssociationMode int `json:"port_association_mode"` Purpose *string `json:"purpose"` Serial *string `json:"serial"` Status bool `json:"status"` StatusReason string `json:"status_reason"` SysContact *string `json:"sysContact"` SysDescr *string `json:"sysDescr"` SysName *string `json:"sysName"` SysObjectID *string `json:"sysObjectID"` Type *string `json:"type"` Uptime int `json:"uptime"` Version *string `json:"version"` }
type LibreDeviceResponse ¶
type LibreDeviceResponse struct { Count int `json:"count"` Devices []LibreDevice `json:"devices"` Status string `json:"status"` }
type LibreErrorResponse ¶
LibreErrorResponse can be used to decode the body when a non-2xx status is returned
func GetLibreError ¶
func GetLibreError(resp *resty.Response) (LibreErrorResponse, error)
type Port ¶
type Port struct { DeviceID int `json:"device_id"` IfAdminStatus string `json:"ifAdminStatus"` IfAdminStatusPrev string `json:"ifAdminStatus_prev"` IfAlias string `json:"ifAlias"` IfConnectorPresent string `json:"ifConnectorPresent"` IfDescr string `json:"ifDescr"` IfDuplex *string `json:"ifDuplex"` IfMtu int `json:"ifMtu"` IfName string `json:"ifName"` IfOperStatus string `json:"ifOperStatus"` IfOperStatusPrev string `json:"ifOperStatus_prev"` IfSpeed *int `json:"ifSpeed"` IfSpeedPrev int `json:"ifSpeed_prev"` IfType string `json:"ifType"` IfPhysAddress *string `json:"ifPhysAddress"` IfVlan *string `json:"ifVlan"` IfTrunk *string `json:"ifTrunk"` PortDescrCircuit *string `json:"port_descr_circuit"` PortDescrDescr *string `json:"port_descr_descr"` PortDescrNotes *string `json:"port_descr_notes"` PortDescrSpeed *int `json:"port_descr_speed"` PortDescrType *string `json:"port_descr_type"` PortID int `json:"port_id"` PortName *string `json:"portName"` }
func (Port) GetPhysAddress ¶
type PortResponse ¶
type PortResponse struct { Count int `json:"count"` Ports []Port `json:"port"` Status string `json:"status"` }
PortResponse is returned when querying for a given port