api

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const CollectionStatusFailed = "FAILED"

CollectionStatusFailed collection failed

View Source
const CollectionStatusSucceded = "SUCCEEDED"

CollectionStatusSucceded collection finished successfully

View Source
const CollectionStatusUnknown = "UNKNOWN"

CollectionStatusUnknown status unknown

View Source
const DefaultRetries = 2

DefaultRetries default retries

View Source
const DefaultTimeout = 3 * time.Second

DefaultTimeout default timeout duration

View Source
const ServiceAvailable = "Up"

ServiceAvailable poll status name available

View Source
const ServiceAvailableCode = 1

ServiceAvailableCode poll status cod for ServiceAvailable

View Source
const ServiceUnavailable = "Down"

ServiceUnavailable poll status name unavailable

View Source
const ServiceUnavailableCode = 2

ServiceUnavailableCode poll status cod for ServiceUnavailable

View Source
const ServiceUnknown = "Unknown"

ServiceUnknown poll status name unknown

View Source
const ServiceUnknownCode = 0

ServiceUnknownCode poll status cod for ServiceUnknown

View Source
const ServiceUnresponsive = "Unresponsive"

ServiceUnresponsive poll status name unavailable

View Source
const ServiceUnresponsiveCode = 3

ServiceUnresponsiveCode poll status cod for ServiceUnresponsive

View Source
const TimeFormat = "2006-01-02T15:04:05.000-07:00"

TimeFormat the format to be used to marshal/unmarshal date from strings

Variables

This section is empty.

Functions

func RegisterRPCModule

func RegisterRPCModule(module RPCModule)

RegisterRPCModule registers a new RPC Module implementation

func UnregisterRPCModule

func UnregisterRPCModule(module RPCModule)

UnregisterRPCModule unregister an existing RPC Module implementation

Types

type Broker

type Broker interface {

	// Starts the broker (non-blocking method)
	Start() error

	// Shuts down the broker
	Stop()
}

Broker represents a broker implementation to control its life cycle

type CircuitBreakerConfig

type CircuitBreakerConfig struct {
	MaxRequests uint32 `yaml:"maxRequests,omitempty" json:"maxRequests,omitempty"`
	Interval    int    `yaml:"interval,omitempty" json:"interval,omitempty"`
	Timeout     int    `yaml:"timeout,omitempty" json:"timeout,omitempty"`
}

CircuitBreakerConfig Circuit Breaker Configuration

type CollectionAgentDTO

type CollectionAgentDTO struct {
	XMLName             xml.Name                 `xml:"agent"`
	IPAddress           string                   `xml:"address,attr"`
	StoreByFS           bool                     `xml:"store-by-fs,attr"`
	NodeID              int                      `xml:"node-id,attr"`
	NodeLabel           string                   `xml:"node-label,attr"`
	ForeignSource       string                   `xml:"foreign-source,attr,omitempty"`
	ForeignID           string                   `xml:"foreign-id,attr,omitempty"`
	Location            string                   `xml:"location,attr,omitempty"`
	StorageResourcePath string                   `xml:"storage-resource-path,attr"`
	SysUpTime           int64                    `xml:"sys-up-time,attr"`
	Attributes          []CollectionAttributeDTO `xml:"attribute,omitempty"`
}

CollectionAgentDTO represents a collection agent

type CollectionAttributeDTO

type CollectionAttributeDTO struct {
	XMLName xml.Name `xml:"attribute"`
	Key     string   `xml:"key,attr"`
	Content string   `xml:",innerxml"`
}

CollectionAttributeDTO represents a collection attribute

type CollectionResourceDTO

type CollectionResourceDTO struct {
	XMLName           xml.Name                `xml:"collection-resource"`
	Name              string                  `xml:"name,attr,omitempty"`
	ResourceType      interface{}             // NodeLevelResourceDTO, InterfaceLevelResourceDTO, or GenericTypeResourceDTO
	Resources         []CollectionResourceDTO `xml:"resource"`
	NumericAttributes []ResourceAttributeDTO  `xml:"numeric-attribute"`
	StringAttributes  []ResourceAttributeDTO  `xml:"string-attribute"`
}

CollectionResourceDTO represents a collection resource

func (*CollectionResourceDTO) AddAttribute

func (resource *CollectionResourceDTO) AddAttribute(attr ResourceAttributeDTO)

AddAttribute adds an attribute

type CollectionSetBuilder

type CollectionSetBuilder struct {
	Agent *CollectionAgentDTO
	// contains filtered or unexported fields
}

CollectionSetBuilder represents a collection set builder

func NewCollectionSetBuilder

func NewCollectionSetBuilder(agent *CollectionAgentDTO) *CollectionSetBuilder

NewCollectionSetBuilder returns a new CollectionSet builder

func (*CollectionSetBuilder) Build

func (builder *CollectionSetBuilder) Build() *CollectionSetDTO

Build generates the collection set

func (*CollectionSetBuilder) WithAttribute

func (builder *CollectionSetBuilder) WithAttribute(resource *CollectionResourceDTO, groupName string, metricName string, metricValue string, metricType string) *CollectionSetBuilder

WithAttribute adds an attribute

func (*CollectionSetBuilder) WithMetric added in v0.1.5

WithMetric adds a metric/attribute object

func (*CollectionSetBuilder) WithStatus

func (builder *CollectionSetBuilder) WithStatus(status string) *CollectionSetBuilder

