Add struct tags for jti_openconfig_telemetry plugin
This commit is contained in:
parent
131f85db73
commit
1dc3028237
|
@ -42,6 +42,7 @@ This plugin reads Juniper Networks implementation of OpenConfig telemetry data f
|
|||
]
|
||||
|
||||
## Optional TLS Config
|
||||
# enable_tls = true
|
||||
# tls_ca = "/etc/telegraf/ca.pem"
|
||||
# tls_cert = "/etc/telegraf/cert.pem"
|
||||
# tls_key = "/etc/telegraf/key.pem"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package jti_openconfig_telemetry
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
|
@ -24,22 +23,19 @@ import (
|
|||
)
|
||||
|
||||
type OpenConfigTelemetry struct {
|
||||
Servers []string
|
||||
Sensors []string
|
||||
Username string
|
||||
Password string
|
||||
Servers []string `toml:"servers"`
|
||||
Sensors []string `toml:"sensors"`
|
||||
Username string `toml:"username"`
|
||||
Password string `toml:"password"`
|
||||
ClientID string `toml:"client_id"`
|
||||
SampleFrequency internal.Duration `toml:"sample_frequency"`
|
||||
StrAsTags bool `toml:"str_as_tags"`
|
||||
RetryDelay internal.Duration `toml:"retry_delay"`
|
||||
|
||||
sensorsConfig []sensorConfig
|
||||
|
||||
// GRPC settings
|
||||
grpcClientConns []*grpc.ClientConn
|
||||
EnableTLS bool `toml:"enable_tls"`
|
||||
internaltls.ClientConfig
|
||||
|
||||
sensorsConfig []sensorConfig
|
||||
grpcClientConns []*grpc.ClientConn
|
||||
wg *sync.WaitGroup
|
||||
}
|
||||
|
||||
|
@ -81,6 +77,7 @@ var (
|
|||
]
|
||||
|
||||
## Optional TLS Config
|
||||
# enable_tls = true
|
||||
# tls_ca = "/etc/telegraf/ca.pem"
|
||||
# tls_cert = "/etc/telegraf/cert.pem"
|
||||
# tls_key = "/etc/telegraf/key.pem"
|
||||
|
@ -353,23 +350,18 @@ func (m *OpenConfigTelemetry) collectData(ctx context.Context,
|
|||
|
||||
func (m *OpenConfigTelemetry) Start(acc telegraf.Accumulator) error {
|
||||
|
||||
var tlscfg *tls.Config
|
||||
var opts []grpc.DialOption
|
||||
var err error
|
||||
|
||||
// Build sensors config
|
||||
if m.splitSensorConfig() == 0 {
|
||||
return fmt.Errorf("E! No valid sensor configuration available")
|
||||
}
|
||||
|
||||
// Parse TLS config
|
||||
var opts []grpc.DialOption
|
||||
if m.EnableTLS {
|
||||
if tlscfg, err = m.ClientConfig.TLSConfig(); err != nil {
|
||||
tlscfg, err := m.ClientConfig.TLSConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if tlscfg != nil {
|
||||
opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(tlscfg)))
|
||||
} else {
|
||||
opts = append(opts, grpc.WithInsecure())
|
||||
|
|
Loading…
Reference in New Issue