vsphere

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client  *govmomi.Client
	Views   *view.Manager
	Root    *view.ContainerView
	Perf    *performance.Manager
	Valid   bool
	Timeout time.Duration
	// contains filtered or unexported fields
}

Client represents a connection to vSphere and is backed by a govmomi connection

func NewClient

func NewClient(ctx context.Context, vSphereURL *url.URL, vs *Instance) (*Client, error)

NewClient creates a new vSphere client based on the url and setting passed as parameters.

func (*Client) CounterInfoByKey

func (c *Client) CounterInfoByKey(ctx context.Context) (map[int32]*types.PerfCounterInfo, error)

CounterInfoByKey wraps performance.CounterInfoByKey to give it proper timeouts

func (*Client) CounterInfoByName

func (c *Client) CounterInfoByName(ctx context.Context) (map[string]*types.PerfCounterInfo, error)

CounterInfoByName wraps performance.CounterInfoByName to give it proper timeouts

func (*Client) GetCustomFields

func (c *Client) GetCustomFields(ctx context.Context) (map[int32]string, error)

func (*Client) GetMaxQueryMetrics

func (c *Client) GetMaxQueryMetrics(ctx context.Context) (int, error)

GetMaxQueryMetrics returns the max_query_metrics setting as configured in vCenter

func (*Client) GetServerTime

func (c *Client) GetServerTime(ctx context.Context) (time.Time, error)

GetServerTime returns the time at the vCenter server

func (*Client) ListResources

func (c *Client) ListResources(ctx context.Context, root *view.ContainerView, kind []string, ps []string, dst interface{}) error

ListResources wraps property.Collector.Retrieve to give it proper timeouts

func (*Client) QueryMetrics

func (c *Client) QueryMetrics(ctx context.Context, pqs []types.PerfQuerySpec) ([]performance.EntityMetric, error)

QueryMetrics wraps performance.Query to give it proper timeouts

type ClientFactory

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

ClientFactory is used to obtain Clients to be used throughout the plugin. Typically, a single Client is reused across all functions and goroutines, but the client is periodically recycled to avoid authentication expiration issues.

func NewClientFactory

func NewClientFactory(vSphereURL *url.URL, parent *Instance) *ClientFactory

NewClientFactory creates a new ClientFactory and prepares it for use.

func (*ClientFactory) Close

func (cf *ClientFactory) Close()

Close shuts down a ClientFactory and releases any resources associated with it.

func (*ClientFactory) GetClient

func (cf *ClientFactory) GetClient(ctx context.Context) (*Client, error)

GetClient returns a client. The caller is responsible for calling Release() on the client once it's done using it.

type Endpoint

type Endpoint struct {
	Parent *Instance
	URL    *url.URL
	// contains filtered or unexported fields
}

Endpoint is a high-level representation of a connected vCenter endpoint. It is backed by the lower level Client type.

func NewEndpoint

func NewEndpoint(ctx context.Context, parent *Instance, address *url.URL) (*Endpoint, error)

NewEndpoint returns a new connection to a vCenter based on the URL and configuration passed as parameters.

func (*Endpoint) Close

func (e *Endpoint) Close()

Close shuts down an Endpoint and releases any resources associated with it.

func (*Endpoint) Collect

func (e *Endpoint) Collect(ctx context.Context, slist *types.SampleList) error

Collect runs a round of data collections as specified in the configuration.

type Finder

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

Finder allows callers to find resources in vCenter given a query string.

func (*Finder) Find

func (f *Finder) Find(ctx context.Context, resType, path string, dst interface{}) error

Find returns the resources matching the specified path.

func (*Finder) FindAll

func (f *Finder) FindAll(ctx context.Context, resType string, paths, excludePaths []string, dst interface{}) error

FindAll returns the union of resources found given the supplied resource type and paths.

type Instance