WithStatus sets the status

func (*CollectionSetBuilder) WithTimestamp

func (builder *CollectionSetBuilder) WithTimestamp(ts time.Time) *CollectionSetBuilder

WithTimestamp sets the timestamp

type CollectionSetDTO

type CollectionSetDTO struct {
	XMLName                   xml.Name                `xml:"collection-set"`
	Timestamp                 *Timestamp              `xml:"timestamp,attr"`
	Status                    string                  `xml:"collection-status,attr"`
	DisableCounterPersistence bool                    `xml:"disable-counter-persistence,attr,omitempty"`
	SequenceNumber            int                     `xml:"sequence-number,attr,omitempty"`
	Agent                     *CollectionAgentDTO     `xml:"agent"`
	Resources                 []CollectionResourceDTO `xml:"collection-resource"`
}

CollectionSetDTO represents a collection set

func (*CollectionSetDTO) AddResource

func (set *CollectionSetDTO) AddResource(resource CollectionResourceDTO)

AddResource adds a new resource to the collection set

type CollectorRequestDTO

type CollectorRequestDTO struct {
	XMLName                    xml.Name                 `xml:"collector-request"`
	Location                   string                   `xml:"location,attr"`
	SystemID                   string                   `xml:"system-id,attr"`
	ClassName                  string                   `xml:"class-name,attr"`
	AttributesNeedUnmarshaling bool                     `xml:"attributes-need-unmarshaling,attr"`
	CollectionAgent            *CollectionAgentDTO      `xml:"agent,omitempty"`
	Attributes                 []CollectionAttributeDTO `xml:"attribute,omitempty"`
}

CollectorRequestDTO represents a collector request

func (*CollectorRequestDTO) GetAttributeValue

func (req *CollectorRequestDTO) GetAttributeValue(key string, defaultValue string) string

GetAttributeValue gets the value of a given attribute

func (*CollectorRequestDTO) GetCollector

func (req *CollectorRequestDTO) GetCollector() string

GetCollector returns the simple class name for the collector implementation

func (*CollectorRequestDTO) GetResourcePath

func (req *CollectorRequestDTO) GetResourcePath() string

GetResourcePath returns the base resource path

func (*CollectorRequestDTO) GetTimeout

func (req *CollectorRequestDTO) GetTimeout() time.Duration

GetTimeout extracts the duration of the timeout attribute if available; otherwise returns default value

type CollectorResponseDTO

type CollectorResponseDTO struct {
	XMLName       xml.Name          `xml:"collector-response"`
	Error         string            `xml:"error,attr,omitempty"`
	CollectionSet *CollectionSetDTO `xml:"collection-set"`
}

CollectorResponseDTO represents a collector response

func (*CollectorResponseDTO) GetStatus

func (set *CollectorResponseDTO) GetStatus() string

GetStatus returns the collection status as a string

func (*CollectorResponseDTO) MarkAsFailed

func (set *CollectorResponseDTO) MarkAsFailed(agent *CollectionAgentDTO, err error)

MarkAsFailed sets the response as failed

type DNSConfig

