Documentation
¶
Index ¶
- Constants
- Variables
- func InitMIBTranslator(mibPath string) ([]string, error)
- func ParserWorker(i int, wg *sync.WaitGroup, parseChan <-chan []byte, messageChan chan<- Message)
- type AuthConfig
- type AuthType
- type Community
- type Config
- type Header
- type Message
- type MessageCompiled
- type MessageCompiler
- type PrivacyProtocol
- type TimeLayout
- type User
- type Value
- type ValueCompiled
- type ValueDetail
- type ValueType
Constants ¶
View Source
const (
PidFilePath = "/var/run/snmptrapd/snmptrapd.pid"
)
Variables ¶
View Source
var Functions = []expr.Option{ expr.Function( "MergeMap", func(params ...any) (any, error) { switch vList := params[0].(type) { case []map[string]any: res := make(map[string]any) for _, m := range vList { for k, v := range m { res[k] = v } } return res, nil case []any: res := make(map[string]any) for _, m := range vList { if mCast, ok := m.(map[string]any); !ok { return nil, errors.Errorf("incorrect type passed %s", reflect.TypeOf(m)) } else { for k, v := range mCast { res[k] = v } } } return res, nil default: return nil, errors.Errorf("incorrect type passed %s", reflect.TypeOf(params[0])) } }, new(func([]map[string]any) map[string]any), ), }
Functions ¶
func InitMIBTranslator ¶
Types ¶
type AuthConfig ¶
type Config ¶
type Config struct { Auth AuthConfig Listening []string AdditionalConfig string `mapstructure:"additional_config"` MagicBegin string `mapstructure:"magic_begin"` MagicEnd string `mapstructure:"magic_end"` }
type Message ¶
type Message struct { Time TimeLayout `json:"time"` UptimeSeconds null.Float `json:"uptime_seconds"` SrcAddress string `json:"src_address"` SrcPort int `json:"src_port"` DstAddress string `json:"dst_address"` DstPort int `json:"dst_port"` AgentAddress null.String `json:"agent_address"` PDUVersion string `json:"pdu_version"` SNMPVersion string `json:"snmp_version"` Community null.String `json:"community"` EnterpriseOID null.String `json:"enterprise_oid"` EnterpriseMIBName null.String `json:"enterprise_mib_name"` User null.String `json:"user"` Context null.String `json:"context"` Description null.String `json:"description"` TrapType null.Int `json:"trap_type"` TrapSubType null.Int `json:"trap_sub_type"` Values []Value `json:"values"` Retries int `json:"-"` Eta time.Time `json:"-"` Skip bool `json:"-"` MessageCompiled MessageCompiled `json:"-"` MessageJSON []byte `json:"-"` // contains filtered or unexported fields }
func (*Message) Compile ¶ added in v0.2.0
func (m *Message) Compile(conf MessageCompiler)
func (*Message) ComputeEta ¶ added in v0.2.0
func (*Message) UnmarshalText ¶
type MessageCompiled ¶ added in v0.2.0
type MessageCompiled struct { Time any `expr:"time"` UptimeSeconds *float64 `expr:"uptime_seconds"` SrcAddress string `expr:"src_address"` SrcPort int `expr:"src_port"` DstAddress string `expr:"dst_address"` DstPort int `expr:"dst_port"` AgentAddress *string `expr:"agent_address"` PDUVersion string `expr:"pdu_version"` SNMPVersion string `expr:"snmp_version"` Community *string `expr:"community"` EnterpriseOID *string `expr:"enterprise_oid"` EnterpriseMIBName *string `expr:"enterprise_mib_name"` User *string `expr:"user"` Context *string `expr:"context"` Description *string `expr:"description"` TrapType *int64 `expr:"trap_type"` TrapSubType *int64 `expr:"trap_sub_type"` Values []ValueCompiled `expr:"values"` }
type MessageCompiler ¶ added in v0.2.0
type PrivacyProtocol ¶
type PrivacyProtocol int8
const ( PrivAES PrivacyProtocol = iota PrivDES )
func (*PrivacyProtocol) String ¶
func (p *PrivacyProtocol) String() string
func (*PrivacyProtocol) UnmarshalText ¶
func (p *PrivacyProtocol) UnmarshalText(text []byte) error
type TimeLayout ¶ added in v0.2.0
func (*TimeLayout) MarshalJSON ¶ added in v0.2.0
func (t *TimeLayout) MarshalJSON() ([]byte, error)
func (*TimeLayout) MarshalNative ¶ added in v0.2.0
func (t *TimeLayout) MarshalNative() any
func (*TimeLayout) SetLayout ¶ added in v0.2.0
func (t *TimeLayout) SetLayout(layout string)
func (*TimeLayout) SetTimezone ¶ added in v0.2.0
func (t *TimeLayout) SetTimezone(tz string)
func (*TimeLayout) String ¶ added in v0.2.0
func (t *TimeLayout) String() string
type User ¶
type User struct { Username string NoAuth bool `mapstructure:"no_auth"` RequirePrivacy bool `mapstructure:"require_privacy"` EngineID string `mapstructure:"engine_id"` AuthType AuthType `mapstructure:"auth_type"` AuthPassphrase string `mapstructure:"auth_passphrase"` PrivacyProtocol PrivacyProtocol `mapstructure:"privacy_protocol"` PrivacyPassphrase string `mapstructure:"privacy_passphrase"` }
func (User) SecurityLevel ¶
type Value ¶
type Value struct { OID string `json:"oid"` MIBName null.String `json:"mib_name"` Type ValueType `json:"type"` NativeType string `json:"native_type"` Value any `json:"value"` ValueDetail ValueDetail `json:"value_detail"` }
func (Value) Compile ¶ added in v0.2.0
func (v Value) Compile(conf MessageCompiler) ValueCompiled
func (Value) HasOIDPrefix ¶
type ValueCompiled ¶ added in v0.2.0
type ValueDetail ¶
Click to show internal directories.
Click to hide internal directories.