Documentation
¶
Index ¶
- func CreatePrefix(prefix, target string) (*gnmi.Path, error)
- func ParsePath(p string) (*gnmi.Path, error)
- type Collector
- func (c *Collector) FormatMsg(meta map[string]interface{}, rsp *gnmi.SubscribeResponse) ([]byte, error)
- func (c *Collector) InitTarget(tc *TargetConfig)
- func (c *Collector) PolledSubscriptionsTargets() map[string][]string
- func (c *Collector) Start()
- func (c *Collector) Subscribe(tName string) error
- func (c *Collector) TargetPoll(targetName, subscriptionName string) (*gnmi.SubscribeResponse, error)
- type Config
- type SubscribeResponse
- type SubscriptionConfig
- type Target
- func (t *Target) Capabilities(ctx context.Context, ext ...*gnmi_ext.Extension) (*gnmi.CapabilityResponse, error)
- func (t *Target) CreateGNMIClient(ctx context.Context, opts ...grpc.DialOption) error
- func (t *Target) Export(msg []byte, m outputs.Meta)
- func (t *Target) Get(ctx context.Context, req *gnmi.GetRequest) (*gnmi.GetResponse, error)
- func (t *Target) Set(ctx context.Context, req *gnmi.SetRequest) (*gnmi.SetResponse, error)
- func (t *Target) Subscribe(ctx context.Context, req *gnmi.SubscribeRequest, subscriptionName string)
- type TargetConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collector ¶
type Collector struct { Config *Config Subscriptions map[string]*SubscriptionConfig Outputs map[string][]outputs.Output DialOpts []grpc.DialOption Targets map[string]*Target Logger *log.Logger // contains filtered or unexported fields }
Collector //
func NewCollector ¶
func NewCollector(ctx context.Context, config *Config, targetConfigs map[string]*TargetConfig, subscriptions map[string]*SubscriptionConfig, outputs map[string][]outputs.Output, dialOpts []grpc.DialOption, logger *log.Logger, ) *Collector
NewCollector //
func (*Collector) FormatMsg ¶
func (c *Collector) FormatMsg(meta map[string]interface{}, rsp *gnmi.SubscribeResponse) ([]byte, error)
FormatMsg formats the gnmi.SubscribeResponse and returns a []byte and an error
func (*Collector) InitTarget ¶
func (c *Collector) InitTarget(tc *TargetConfig)
InitTarget initializes a target based on *TargetConfig
func (*Collector) PolledSubscriptionsTargets ¶
PolledSubscriptionsTargets returns a map of target name to a list of subscription names that have Mode == POLL
func (*Collector) Start ¶
func (c *Collector) Start()
Start start the prometheus server as well as a goroutine per target selecting on the response chan, the error chan and the ctx.Done() chan
func (*Collector) TargetPoll ¶
func (c *Collector) TargetPoll(targetName, subscriptionName string) (*gnmi.SubscribeResponse, error)
TargetPoll sends a gnmi.SubscribeRequest_Poll to targetName and returns the response and an error, it uses the targetName and the subscriptionName strings to find the gnmi.GNMI_SubscribeClient
type SubscribeResponse ¶
type SubscribeResponse struct { SubscriptionName string Response *gnmi.SubscribeResponse }
SubscribeResponse //
type SubscriptionConfig ¶
type SubscriptionConfig struct { Name string `mapstructure:"name,omitempty"` Models []string `mapstructure:"models,omitempty"` Prefix string `mapstructure:"prefix,omitempty"` Target string `mapstructure:"target,omitempty"` Paths []string `mapstructure:"paths,omitempty"` Mode string `mapstructure:"mode,omitempty"` StreamMode string `mapstructure:"stream-mode,omitempty"` Encoding string `mapstructure:"encoding,omitempty"` Qos *uint32 `mapstructure:"qos,omitempty"` SampleInterval *time.Duration `mapstructure:"sample-interval,omitempty"` HeartbeatInterval *time.Duration `mapstructure:"heartbeat-interval,omitempty"` SuppressRedundant bool `mapstructure:"suppress-redundant,omitempty"` UpdatesOnly bool `mapstructure:"updates-only,omitempty"` }
SubscriptionConfig //
func (*SubscriptionConfig) CreateSubscribeRequest ¶
func (sc *SubscriptionConfig) CreateSubscribeRequest() (*gnmi.SubscribeRequest, error)
CreateSubscribeRequest validates the SubscriptionConfig and creates gnmi.SubscribeRequest
type Target ¶
type Target struct { Config *TargetConfig Subscriptions []*SubscriptionConfig Outputs []outputs.Output Client gnmi.GNMIClient SubscribeClients map[string]gnmi.GNMI_SubscribeClient // subscription name to subscribeClient PollChan chan string // subscription name to be polled SubscribeResponses chan *SubscribeResponse Errors chan error // contains filtered or unexported fields }
Target represents a gNMI enabled box
func (*Target) Capabilities ¶
func (t *Target) Capabilities(ctx context.Context, ext ...*gnmi_ext.Extension) (*gnmi.CapabilityResponse, error)
Capabilities sends a gnmi.CapabilitiesRequest to the target *t and returns a gnmi.CapabilitiesResponse and an error
func (*Target) CreateGNMIClient ¶
CreateGNMIClient //
func (*Target) Get ¶
func (t *Target) Get(ctx context.Context, req *gnmi.GetRequest) (*gnmi.GetResponse, error)
Get sends a gnmi.GetRequest to the target *t and returns a gnmi.GetResponse and an error
func (*Target) Set ¶
func (t *Target) Set(ctx context.Context, req *gnmi.SetRequest) (*gnmi.SetResponse, error)
Set sends a gnmi.SetRequest to the target *t and returns a gnmi.SetResponse and an error
type TargetConfig ¶
type TargetConfig struct { Name string `mapstructure:"name,omitempty"` Address string `mapstructure:"address,omitempty"` Username *string `mapstructure:"username,omitempty"` Password *string `mapstructure:"password,omitempty"` Timeout time.Duration `mapstructure:"timeout,omitempty"` Insecure *bool `mapstructure:"insecure,omitempty"` TLSCA *string `mapstructure:"tls-ca,omitempty"` TLSCert *string `mapstructure:"tls-cert,omitempty"` TLSKey *string `mapstructure:"tls-key,omitempty"` SkipVerify *bool `mapstructure:"skip-verify,omitempty"` Subscriptions []string `mapstructure:"subscriptions,omitempty"` Outputs []string `mapstructure:"outputs,omitempty"` BufferSize uint `mapstructure:"buffer-size,omitempty"` }
TargetConfig //
func (*TargetConfig) String ¶
func (tc *TargetConfig) String() string