Documentation ¶
Overview ¶
Package client implements a kafka consumer that works with single or multi-part messages for OpenNMS Sink and RPC API messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AvailableParsers = &EnumValue{ Enum: []string{"heartbeat", "snmp", "syslog", "netflow", "sflow"}, }
AvailableParsers list of available parsers for the Sink API.
Functions ¶
This section is empty.
Types ¶
type EnumValue ¶ added in v0.2.0
EnumValue a enumaration array of strings
func (EnumValue) EnumAsString ¶ added in v0.2.0
EnumAsString gets a CSV with all the values on the enum
type KafkaClient ¶
type KafkaClient struct { Bootstrap string // The Kafka Server Bootstrap string. Topic string // The name of the Kafka Topic. GroupID string // The name of the Consumer Group ID. IPC string // Either rpc or sink. Parser string // See AvailableParsers. // contains filtered or unexported fields }
KafkaClient defines a simple Kafka consumer client.
func (*KafkaClient) Initialize ¶
func (cli *KafkaClient) Initialize(ctx context.Context) error
Initialize Builds the Kafka consumer object and the cache for chunk handling.
func (*KafkaClient) Start ¶
func (cli *KafkaClient) Start(action ProcessMessage)
Start Registers the consumer for the chosen topic, and reads messages from it on an infinite loop. It is recommended to use it within a Go Routine as it is a blocking operation.
type ProcessMessage ¶ added in v0.2.0
type ProcessMessage func(msg []byte)
ProcessMessage defines the action to execute after successfully received an IPC message. It receives the payload as an array of bytes (usually in XML or JSON format).
type SNMPResultDTO ¶ added in v0.2.0
type SNMPResultDTO struct { XMLName xml.Name `xml:"result" json:"-"` Base string `xml:"base" json:"base"` Instance string `xml:"instance,omitempty" json:"instance,omitempty"` Value SNMPValueDTO `xml:"value" json:"value"` }
SNMPResultDTO represents an SNMP result
type SNMPResults ¶ added in v0.2.0
type SNMPResults struct {
Results []SNMPResultDTO `xml:"result" json:"varbinds"`
}
SNMPResults represents a collection of SNMP result instances
type SNMPValueDTO ¶ added in v0.2.0
type SNMPValueDTO struct { XMLName xml.Name `xml:"value" json:"-"` Type int `xml:"type,attr" json:"type"` Value string `xml:",chardata" json:"content"` }
SNMPValueDTO represents an SNMP value
func (SNMPValueDTO) MarshalJSON ¶ added in v0.2.0
func (dto SNMPValueDTO) MarshalJSON() ([]byte, error)
MarshalJSON converts SNMP Value to JSON
type SyslogMessageDTO ¶ added in v0.2.0
type SyslogMessageDTO struct { Timestamp string `xml:"timestamp,attr" json:"timestamp"` Content []byte `xml:",chardata" json:"content"` }
SyslogMessageDTO represents a Syslog message
func (*SyslogMessageDTO) MarshalJSON ¶ added in v0.2.0
func (dto *SyslogMessageDTO) MarshalJSON() ([]byte, error)
MarshalJSON converts Syslog message to JSON
type SyslogMessageLogDTO ¶ added in v0.2.0
type SyslogMessageLogDTO struct { XMLName xml.Name `xml:"syslog-message-log" json:"-"` SystemID string `xml:"system-id,attr" json:"systemId"` Location string `xml:"location,attr" json:"location"` SourceAddress string `xml:"source-address,attr" json:"sourceAddress"` SourcePort int `xml:"source-port,attr" json:"sourcePort"` Messages []SyslogMessageDTO `xml:"messages" json:"messages"` }
SyslogMessageLogDTO represents a collection of Syslog messages
func (SyslogMessageLogDTO) String ¶ added in v0.2.0
func (dto SyslogMessageLogDTO) String() string
type TrapDTO ¶ added in v0.2.0
type TrapDTO struct { AgentAddress string `xml:"agent-address" json:"agentAddress"` Community string `xml:"community" json:"community,omitempty"` Version string `xml:"version" json:"version"` Timestamp int64 `xml:"timestamp" json:"timestamp"` CreationTime int64 `xml:"creation-time" json:"creationTime"` PDULength int `xml:"pdu-length" json:"pduLength"` RawMessage []byte `xml:"raw-message,omitempty" json:"rawMessage,omitempty"` TrapIdentity *TrapIdentityDTO `xml:"trap-identity" json:"trapIdentity"` Results *SNMPResults `xml:"results" json:"results"` }
TrapDTO represents an SNMP Trap
type TrapIdentityDTO ¶ added in v0.2.0
type TrapIdentityDTO struct { EnterpriseID string `xml:"enterprise-id,attr" json:"enterpriseID"` Generic int `xml:"generic,attr" json:"generic"` Specific int `xml:"specific,attr" json:"specific"` }
TrapIdentityDTO represents the SNMP Trap Identity
type TrapLogDTO ¶ added in v0.2.0
type TrapLogDTO struct { XMLName xml.Name `xml:"trap-message-log" json:"-"` Location string `xml:"location,attr" json:"location"` SystemID string `xml:"system-id,attr" json:"systemId"` TrapAddress string `xml:"trap-address,attr" json:"trapAddress"` Messages []TrapDTO `xml:"messages" json:"messages"` }
TrapLogDTO represents a collection of SNMP Trap messages
func (TrapLogDTO) String ¶ added in v0.2.0
func (dto TrapLogDTO) String() string