type DNSConfig struct {
	NameServer           string               `yaml:"nameServer,omitempty" json:"nameServer,omitempty"`
	Timeout              int                  `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	CacheRefreshDuration int                  `yaml:"cacheRefreshDuration,omitempty" json:"cacheRefreshDuration,omitempty"`
	CircuitBreaker       CircuitBreakerConfig `yaml:"circuitBreaker" json:"circuitBreaker"`
}

DNSConfig DNS Configuration

type DNSLookupRequestDTO

type DNSLookupRequestDTO struct {
	XMLName     xml.Name `xml:"dns-lookup-request"`
	Location    string   `xml:"location,attr"`
	SystemID    string   `xml:"system-id,attr"`
	HostRequest string   `xml:"host-request,attr"`
	QueryType   string   `xml:"query-type,attr"`
}

DNSLookupRequestDTO represents a DNS Lookup request

type DNSLookupResponseDTO

type DNSLookupResponseDTO struct {
	XMLName      xml.Name `xml:"dns-lookup-response"`
	HostResponse string   `xml:"host-response,attr,omitempty"`
	Error        string   `xml:"error,attr,omitempty"`
}

DNSLookupResponseDTO represents a DNS Lookup response

type DetectorAttributeDTO

type DetectorAttributeDTO struct {
	Key   string `xml:"key,attr"`
	Value string `xml:",chardata"`
}

DetectorAttributeDTO represents a detector attribute

type DetectorRequestDTO

type DetectorRequestDTO struct {
	XMLName   xml.Name `xml:"detector-request"`
	Location  string   `xml:"location,attr"`
	SystemID  string   `xml:"system-id,attr"`
	ClassName string   `xml:"class-name,attr"`
	IPAddress string   `xml:"address,attr"`

	DetectorAttributes []DetectorAttributeDTO `xml:"detector-attribute,omitempty"`
	RuntimeAttributes  []DetectorAttributeDTO `xml:"runtime-attribute,omitempty"`
}

DetectorRequestDTO represents a detector request

func (*DetectorRequestDTO) GetAttributeValue

func (req *DetectorRequestDTO) GetAttributeValue(key string, defaultValue string) string

GetAttributeValue extract the value of a given detector attribute

func (*DetectorRequestDTO) GetAttributeValueAsInt

func (req *DetectorRequestDTO) GetAttributeValueAsInt(key string) int

GetAttributeValueAsInt extract the value as an integer of a given detector attribute

func (*DetectorRequestDTO) GetDetector

func (req *DetectorRequestDTO) GetDetector() string

GetDetector returns the simple class name for the detector implementation

func (*DetectorRequestDTO) GetRetries

func (req *DetectorRequestDTO) GetRetries() int

GetRetries extracts the retries attribute if available; otherwise returns default value

func (*DetectorRequestDTO) GetRuntimeAttributeValue

func (req *DetectorRequestDTO) GetRuntimeAttributeValue(key string) string

GetRuntimeAttributeValue extract the value of a given runtime attribute

func (*DetectorRequestDTO) GetRuntimeAttributeValueAsInt

func (req *DetectorRequestDTO) GetRuntimeAttributeValueAsInt(key string) int

GetRuntimeAttributeValueAsInt extract the value as an integer of a given runtime attribute

func (*DetectorRequestDTO) GetTimeout

func (req *DetectorRequestDTO) GetTimeout() time.Duration

GetTimeout extracts the duration of the timeout attribute if available; otherwise returns default value

type DetectorResponseDTO

type DetectorResponseDTO struct {
	XMLName    xml.Name               `xml:"detector-response"`
	Error      string                 `xml:"error,attr,omitempty"`
	Detected   bool                   `xml:"detected,attr"`
	Attributes []DetectorAttributeDTO `xml:"attribute,omitempty"`
}

DetectorResponseDTO represents a detector response

func (DetectorResponseDTO) GetStatus

func (response DetectorResponseDTO) GetStatus() string

GetStatus returns the detection status as a string

type EchoRequest

type EchoRequest struct {
	XMLName     xml.Name `xml:"echo-request"`
	ID          int64    `xml:"id,attr"`
	Message     string   `xml:"message,attr"`
	Body        string   `xml:"body,omitempty"`
	Location    string   `xml:"location,attr"`
	SystemID    string   `xml:"system-id,attr"`
	Delay       int64    `xml:"delay,attr"`
	ShouldThrow bool     `xml:"throw,attr"`
}

EchoRequest represents an echo request

type EchoResponse

type EchoResponse struct {
	XMLName xml.Name `xml:"echo-response"`
	ID      int64    `xml:"id,attr"`
	Message string   `xml:"message,attr,omitempty"`
	Body    string   `xml:"body,omitempty"`
	Error   string   `xml:"error,attr,omitempty"`
}

EchoResponse represents an echo response

type GenericTypeResourceDTO

type GenericTypeResourceDTO struct {
	XMLName   xml.Name              `xml:"generic-type-resource"`
	Node      *NodeLevelResourceDTO `xml:"node-level-resource"`
	Name      string                `xml:"name,attr"`
	Fallback  string                `xml:"fallback,attr"`
	Instance  string                `xml:"instance,attr"`
	Timestamp *Timestamp            `xml:"timestamp,attr,omitempty"`
}

GenericTypeResourceDTO represents a Generic Level Resource Type

type HTTPAttribute

type HTTPAttribute struct {
	XMLName    xml.Name `xml:"attrib"`
	Alias      string   `xml:"alias,attr"`
	MatchGroup int      `xml:"match-group,attr"`
	Type       string   `xml:"type,attr"`
}

HTTPAttribute represents an HTTP attribute

type HTTPAttributeList

type HTTPAttributeList struct {
	XMLName       xml.Name        `xml:"attributes"`
	AttributeList []HTTPAttribute `xml:"attrib"`
}

HTTPAttributeList represents a list of HTTP attributes object

type HTTPCollection

type HTTPCollection struct {
	XMLName xml.Name     `xml:"http-collection"`
	Name    string       `xml:"name,attr"`
	RRD     *RRD         `xml:"rrd"`
	URIs    *HTTPUriList `xml:"uris"`
}

HTTPCollection represents an HTTP collection object

func (*HTTPCollection) AddURI

func (collection *HTTPCollection) AddURI(uri HTTPUri)

AddURI adds a new URI to the HTTP collection

func (*HTTPCollection) FindURI

func (collection *HTTPCollection) FindURI(name string) *HTTPUri

FindURI finds a URI by its name

type HTTPUri

type HTTPUri struct {
	XMLName    xml.Name           `xml:"uri"`
	Name       string             `xml:"name,attr"`
	URL        *HTTPUrl           `xml:"url"`
	Attributes *HTTPAttributeList `xml:"attributes"`
}

HTTPUri represents an HTTP URI object

func (*HTTPUri) AddAttribute

func (uri *HTTPUri) AddAttribute(attrib HTTPAttribute)

AddAttribute adds a new HTTP attribute

func (*HTTPUri) FindAttributeByAlias

func (uri *HTTPUri) FindAttributeByAlias(alias string) *HTTPAttribute

FindAttributeByAlias finds an attribute by alias

func (*HTTPUri) FindAttributeByMatchGroup

func (uri *HTTPUri) FindAttributeByMatchGroup(matchGroup int) *HTTPAttribute

FindAttributeByMatchGroup finds an attribute by match group

type HTTPUriList

type HTTPUriList struct {
	XMLName xml.Name  `xml:"uris"`
	URIList []HTTPUri `xml:"uri"`
}

HTTPUriList represents a list of HTTP URI object

type HTTPUrl

type HTTPUrl struct {
	XMLName       xml.Name `xml:"url"`
	Path          string   `xml:"path,attr"`
	UserAgent     string   `xml:"user-agent,attr"`
	Matches       string   `xml:"matches,attr"`
	ResponseRange string   `xml:"response-range,attr"`
}

HTTPUrl represents an HTTP URL object

type InterfaceLevelResourceDTO

type InterfaceLevelResourceDTO struct {
	XMLName   xml.Name              `xml:"interface-level-resource"`
	Node      *NodeLevelResourceDTO `xml:"node-level-resource"`
	IntfName  string                `xml:"if-name,attr"`
	Timestamp *Timestamp            `xml:"timestamp,attr,omitempty"`
}

InterfaceLevelResourceDTO represents an Interface Level Resource Type

type Metrics added in v0.1.2

type Metrics struct {
	SinkMsgDeliverySucceeded *prometheus.CounterVec // Sink messages successfully delivered
	SinkMsgDeliveryFailed    *prometheus.CounterVec // Failed attempts to send Sink messages
	RPCReqReceivedSucceeded  *prometheus.CounterVec // RPC requests successfully received
	RPCReqReceivedFailed     *prometheus.CounterVec // Failed attempts to receive RPC requests
	RPCReqProcessedSucceeded *prometheus.CounterVec // RPC requests successfully processed
	RPCReqProcessedFailed    *prometheus.CounterVec // Failed attempts to process RPC requests
	RPCResSentSucceeded      *prometheus.CounterVec // RPC responses successfully sent
	RPCResSentFailed         *prometheus.CounterVec // Failed attempts to send RPC responses
}

Metrics represents the broker metric set per module

func NewMetrics added in v0.1.2

func NewMetrics() *Metrics

NewMetrics returns a new Metrics object

func (*Metrics) Register added in v0.1.2

func (m *Metrics) Register()

Register register all prometheus metrics

type MinionConfig

type MinionConfig struct {
	ID               string            `yaml:"id" json:"id"`
	Location         string            `yaml:"location" json:"location"`
	BrokerURL        string            `yaml:"brokerUrl" json:"brokerUrl"`
	BrokerType       string            `yaml:"brokerType" json:"brokerType"`
	BrokerProperties map[string]string `yaml:"brokerProperties,omitempty" json:"brokerProperties,omitempty"`
	TrapPort         int               `yaml:"trapPort" json:"trapPort"`
	SyslogPort       int               `yaml:"syslogPort" json:"syslogPort"`
	StatsPort        int               `yaml:"statsPort" json:"statsPort"`
	LogLevel         string            `yaml:"logLevel" json:"logLevel"`
	DNS              *DNSConfig        `yaml:"dns,omitempty" json:"dns,omitempty"`
	Listeners        []MinionListener  `yaml:"listeners,omitempty" json:"listeners,omitempty"`
}

MinionConfig represents basic Minion Configuration

func (*MinionConfig) GetBrokerProperty added in v0.1.9

func (cfg *MinionConfig) GetBrokerProperty(property string) string

func (*MinionConfig) GetHeaderResponse

func (cfg *MinionConfig) GetHeaderResponse() *ipc.RpcResponseProto

GetHeaderResponse builds an RPC response with the headers context

func (*MinionConfig) GetListener

func (cfg *MinionConfig) GetListener(name string) *MinionListener

GetListener gets a given listener by name

func (*MinionConfig) GetListenerByParser

func (cfg *MinionConfig) GetListenerByParser(parser string) *MinionListener

GetListenerByParser gets a given listener by parser name

func (*MinionConfig) IsValid

func (cfg *MinionConfig) IsValid() error

IsValid returns an error if the configuration is not valid

func (*MinionConfig) ParseListeners

func (cfg *MinionConfig) ParseListeners(csvs []string) error

ParseListeners parses an array of listeners in CSV format

func (*MinionConfig) String

func (cfg *MinionConfig) String() string

type MinionIdentityDTO

type MinionIdentityDTO struct {
	XMLName   xml.Name   `xml:"minion"`
	ID        string     `xml:"id"`
	Location  string     `xml:"location"`
	Timestamp *Timestamp `xml:"timestamp"`
}

MinionIdentityDTO represents the Minion Identity

type MinionListener

type MinionListener struct {
	Name       string            `yaml:"name" json:"name"`
	Parser     string            `yaml:"parser" json:"parser"`
	Port       int               `yaml:"port" json:"port"`
	Properties map[string]string `yaml:"properties,omitempty" json:"properties,omitempty"`
}

MinionListener represents a Minion Listener

func (*MinionListener) GetParser

func (listener *MinionListener) GetParser() string

GetParser returns the simple class name for the parser implementation

func (*MinionListener) Is

func (listener *MinionListener) Is(parser string) bool

Is returns true if the listener matches a given parser

type NodeLevelResourceDTO

type NodeLevelResourceDTO struct {
	XMLName   xml.Name   `xml:"node-level-resource"`
	NodeID    int        `xml:"node-id,attr"`
	Path      string     `xml:"path,attr,omitempty"`
	Timestamp *Timestamp `xml:"timestamp,attr,omitempty"`
}

NodeLevelResourceDTO represents a Node Level Resource Type

type PingRequest

type PingRequest struct {
	XMLName    xml.Name `xml:"ping-request"`
	Location   string   `xml:"location,attr"`
	SystemID   string   `xml:"system-id,attr"`
	Retries    int      `xml:"retries,attr"`
	Timeout    int      `xml:"timeout,attr"`
	Address    string   `xml:"address"`
	PacketSize int      `xml:"packet-size"`
}

PingRequest represents a ping request

func (*PingRequest) GetTimeout

func (req *PingRequest) GetTimeout() time.Duration

GetTimeout gets the timeout duration

type PingResponse

type PingResponse struct {
	XMLName xml.Name `xml:"ping-response"`
	RTT     float64  `xml:"rtt,omitempty"`
	Error   string   `xml:"error,attr,omitempty"`
}

PingResponse represents a ping response

type PollStatus

type PollStatus struct {
	XMLName      xml.Name                `xml:"poll-status"`
	Timestamp    *Timestamp              `xml:"time,attr,omitempty"`
	Reason       string                  `xml:"reason,attr,omitempty"`
	ResponseTime float64                 `xml:"response-time,attr"`
	StatusCode   int                     `xml:"code,attr"`
	StatusName   string                  `xml:"name,attr"`
	Properties   *PollStatusPropertyList `xml:"properties,omitempty"`
}

PollStatus represents a poll status

func (*PollStatus) Down

func (status *PollStatus) Down(reason string)

Down update the poll status for an unavailable service

func (*PollStatus) GetPropertyValue

func (status *PollStatus) GetPropertyValue(key string) float64

GetPropertyValue adds or updates an existing property

func (*PollStatus) SetProperty

func (status *PollStatus) SetProperty(key string, value float64)

SetProperty adds or updates an existing property

func (*PollStatus) Unknown

func (status *PollStatus) Unknown(reason string)

Unknown update the poll status to be unknown

func (*PollStatus) Up

func (status *PollStatus) Up(responseTime float64) *PollStatus

Up update the poll status for an available service

type PollStatusProperty

type PollStatusProperty struct {
	XMLName xml.Name `xml:"property"`
	Key     string   `xml:"key,attr"`
	Value   float64  `xml:",chardata"`
}

PollStatusProperty represents a poll status property

type PollStatusPropertyList

type PollStatusPropertyList struct {
	XMLName      xml.Name             `xml:"properties"`
	PropertyList []PollStatusProperty `xml:"property"`
}

PollStatusPropertyList represents a poll status property list

type PollerAttributeDTO

type PollerAttributeDTO struct {
	Key     string `xml:"key,attr"`
	Value   string `xml:"value,attr"`
	Content string `xml:",innerxml"`
}

PollerAttributeDTO represents a poller atrribute

type PollerRequestDTO

type PollerRequestDTO struct {
	XMLName      xml.Name             `xml:"poller-request"`
	Location     string               `xml:"location,attr"`
	SystemID     string               `xml:"system-id,attr"`
	ClassName    string               `xml:"class-name,attr"`
	ServiceName  string               `xml:"service-name,attr"`
	IPAddress    string               `xml:"address,attr"`
	NodeID       string               `xml:"node-id,attr"`
	NodeLabel    string               `xml:"node-label,attr"`
	NodeLocation string               `xml:"node-location,attr"`
	Attributes   []PollerAttributeDTO `xml:"attribute,omitempty"`
}

PollerRequestDTO represents a poller request

func (*PollerRequestDTO) GetAttributeContent

func (req *PollerRequestDTO) GetAttributeContent(key string) string

GetAttributeContent gets the value of a given attribute

func (*PollerRequestDTO) GetAttributeValue

func (req *PollerRequestDTO) GetAttributeValue(key string, defaultValue string) string

GetAttributeValue gets the value of a given attribute

func (*PollerRequestDTO) GetAttributeValueAsInt

func (req *PollerRequestDTO) GetAttributeValueAsInt(key string, defaultValue int) int

GetAttributeValueAsInt gets the value of a given attribute as integer

func (*PollerRequestDTO) GetMonitor

func (req *PollerRequestDTO) GetMonitor() string

GetMonitor returns the simple class name for the monitor implementation

func (*PollerRequestDTO) GetRetries

func (req *PollerRequestDTO) GetRetries() int

GetRetries extracts the retries attribute if available; otherwise returns default value

func (*PollerRequestDTO) GetTimeout

func (req *PollerRequestDTO) GetTimeout() time.Duration

GetTimeout extracts the duration of the timeout attribute if available; otherwise returns default value

type PollerResponseDTO

type PollerResponseDTO struct {
	XMLName xml.Name    `xml:"poller-response"`
	Error   string      `xml:"error,attr,omitempty"`
	Status  *PollStatus `xml:"poll-status,omitempty"`
}

PollerResponseDTO represents a poller response

type RPCModule

type RPCModule interface {

	// Returns the ID of the RPC Module implementation
	GetID() string

	// Executes an RPC request and returns the response
	// The response tells if the operation was successful or not
	Execute(request *ipc.RpcRequestProto) *ipc.RpcResponseProto
}

RPCModule represents an implementation of an OpenNMS RPC Module

func GetAllRPCModules

func GetAllRPCModules() []RPCModule

GetAllRPCModules gets all the registered RPC modules

func GetRPCModule

func GetRPCModule(id string) (RPCModule, bool)

GetRPCModule gets the RPC Module implementation for a given ID

type RRA

type RRA struct {
	XMLName xml.Name `xml:"rra"`
	Content string   `xml:",chardata"`
}

RRA represents an RRA object

type RRD

type RRD struct {
	XMLName xml.Name `xml:"rrd"`
	Step    int      `xml:"step,attr"`
	RRAs    []RRA    `xml:"rra"`
}

RRD represents an RRD object

type ResourceAttributeDTO

type ResourceAttributeDTO struct {
	Group      string `xml:"group,attr"`
	Name       string `xml:"name,attr"`
	Type       string `xml:"type,attr"`
	Identifier string `xml:"identifier,attr,omitempty"`
	Value      string `xml:"value,attr"`
}

ResourceAttributeDTO represents a generic resource attribute

type SNMPAgentDTO

type SNMPAgentDTO struct {
	Address         string `xml:"address"`
	ProxyFor        string `xml:"proxyFor"`
	Version         int    `xml:"version"`
	VersionAsString string `xml:"versionAsString"`
	MaxRepetitions  int    `xml:"maxRepetitions"`
	MaxRequestSize  int    `xml:"maxRequestSize"`
	MaxVarsPerPdu   int    `xml:"maxVarsPerPdu"`
	Port            int    `xml:"port"`
	Retries         int    `xml:"retries"`
	Timeout         int    `xml:"timeout"`
	ReadCommunity   string `xml:"readCommunity"`
	WriteCommunity  string `xml:"writeCommunity"`
	SecurityLevel   int    `xml:"securityLevel"`
	SecurityName    string `xml:"securityName"`
	AuthPassPhrase  string `xml:"authPassPhrase"`
	AuthProtocol    string `xml:"authProtocol"`
	PrivPassPhrase  string `xml:"privPassPhrase"`
	PrivProtocol    string `xml:"privProtocol"`
	ContextName     string `xml:"contextName"`
	ContextEngineID string `xml:"contextEngineId"`
	EngineID        string `xml:"engineId"`
}

SNMPAgentDTO represents an SNMP agent

func (*SNMPAgentDTO) GetSNMPClient

func (agent *SNMPAgentDTO) GetSNMPClient() SNMPHandler

GetSNMPClient gets an SNMP Client instance

type SNMPClient

type SNMPClient struct {
	// contains filtered or unexported fields
}

SNMPClient represents an SNMP handler implementation

func (*SNMPClient) BulkWalk

func (cli *SNMPClient) BulkWalk(rootOid string, walkFn gosnmp.WalkFunc) error

BulkWalk executes an SNMP bulk walk calling WalkFunc after receiving data

func (*SNMPClient) Connect

func (cli *SNMPClient) Connect() error

Connect initiates a connection against the target device

func (*SNMPClient) Disconnect

func (cli *SNMPClient) Disconnect() error

Disconnect terminates the connection against the target device

func (*SNMPClient) Get

func (cli *SNMPClient) Get(oid string) (result *gosnmp.SnmpPacket, err error)

Get execute an SNMP GET request

func (*SNMPClient) Target

func (cli *SNMPClient) Target() string

Target returns the target device IP/Hostname

func (*SNMPClient) Version

func (cli *SNMPClient) Version() string

Version returns the SNMP version

type SNMPGetRequestDTO

type SNMPGetRequestDTO struct {
	XMLName       xml.Name `xml:"get"`
	CorrelationID string   `xml:"correlation-id,attr"`
	OIDs          []string `xml:"oid,omitempty"`
}

SNMPGetRequestDTO represents an SNMP get request

type SNMPHandler

type SNMPHandler interface {
	Connect() error
	Disconnect() error
	Version() string
	Target() string
	BulkWalk(rootOid string, walkFn gosnmp.WalkFunc) error
	Get(oid string) (result *gosnmp.SnmpPacket, err error)
}

SNMPHandler represents an SNMP handler based on GoSNMP

type SNMPMultiResponseDTO

type SNMPMultiResponseDTO struct {
	XMLName   xml.Name          `xml:"snmp-response"`
	Error     string            `xml:"error,attr,omitempty"`
	Responses []SNMPResponseDTO `xml:"response"`
}

SNMPMultiResponseDTO represents an SNMP multi-value response

func (*SNMPMultiResponseDTO) AddResponse

func (dto *SNMPMultiResponseDTO) AddResponse(response *SNMPResponseDTO)

AddResponse adds a response to the multi-response list

type SNMPRequestDTO

type SNMPRequestDTO struct {
	XMLName     xml.Name             `xml:"snmp-request"`
	Location    string               `xml:"location,attr"`
	SystemID    string               `xml:"system-id,attr"`
	Description string               `xml:"description,attr"`
	Agent       SNMPAgentDTO         `xml:"agent"`
	Gets        []SNMPGetRequestDTO  `xml:"get,omitempty"`
	Walks       []SNMPWalkRequestDTO `xml:"walk,omitempty"`
}

SNMPRequestDTO represents an SNMP request

type SNMPResponseDTO

type SNMPResponseDTO struct {
	XMLName       xml.Name        `xml:"response"`
	CorrelationID string          `xml:"correlation-id,attr"`
	Results       []SNMPResultDTO `xml:"result"`
}

SNMPResponseDTO represents an SNMP response

type SNMPResultDTO

type SNMPResultDTO struct {
	XMLName  xml.Name     `xml:"result"`
	Base     string       `xml:"base"`
	Instance string       `xml:"instance,omitempty"`
	Value    SNMPValueDTO `xml:"value"`
}

SNMPResultDTO represents an SNMP result

type SNMPResults

type SNMPResults struct {
	Results []SNMPResultDTO `xml:"result"`
}

SNMPResults represents a collection of SNMP result instances

type SNMPValueDTO

type SNMPValueDTO struct {
	XMLName xml.Name `xml:"value"`
	Type    int      `xml:"type,attr"`
	Value   string   `xml:",chardata"`
}

SNMPValueDTO represents an SNMP value

type SNMPWalkRequestDTO

type SNMPWalkRequestDTO struct {
	XMLName        xml.Name `xml:"walk"`
	CorrelationID  string   `xml:"correlation-id,attr"`
	MaxRepetitions int      `xml:"max-repetitions,attr,omitempty"`
	Instance       string   `xml:"instance,attr,omitempty"`
	OIDs           []string `xml:"oid,omitempty"`
}

SNMPWalkRequestDTO represents an SNMP walk request

type ServiceCollector

type ServiceCollector interface {

	// Returns the ID of the Service Collector implementation
	GetID() string

	// Executes the data collection operation from the request
	// The response tells if the operation was successful or not
	Collect(request *CollectorRequestDTO) *CollectorResponseDTO
}

ServiceCollector represents an implementation of a service collector

type ServiceDetector

type ServiceDetector interface {

	// Returns the ID of the Service Detector implementation
	GetID() string

	// Executes the detection operation from the request
	// The response tells if the operation was successful or not
	Detect(request *DetectorRequestDTO) *DetectorResponseDTO
}

ServiceDetector represents an implementation of a service detector

type ServiceMonitor

type ServiceMonitor interface {

	// Returns the ID of the Service Monitor implementation
	GetID() string

	// Executes the polling operation from the request
	// The response tells if the operation was successful or not
	Poll(request *PollerRequestDTO) *PollerResponseDTO
}

ServiceMonitor represents an implementation of a service monitor

type Sink

type Sink interface {

	// Sends a Sink Message to OpenNMS
	Send(msg *ipc.SinkMessage) error
}

Sink represents the broker functionality for sending messages via the Sink API

type SinkModule

type SinkModule interface {

	// Returns the ID of the Sink Module implementation
	GetID() string

	// Starts the Sink Module (non-blocking method)
	Start(config *MinionConfig, sink Sink) error

	// Shuts down the Sink Module (including all listeners)
	Stop()
}

SinkModule represents an implementation of an OpenNMS Sink Module

type SinkRegistry added in v0.1.2

type SinkRegistry struct {
	// contains filtered or unexported fields
}

SinkRegistry tracks all the enabled Sink module instances for a given broker.

func (*SinkRegistry) GetAllModules added in v0.1.2

func (r *SinkRegistry) GetAllModules() []SinkModule

GetAllModules gets all the registered Sink modules

func (*SinkRegistry) Init added in v0.1.2

func (r *SinkRegistry) Init()

Init initializes a new Sink registry

func (*SinkRegistry) RegisterModule added in v0.1.2

func (r *SinkRegistry) RegisterModule(module SinkModule)

RegisterModule registers a new RPC Module implementation

func (*SinkRegistry) StartModules added in v0.1.2

func (r *SinkRegistry) StartModules(config *MinionConfig, sink Sink) error

StartModules starts all the registered Sink modules (non-blocking method)

func (*SinkRegistry) StopModules added in v0.1.2

func (r *SinkRegistry) StopModules()

StopModules stops all the registered Sink modules

func (*SinkRegistry) UnregisterModule added in v0.1.2

func (r *SinkRegistry) UnregisterModule(module SinkModule)

UnregisterModule unregisters an existing RPC Module implementation

type SyslogMessageDTO

type SyslogMessageDTO struct {
	Timestamp string `xml:"timestamp,attr"`
	Content   []byte `xml:",chardata"`
}

SyslogMessageDTO represents a Syslog message

type SyslogMessageLogDTO

type SyslogMessageLogDTO struct {
	XMLName       xml.Name           `xml:"syslog-message-log"`
	SystemID      string             `xml:"system-id,attr"`
	Location      string             `xml:"location,attr"`
	SourceAddress string             `xml:"source-address,attr"`
	SourcePort    int                `xml:"source-port,attr"`
	Messages      []SyslogMessageDTO `xml:"messages"`
}

SyslogMessageLogDTO represents a collection of Syslog messages

func (*SyslogMessageLogDTO) AddMessage

func (msgLog *SyslogMessageLogDTO) AddMessage(message SyslogMessageDTO)

AddMessage adds a new message to the log

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp an object to seamlessly manage times in multiple formats Expected text format: 2006-01-02T15:04:05.000-07:00

func (Timestamp) MarshalXML

func (t Timestamp) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML converts time object into time as string

func (*Timestamp) UnmarshalXML

func (t *Timestamp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML converts time string into time object

type TrapDTO

type TrapDTO struct {
	AgentAddress string           `xml:"agent-address"`
	Community    string           `xml:"community"`
	Version      string           `xml:"version"`
	Timestamp    int64            `xml:"timestamp"`
	CreationTime int64            `xml:"creation-time"`
	PDULength    int              `xml:"pdu-length"`
	RawMessage   []byte           `xml:"raw-message,omitempty"`
	TrapIdentity *TrapIdentityDTO `xml:"trap-identity"`
	Results      *SNMPResults     `xml:"results"`
}

TrapDTO represents an SNMP Trap

func (*TrapDTO) AddResult

func (trap *TrapDTO) AddResult(result SNMPResultDTO)

AddResult adds an SNMP results to the trap object

type TrapIdentityDTO

type TrapIdentityDTO struct {
	EnterpriseID string `xml:"enterprise-id,attr"`
	Generic      int    `xml:"generic,attr"`
	Specific     int    `xml:"specific,attr"`
}

TrapIdentityDTO represents the SNMP Trap Identity

type TrapLogDTO

type TrapLogDTO struct {
	XMLName     xml.Name  `xml:"trap-message-log"`
	Location    string    `xml:"location,attr"`
	SystemID    string    `xml:"system-id,attr"`
	TrapAddress string    `xml:"trap-address,attr"`
	Messages    []TrapDTO `xml:"messages"`
}

TrapLogDTO represents a collection of SNMP Trap messages

func (*TrapLogDTO) AddTrap

func (trapLog *TrapLogDTO) AddTrap(trap TrapDTO)

AddTrap adds a new trap to the log

type XMLCollection

type XMLCollection struct {
	XMLName xml.Name    `xml:"xml-collection"`
	Name    string      `xml:"name,attr"`
	RRD     *RRD        `xml:"rrd"`
	Sources []XMLSource `xml:"xml-source"`
}

XMLCollection represents an XML collection object

type XMLGroup

type XMLGroup struct {
	XMLName         xml.Name        `xml:"xml-group"`
	Name            string          `xml:"name,attr"`
	ResourceType    string          `xml:"resource-type,attr"`
	ResourceXPath   string          `xml:"resource-xpath,attr"`
	KeyXPath        string          `xml:"key-xpath,attr"`
	TimestampFormat string          `xml:"timestamp-format,attr"`
	TimestampXPath  string          `xml:"timestamp-xpath,attr"`
	Objects         []XMLObject     `xml:"xml-object,omitempty"`
	ResourceKey     *XMLResourceKey `xml:"resource-key,omitempty"`
}

XMLGroup represents an XML group

func (*XMLGroup) HasMultipleResourceKeys

func (group *XMLGroup) HasMultipleResourceKeys() bool

HasMultipleResourceKeys checks if the group has multiple resource keys

type XMLObject

type XMLObject struct {
	XMLName xml.Name `xml:"xml-object"`
	Name    string   `xml:"name,attr"`
	Type    string   `xml:"type,attr"`
	XPath   string   `xml:"xpath,attr"`
}

XMLObject represents an XML object

type XMLRequest

type XMLRequest struct {
	XMLName    xml.Name              `xml:"request"`
	Method     string                `xml:"method,attr"`
	Headers    []XMLRequestHeader    `xml:"header,omitempty"`
	Parameters []XMLRequestParameter `xml:"parameter,omitempty"`
	Content    *XMLRequestContent    `xml:"content,omitempty"`
}

XMLRequest represents an XML request

func (*XMLRequest) GetBody

func (r *XMLRequest) GetBody() io.Reader

GetBody returns a reader with the request body if exist

func (*XMLRequest) GetMethod

func (r *XMLRequest) GetMethod() string

GetMethod returns the HTTP method of the XML Request

func (*XMLRequest) GetParameterAsInt

func (r *XMLRequest) GetParameterAsInt(key string) int

GetParameterAsInt gets the value of a request parameter as an integer

func (*XMLRequest) GetParameterAsString

func (r *XMLRequest) GetParameterAsString(key string) string

GetParameterAsString gets the value of a request parameter as a string

type XMLRequestContent

type XMLRequestContent struct {
	XMLName xml.Name `xml:"content"`
	Type    string   `xml:"content-type,attr"`
	Value   string   `xml:",innerxml"`
}

XMLRequestContent represents an XML request content

type XMLRequestHeader

type XMLRequestHeader struct {
	XMLName xml.Name `xml:"header"`
	Name    string   `xml:"name,attr"`
	Value   string   `xml:"value,attr"`
}

XMLRequestHeader represents an XML request header

type XMLRequestParameter

type XMLRequestParameter struct {
	XMLName xml.Name `xml:"parameter"`
	Name    string   `xml:"name,attr"`
	Value   string   `xml:"value,attr"`
}

XMLRequestParameter represents an XML request parameter

type XMLResourceKey

type XMLResourceKey struct {
	XMLName   xml.Name `xml:"resource-key"`
	KeyXPaths []string `xml:"key-xpath"`
}

XMLResourceKey represents a resource key list inside a group

type XMLSource

type XMLSource struct {
	XMLName xml.Name    `xml:"xml-source"`
	URL     string      `xml:"url,attr"`
	Groups  []XMLGroup  `xml:"xml-group"`
	Request *XMLRequest `xml:"request,omitempty"`
}

XMLSource represents an XML source

func (*XMLSource) GetHTTPRequest

func (src *XMLSource) GetHTTPRequest() (*http.Request, error)

GetHTTPRequest gets an HTTP request

func (*XMLSource) GetRequest

func (src *XMLSource) GetRequest() *XMLRequest

GetRequest gets the HTTP request

func (*XMLSource) SkipSSL

func (src *XMLSource) SkipSSL() bool

SkipSSL checks whether or not to skip certificate validation for HTTPS

Jump to

Keyboard shortcuts

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