type Instance struct {
	config.InstanceConfig

	Vcenter  string `toml:"vcenter"`
	Username string `toml:"username"`
	Password string `toml:"password"`

	DatacenterInstances       bool     `toml:"datacenter_instances"`
	DatacenterMetricInclude   []string `toml:"datacenter_metric_include"`
	DatacenterMetricExclude   []string `toml:"datacenter_metric_exclude"`
	DatacenterInclude         []string `toml:"datacenter_include"`
	DatacenterExclude         []string `toml:"datacenter_exclude"`
	ClusterInstances          bool     `toml:"cluster_instances"`
	ClusterMetricInclude      []string `toml:"cluster_metric_include"`
	ClusterMetricExclude      []string `toml:"cluster_metric_exclude"`
	ClusterInclude            []string `toml:"cluster_include"`
	ClusterExclude            []string `toml:"cluster_exclude"`
	ResourcePoolInstances     bool     `toml:"resoucepool_instances"`
	ResourcePoolMetricInclude []string `toml:"resoucepool_metric_include"`
	ResourcePoolMetricExclude []string `toml:"resoucepool_metric_exclude"`
	ResourcePoolInclude       []string `toml:"resoucepool_include"`
	ResourcePoolExclude       []string `toml:"resoucepool_exclude"`
	HostInstances             bool     `toml:"host_instances"`
	HostMetricInclude         []string `toml:"host_metric_include"`
	HostMetricExclude         []string `toml:"host_metric_exclude"`
	HostInclude               []string `toml:"host_include"`
	HostExclude               []string `toml:"host_exclude"`
	VMInstances               bool     `toml:"vm_instances"`
	VMMetricInclude           []string `toml:"vm_metric_include"`
	VMMetricExclude           []string `toml:"vm_metric_exclude"`
	VMInclude                 []string `toml:"vm_include"`
	VMExclude                 []string `toml:"vm_exclude"`
	DatastoreInstances        bool     `toml:"datastore_instances"`
	DatastoreMetricInclude    []string `toml:"datastore_metric_include"`
	DatastoreMetricExclude    []string `toml:"datastore_metric_exclude"`
	DatastoreInclude          []string `toml:"datastore_include"`
	DatastoreExclude          []string `toml:"datastore_exclude"`

	Separator               string          `toml:"separator"`
	CustomAttributeInclude  []string        `toml:"custom_attribute_include"`
	CustomAttributeExclude  []string        `toml:"custom_attribute_exclude"`
	UseIntSamples           bool            `toml:"use_int_samples"`
	IPAddresses             []string        `toml:"ip_addresses"`
	MetricLookback          int             `toml:"metric_lookback"`
	MaxQueryObjects         int             `toml:"max_query_objects"`
	MaxQueryMetrics         int             `toml:"max_query_metrics"`
	CollectConcurrency      int             `toml:"collect_concurrency"`
	DiscoverConcurrency     int             `toml:"discover_concurrency"`
	ObjectDiscoveryInterval config.Duration `toml:"object_discovery_interval"`
	HistoricalInterval      config.Duration `toml:"historical_interval"`
	Timeout                 config.Duration `toml:"timeout"`
	tls.ClientConfig                        // Mix in the TLS/SSL goodness from core
	// contains filtered or unexported fields
}

func (*Instance) Drop

func (v *Instance) Drop()

func (*Instance) Gather

func (ins *Instance) Gather(slist *types.SampleList)

Gather is the main data collection function called by the Telegraf core. It performs all the data collection and writes all metrics into the Accumulator passed as an argument.

func (*Instance) Init

func (ins *Instance) Init() error

type ResourceFilter

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

ResourceFilter is a convenience class holding a finder and a set of paths. It is useful when you need a self contained object capable of returning a certain set of resources.

func (*ResourceFilter) FindAll

func (r *ResourceFilter) FindAll(ctx context.Context, dst interface{}) error

FindAll finds all resources matching the paths that were specified upon creation of the ResourceFilter.

type TSCache

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

TSCache is a cache of timestamps used to determine the validity of datapoints

func NewTSCache

func NewTSCache(ttl time.Duration) *TSCache

NewTSCache creates a new TSCache with a specified time-to-live after which timestamps are discarded.

func (*TSCache) Get

func (t *TSCache) Get(key string, metricName string) (time.Time, bool)

Get returns a timestamp (if present)

func (*TSCache) IsNew

func (t *TSCache) IsNew(key string, metricName string, tm time.Time) bool

IsNew returns true if the supplied timestamp for the supplied key is more recent than the timestamp we have on record.

func (*TSCache) Purge

func (t *TSCache) Purge()

Purge removes timestamps that are older than the time-to-live

func (*TSCache) Put

func (t *TSCache) Put(key string, metricName string, timestamp time.Time)

Put updates the latest timestamp for the supplied key.

type ThrottledExecutor

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

ThrottledExecutor provides a simple mechanism for running jobs in separate goroutines while limit the number of concurrent jobs running at any given time.

func NewThrottledExecutor

func NewThrottledExecutor(limit int) (*ThrottledExecutor, error)

NewThrottledExecutor creates a new ThrottlesExecutor with a specified maximum number of concurrent jobs

func (*ThrottledExecutor) Run

func (t *ThrottledExecutor) Run(ctx context.Context, job func())

Run schedules a job for execution as soon as possible while respecting the maximum concurrency limit.

func (*ThrottledExecutor) Wait

func (t *ThrottledExecutor) Wait()

Wait blocks until all scheduled jobs have finished

type VSphere

type VSphere struct {
	config.PluginConfig
	Instances []*Instance `toml:"instances"`
}

VSphere is the top level type for the vSphere input plugin. It contains all the configuration and a list of connected vSphere endpoints

func (*VSphere) Clone

func (vs *VSphere) Clone() inputs.Input

func (*VSphere) GetInstances

func (pt *VSphere) GetInstances() []inputs.Instance

func (*VSphere) Name

func (vs *VSphere) Name() string

Jump to

Keyboard shortcuts

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