vsphere

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package vsphere provides various wrapper functions and types for interacting with and monitoring VMware vSphere environments.

Index

Constants

View Source
const (
	MgObjRefTypeFolder          string = "Folder"
	MgObjRefTypeDatacenter      string = "Datacenter"
	MgObjRefTypeComputeResource string = "ComputeResource"
	MgObjRefTypeResourcePool    string = "ResourcePool"
	MgObjRefTypeHostSystem      string = "HostSystem"
	MgObjRefTypeVirtualMachine  string = "VirtualMachine"
)

Managed Object Reference types

View Source
const (

	// https://stackoverflow.com/questions/34124294/writing-powers-of-10-as-constants-compactly
	// untyped float
	Hz  = 1
	KHz = 1e3
	MHz = 1e6
	GHz = 1e9
	THz = 1e12
	PHz = 1e15
	EHz = 1e18
	ZHz = 1e21
	YHz = 1e24
)

CPU speed values

View Source
const CustomAttributeValNotSet string = "NotSet"

CustomAttributeValNotSet is used to indicate that a Custom Attribute value was not set on an object.

View Source
const ParentResourcePool string = "Resources"

ParentResourcePool represents the hidden resource pool named Resources which is present on virtual machine hosts. This resource pool is a parent of all resource pools of the host. Including this pool in "eligible" resource pool lists throws off calculations (e.g., causes a VM to show up twice).

Variables

View Source
var ErrAlarmNotExcludedFromEvaluation = errors.New("alarm detected and not excluded from evaluation")

ErrAlarmNotExcludedFromEvaluation indicates that one or more alarms were detected and not excluded from evaluation.

View Source
var ErrAvailableFieldValueNotDefined = errors.New("no custom attributes defined within vSphere environment for this type")

ErrAvailableFieldValueNotDefined is returned when no Custom Attributes are defined within an inventory for an associated managed object type.

View Source
var ErrAvailableFieldValueNotFound = errors.New("failed to find a matching available field name")

ErrAvailableFieldValueNotFound is returned when a specified Custom Attribute name cannot be located within an inventory. This might be the case if a specified Custom Attribute name has a typo.

View Source
var ErrConvertBaseCustomFieldValue = errors.New("failed to convert base custom field value to obtain key/value pair")

ErrConvertBaseCustomFieldValue is returned when a conversion error occurs or (type assertion failure) for a provided BaseCustomFieldValue.

TODO: Document how/when this might occur.

View Source
var ErrCustomAttributeKeyNotFound = errors.New("failed to find a matching custom attribute key/value pair for provided custom attribute key")

ErrCustomAttributeKeyNotFound is returned when a Custom Attribute key (and thus the desired value) cannot be found for a vSphere object. This can occur when a Custom Attribute exists within an inventory, but is not applied to a specific managed object.

View Source
var ErrCustomAttributeNotSet = errors.New("custom attributes not set")

ErrCustomAttributeNotSet is similar to ErrCustomAttributeKeyNotFound, but is returned when there are no Custom Attributes set for an associated managed object type.

View Source
var ErrDatacenterNotFound = errors.New("specified Datacenters not found")

ErrDatacenterNotFound indicates that one or more specified datacenters were not located.

View Source
var ErrDatastoreUsageThresholdCrossed = errors.New("datastore usage exceeds specified threshold")

ErrDatastoreUsageThresholdCrossed indicates that specified resource pools have exceeded a given threshold

View Source
var ErrHostDatastorePairingFailed = errors.New("failed to compile host/datastore pairings")

ErrHostDatastorePairingFailed is returned when compiling host and datastore pairings using provided the Custom Attribute fails. This is usually due to a lack of a match between Custom Attribute values used on hosts and datastores.

For example, this may occur if prefix matching is not enabled and the host Custom Attribute uses a Location attribute which contains a separator between a datacenter and the hosts rack position, whereas a datastore contains only the datacenter.

View Source
var ErrHostSystemCPUUsageThresholdCrossed = errors.New("host CPU usage exceeds specified threshold")

ErrHostSystemCPUUsageThresholdCrossed indicates that specified host CPU usage has exceeded a given threshold

View Source
var ErrHostSystemMemoryUsageThresholdCrossed = errors.New("host memory usage exceeds specified threshold")

ErrHostSystemMemoryUsageThresholdCrossed indicates that specified host memory usage has exceeded a given threshold

View Source
var ErrResourcePoolMemoryUsageThresholdCrossed = errors.New("memory usage exceeds specified threshold")

ErrResourcePoolMemoryUsageThresholdCrossed indicates that specified resource pools have exceeded a given threshold

View Source
var ErrSnapshotAgeThresholdCrossed = errors.New("snapshot exceeds specified age threshold")

ErrSnapshotAgeThresholdCrossed indicates that a snapshot is older than a specified age threshold

View Source
var ErrSnapshotCountThresholdCrossed = errors.New("snapshots exceed specified count threshold")

ErrSnapshotCountThresholdCrossed indicates that a snapshot set for a single VM has exceeded a specified count threshold.

View Source
var ErrSnapshotSizeThresholdCrossed = errors.New("snapshot exceeds specified size threshold")

ErrSnapshotSizeThresholdCrossed indicates that a snapshot is larger than a specified size threshold

View Source
var ErrVCPUsUsageThresholdCrossed = errors.New("vCPUS allocation exceeds specified threshold")

ErrVCPUsUsageThresholdCrossed indicates that specified vCPUs allocation has exceeded a given threshold

View Source
var ErrVMDatastoreNotInVMHostPairedList = errors.New("host/datastore/vm mismatch")

ErrVMDatastoreNotInVMHostPairedList is returned when one or more datastores for a VirtualMachine are not in the list of datastores paired with the VirtualMachine's current host.

View Source
var ErrVirtualHardwareOutdatedVersionsFound = errors.New("outdated hardware versions found")

ErrVirtualHardwareOutdatedVersionsFound indicates that hardware versions older than the minimum have been found.

View Source
var ErrVirtualMachineDiskConsolidationNeeded = errors.New("disk consolidation needed")

ErrVirtualMachineDiskConsolidationNeeded indicates that disk consolidation is needed for one or more Virtual Machines.

View Source
var ErrVirtualMachineInteractiveResponseNeeded = errors.New("interactive response needed")

ErrVirtualMachineInteractiveResponseNeeded indicates that an interactive response is needed for one or more Virtual Machines.

View Source
var ErrVirtualMachinePowerCycleUptimeThresholdCrossed = errors.New("power cycle uptime exceeds specified threshold")

ErrVirtualMachinePowerCycleUptimeThresholdCrossed indicates that specified Virtual Machine power cycle thresholds have been exceeded.

Functions

func AlarmsOneLineCheckSummary added in v0.16.0

func AlarmsOneLineCheckSummary(
	stateLabel string,
	triggeredAlarms TriggeredAlarms,
	datacentersEvaluated []string,
) string

AlarmsOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func AlarmsReport added in v0.16.0

func AlarmsReport(
	c *vim25.Client,
	triggeredAlarms TriggeredAlarms,
	triggeredAlarmFilters TriggeredAlarmFilters,
	specifiedDatacenters []string,
	datacentersEvaluated []string,
) string

AlarmsReport generates a summary of detected alarms along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func CustomAttrKeyToValue added in v0.2.0

func CustomAttrKeyToValue(caKey int32, customValue []types.BaseCustomFieldValue) (string, error)

CustomAttrKeyToValue receives the key of a Custom Attribute key/value pair a slice of BaseCustomFieldValue which represents the Custom Attribute values for vSphere objects (e.g., HostSystem, Datastore). An error is returned if conversion fails or if the specified Custom Attribute key is not found.

func CustomAttrNameToKey added in v0.2.0

func CustomAttrNameToKey(caName string, availableField []types.CustomFieldDef) (int32, error)

CustomAttrNameToKey receives a user-provided Custom Attribute name and a slice of values which contain key/value fields. If a match for the user-provided Custom Attribute name is found, the matching key is returned. This key can be used to search for a match in the Custom Values associated with vSphere objects (e.g., Hosts, Datastores). An error is returned if a match is not found.

func DatastoreIDsToNames added in v0.2.0

func DatastoreIDsToNames(dsRefs []types.ManagedObjectReference, dss []mo.Datastore) []string

DatastoreIDsToNames returns a list of matching Datastore names for the provided list of Managed Object References for Datastores.

func DatastoreUsageOneLineCheckSummary added in v0.3.0

func DatastoreUsageOneLineCheckSummary(
	stateLabel string,
	dsUsageSummary DatastoreUsageSummary,
) string

DatastoreUsageOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func DatastoreUsageReport added in v0.3.0

func DatastoreUsageReport(
	c *vim25.Client,
	dsVMs []mo.VirtualMachine,
	dsUsageSummary DatastoreUsageSummary,
) string

DatastoreUsageReport generates a summary of Datastore usage along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func DisableLogging added in v0.5.1

func DisableLogging()

DisableLogging reapplies default package-level logging settings of muting all logging output.

func EnableLogging added in v0.5.1

func EnableLogging()

EnableLogging enables logging output from this package. Output is muted by default unless explicitly requested (by calling this function).

func EntityStatusToNagiosState added in v0.16.0

func EntityStatusToNagiosState(entityStatus types.ManagedEntityStatus) (string, int)

EntityStatusToNagiosState converts a vSphere Managed Entity Status (e.g., "red", "yellow") to a Nagios state label and exit code.

func ExceedsAge added in v0.4.0

func ExceedsAge(snapshotCreated time.Time, days int) bool

ExceedsAge indicates whether a given snapshot creation date is older than the specified number of days.

func ExceedsSize added in v0.5.0

func ExceedsSize(snapshotSize int64, thresholdSize int64) bool

ExceedsSize indicates whether a given snapshot size is greater than the specified value in GB.

func ExcludeVMsByName

func ExcludeVMsByName(allVMs []mo.VirtualMachine, ignoreList []string) []mo.VirtualMachine

ExcludeVMsByName receives a collection of VirtualMachines and a list of VMs that should be ignored. A new collection minus ignored VirtualMachines is returned. If the collection of VirtualMachine is empty, an empty collection is returned. If the list of ignored VirtualMachines is empty, the same items from the received collection of VirtualMachines is returned. If the list of ignored VirtualMachines is greater than the list of received VirtualMachines, then only matching VirtualMachines will be excluded and any others silently skipped.

func FilterDatastoreByID

func FilterDatastoreByID(dss []mo.Datastore, dsID string) (mo.Datastore, error)

FilterDatastoreByID receives a collection of Datastores and a Datastore ID to filter against. An error is returned if the list of Datastores is empty or if a match was not found.

func FilterDatastoreByName

func FilterDatastoreByName(dss []mo.Datastore, dsName string) (mo.Datastore, error)

FilterDatastoreByName accepts a collection of Datastores and a Datastore name to filter against. An error is returned if the list of Datastores is empty or if a match was not found.

func FilterHostSystemByID added in v0.2.0

func FilterHostSystemByID(hss []mo.HostSystem, hsID string) (mo.HostSystem, error)

FilterHostSystemByID receives a collection of HostSystems and a HostSystem ID to filter against. An error is returned if the list of HostSystems is empty or if a match was not found.

func FilterHostSystemByName added in v0.2.0

func FilterHostSystemByName(hss []mo.HostSystem, hsName string) (mo.HostSystem, error)

FilterHostSystemByName accepts a collection of HostSystems and a HostSystem name to filter against. An error is returned if the list of HostSystems is empty or if a match was not found.

func FilterNetworkByID

func FilterNetworkByID(nets []mo.Network, netID string) (mo.Network, error)

FilterNetworkByID receives a collection of Networks and a Network ID to filter against. An error is returned if the list of Networks is empty or if a match was not found.

func FilterNetworkByName

func FilterNetworkByName(nets []mo.Network, netName string) (mo.Network, error)

FilterNetworkByName accepts a collection of Networks and a Network name to filter against. An error is returned if the list of Networks is empty or if a match was not found.

func FilterVMByID

func FilterVMByID(vms []mo.VirtualMachine, vmID string) (mo.VirtualMachine, error)

FilterVMByID receives a collection of VirtualMachines and a VirtualMachine ID to filter against. An error is returned if the list of VirtualMachines is empty or if a match was not found.

func FilterVMByName

func FilterVMByName(vms []mo.VirtualMachine, vmName string) (mo.VirtualMachine, error)

FilterVMByName accepts a collection of VirtualMachines and a VirtualMachine name to filter against. An error is returned if the list of VirtualMachines is empty or if a match was not found.

func FilterVMsByPowerCycleUptime added in v0.10.0

func FilterVMsByPowerCycleUptime(vms []mo.VirtualMachine, warningThreshold int, criticalThreshold int) []mo.VirtualMachine

FilterVMsByPowerCycleUptime filters the provided collection of VirtualMachines to just those with WARNING or CRITICAL values based on provided thresholds.

func FilterVMsByPowerState

func FilterVMsByPowerState(vms []mo.VirtualMachine, includePoweredOff bool) []mo.VirtualMachine

FilterVMsByPowerState accepts a collection of VirtualMachines and a boolean value to indicate whether powered off VMs should be included in the returned collection. If the collection of provided VirtualMachines is empty, an empty collection is returned.

func FilterVMsWithOldHardware

func FilterVMsWithOldHardware(vms []mo.VirtualMachine, hwIndex HardwareVersionsIndex) []mo.VirtualMachine

FilterVMsWithOldHardware filters the provided collection of VirtualMachines to just those with older hardware versions.

func FilterVMsWithSnapshots added in v0.4.0

func FilterVMsWithSnapshots(vms []mo.VirtualMachine) []mo.VirtualMachine

FilterVMsWithSnapshots filters the provided collection of VirtualMachines to just those with snapshots. Later steps are responsible for validating whether those snapshots place the VMs into non-OK states.

func FilterVMsWithToolsIssues

func FilterVMsWithToolsIssues(vms []mo.VirtualMachine) []mo.VirtualMachine

FilterVMsWithToolsIssues filters the provided collection of VirtualMachines to just those with non-OK status.

func GetDatacenters added in v0.17.0

func GetDatacenters(ctx context.Context, c *vim25.Client, dcNames []string, propsSubset bool) ([]mo.Datacenter, error)

GetDatacenters receives a list of Datacenter names along with a boolean value indicating whether only a subset of properties for the Datacenters should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). If an empty list of Datacenter names is provided then all visible Datacenters will be retrieved. The list of Datacenters found is returned, or an error if one occurs.

func GetDatastoreByName

func GetDatastoreByName(ctx context.Context, c *vim25.Client, dsName string, datacenter string, propsSubset bool) (mo.Datastore, error)

GetDatastoreByName accepts the name of a datastore, the name of a datacenter and a boolean value indicating whether only a subset of properties for the Datastore should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). If the datacenter name is an empty string then the default datacenter will be used.

func GetDatastores

func GetDatastores(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.Datastore, error)

GetDatastores accepts a context, a connected client and a boolean value indicating whether a subset of properties per Datastore are retrieved. A collection of Datastores with requested properties is returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow).

func GetEligibleRPs

func GetEligibleRPs(ctx context.Context, c *vim25.Client, includeRPs []string, excludeRPs []string, propsSubset bool) ([]mo.ResourcePool, error)

GetEligibleRPs receives a list of Resource Pool names that should either be explicitly included or excluded along with a boolean value indicating whether only a subset of properties for the Resource Pools should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). The filtered list of Resource Pools is returned, or an error if one occurs.

func GetHostSystemByName added in v0.2.0

func GetHostSystemByName(ctx context.Context, c *vim25.Client, hsName string, datacenter string, propsSubset bool) (mo.HostSystem, error)

GetHostSystemByName accepts the name of a HostSystem, the name of a datacenter and a boolean value indicating whether only a subset of properties for the HostSystem should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). If the datacenter name is an empty string then the default datacenter will be used.

func GetHostSystems added in v0.2.0

func GetHostSystems(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.HostSystem, error)

GetHostSystems accepts a context, a connected client and a boolean value indicating whether a subset of properties per HostSystem are retrieved. A collection of HostSystems with requested properties is returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow).

func GetHostSystemsTotalMemory added in v0.7.0

func GetHostSystemsTotalMemory(ctx context.Context, c *vim25.Client, excludeOffline bool) (int64, error)

GetHostSystemsTotalMemory returns the total memory capacity for all HostSystems. Unless requested, offline or otherwise unavailable hosts are included for evaluation based on the assumption that offline hosts are offline for only a brief time and should still be considered part of overall cluster capacity.

func GetNetworkByName

func GetNetworkByName(ctx context.Context, c *vim25.Client, netName string, datacenter string, propsSubset bool) (mo.Network, error)

GetNetworkByName accepts the name of a network, the name of a datacenter and a boolean value indicating whether only a subset of properties for the Network should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). If the datacenter name is an empty string then the default datacenter will be used.

func GetNetworks

func GetNetworks(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.Network, error)

GetNetworks accepts a context, a connected client and a boolean value indicating whether a subset of properties per Network are retrieved. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). A collection of Networks with requested properties is returned or nil and an error, if one occurs.

func GetObjectCAVal added in v0.2.0

func GetObjectCAVal(caName string, obj mo.ManagedEntity) (string, error)

GetObjectCAVal receives the name of a Custom Attribute and a ManagedEntity, an abstract base type for all managed objects present in the inventory tree and returns the value for the specified Custom Attribute. An error is returned if the value could not be retrieved indicating the cause of the failure.

func GetRPByName added in v0.2.0

func GetRPByName(ctx context.Context, c *vim25.Client, rpName string, datacenter string, propsSubset bool) (mo.ResourcePool, error)

GetRPByName accepts the name of a Resource Pool, the name of a datacenter and a boolean value indicating whether only a subset of properties for the Network should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). If the datacenter name is an empty string then the default datacenter will be used.

func GetVMByName

func GetVMByName(ctx context.Context, c *vim25.Client, vmName string, datacenter string, propsSubset bool) (mo.VirtualMachine, error)

GetVMByName accepts the name of a VirtualMachine, the name of a datacenter and a boolean value indicating whether only a subset of properties for the VirtualMachine should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). If the datacenter name is an empty string then the default datacenter will be used.

func GetVMToolsStatusSummary

func GetVMToolsStatusSummary(vms []mo.VirtualMachine) (string, int)

GetVMToolsStatusSummary accepts a collection of VirtualMachines and checks the ToolsStatus for each one providing an overall Nagios state label and exit code for the collection.

func GetVMs

func GetVMs(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.VirtualMachine, error)

GetVMs accepts a context, a connected client and a boolean value indicating whether a subset of properties per VirtualMachine are retrieved. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow) A collection of VirtualMachines with requested properties is returned or nil and an error, if one occurs.

func GetVMsFromContainer added in v0.8.0

func GetVMsFromContainer(ctx context.Context, c *vim25.Client, propsSubset bool, objs ...mo.ManagedEntity) ([]mo.VirtualMachine, error)

GetVMsFromContainer receives one or many ManagedEntity values for Folder, Datacenter, ComputeResource, ResourcePool, or HostSystem types and returns a list of VirtualMachine object references.

The propsSubset boolean value indicates whether a subset of properties per VirtualMachine are retrieved. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). A collection of VirtualMachines with requested properties is returned or nil and an error, if one occurs.

func GetVMsFromDatastore added in v0.3.0

func GetVMsFromDatastore(ctx context.Context, c *vim25.Client, ds mo.Datastore, propsSubset bool) ([]mo.VirtualMachine, error)

GetVMsFromDatastore receives a Datastore object reference and returns a list of VirtualMachine object references. The propsSubset boolean value indicates whether a subset of properties per VirtualMachine are retrieved. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow) A collection of VirtualMachines with requested properties is returned or nil and an error, if one occurs.

func H2D2VMsOneLineCheckSummary added in v0.2.0

func H2D2VMsOneLineCheckSummary(
	stateLabel string,
	evaluatedVMs []mo.VirtualMachine,
	vmDatastoresPairingIssues VMToMismatchedDatastoreNames,
	rps []mo.ResourcePool,
) string

H2D2VMsOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func H2D2VMsReport added in v0.2.0

func H2D2VMsReport(
	c *vim25.Client,
	h2dIdx HostToDatastoreIndex,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmDatastoresPairingIssues VMToMismatchedDatastoreNames,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
	ignoreMissingCA bool,
	ignoredDatastores []string,
	datastoreCAPrefixSeparator string,
	hostCAPrefixSeparator string,
	datastoreCAName string,
	hostCAName string,
) string

H2D2VMsReport generates a summary of host/datastore/vms pairings along with additional details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func HostSystemCPUUsageOneLineCheckSummary added in v0.9.0

func HostSystemCPUUsageOneLineCheckSummary(
	stateLabel string,
	hsVMs []mo.VirtualMachine,
	hsUsageSummary HostSystemCPUSummary,
) string

HostSystemCPUUsageOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func HostSystemCPUUsageReport added in v0.9.0

func HostSystemCPUUsageReport(
	c *vim25.Client,
	hsVMs []mo.VirtualMachine,
	hsUsageSummary HostSystemCPUSummary,
) string

HostSystemCPUUsageReport generates a summary of HostSystem CPU usage along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func HostSystemMemoryUsageOneLineCheckSummary added in v0.8.0

func HostSystemMemoryUsageOneLineCheckSummary(
	stateLabel string,
	hsVMs []mo.VirtualMachine,
	hsUsageSummary HostSystemMemorySummary,
) string

HostSystemMemoryUsageOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func HostSystemMemoryUsageReport added in v0.8.0

func HostSystemMemoryUsageReport(
	c *vim25.Client,
	hsVMs []mo.VirtualMachine,
	hsUsageSummary HostSystemMemorySummary,
) string

HostSystemMemoryUsageReport generates a summary of HostSystem memory usage along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func ListVMSnapshots added in v0.5.0

func ListVMSnapshots(vm mo.VirtualMachine, w io.Writer)

ListVMSnapshots generates a quick listing of all snapshots for a given VM and emits the results to the provided io.Writer.

func Login

func Login(
	ctx context.Context,
	server string,
	port int,
	trustCert bool,
	username string,
	domain string,
	password string,
	userAgent string,
) (*govmomi.Client, error)

Login receives credentials and related settings used to handle creating a new client and logging into a specified vSphere environment. The initialized and logged-in client is returned for further use.

func MemoryUsedPercentage added in v0.6.0

func MemoryUsedPercentage(
	aggregateMemoryUsage int64,
	maxMemoryUsageInGB int,
) float64

MemoryUsedPercentage is a helper function used to calculate the current memory usage as a percentage of the specified maximum memory allowed to be used.

func RPMemoryUsageOneLineCheckSummary added in v0.6.0

func RPMemoryUsageOneLineCheckSummary(
	stateLabel string,
	aggregateMemoryUsage int64,
	maxMemoryUsageInGB int,
	clusterMemoryInGB int64,
	rps []mo.ResourcePool,
) string

RPMemoryUsageOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func ResourcePoolsMemoryReport added in v0.6.0

func ResourcePoolsMemoryReport(
	c *vim25.Client,
	aggregateMemoryUsage int64,
	maxMemoryUsageInGB int,
	clusterMemoryInGB int64,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
	rpsVMs []mo.VirtualMachine,
) string

ResourcePoolsMemoryReport generates a summary of memory usage associated with specified Resource Pools along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func SnapshotsAgeOneLineCheckSummary added in v0.4.0

func SnapshotsAgeOneLineCheckSummary(
	stateLabel string,
	snapshotSets SnapshotSummarySets,
	snapshotThresholds SnapshotThresholds,
	evaluatedVMs []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

SnapshotsAgeOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func SnapshotsAgeReport added in v0.4.0

func SnapshotsAgeReport(
	c *vim25.Client,
	snapshotSummarySets SnapshotSummarySets,
	snapshotThresholds SnapshotThresholds,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsWithIssues []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

SnapshotsAgeReport generates a summary of snapshot details along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func SnapshotsCountOneLineCheckSummary added in v0.7.0

func SnapshotsCountOneLineCheckSummary(
	stateLabel string,
	snapshotSets SnapshotSummarySets,
	snapshotThresholds SnapshotThresholds,
	evaluatedVMs []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

SnapshotsCountOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func SnapshotsCountReport added in v0.7.0

func SnapshotsCountReport(
	c *vim25.Client,
	snapshotSummarySets SnapshotSummarySets,
	snapshotThresholds SnapshotThresholds,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsWithIssues []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

SnapshotsCountReport generates a summary of snapshot details along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func SnapshotsSizeOneLineCheckSummary added in v0.5.0

func SnapshotsSizeOneLineCheckSummary(
	stateLabel string,
	snapshotSets SnapshotSummarySets,
	snapshotThresholds SnapshotThresholds,
	evaluatedVMs []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

SnapshotsSizeOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func SnapshotsSizeReport added in v0.5.0

func SnapshotsSizeReport(
	c *vim25.Client,
	snapshotSummarySets SnapshotSummarySets,
	snapshotThresholds SnapshotThresholds,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsWithIssues []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

SnapshotsSizeReport generates a summary of snapshot details along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func VMDiskConsolidationOneLineCheckSummary added in v0.14.0

func VMDiskConsolidationOneLineCheckSummary(
	stateLabel string,
	evaluatedVMs []mo.VirtualMachine,
	vmsNeedingConsolidation []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

VMDiskConsolidationOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func VMDiskConsolidationReport added in v0.14.0

func VMDiskConsolidationReport(
	c *vim25.Client,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsNeedingConsolidation []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

VMDiskConsolidationReport generates a summary of VMs which require disk consolidation along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func VMInteractiveQuestionOneLineCheckSummary added in v0.15.0

func VMInteractiveQuestionOneLineCheckSummary(
	stateLabel string,
	evaluatedVMs []mo.VirtualMachine,
	vmsNeedingResponse []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

VMInteractiveQuestionOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func VMInteractiveQuestionReport added in v0.15.0

func VMInteractiveQuestionReport(
	c *vim25.Client,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsNeedingResponse []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

VMInteractiveQuestionReport generates a summary of VMs which require an interactive response along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func VMNames added in v0.14.0

func VMNames(vmsList []mo.VirtualMachine) []string

VMNames receives a list of VirtualMachine values and returns a new list of VirtualMachine Name values.

func VMPowerCycleUptimeOneLineCheckSummary added in v0.10.0

func VMPowerCycleUptimeOneLineCheckSummary(
	stateLabel string,
	evaluatedVMs []mo.VirtualMachine,
	uptimeSummary VirtualMachinePowerCycleUptimeStatus,
	rps []mo.ResourcePool,
) string

VMPowerCycleUptimeOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func VMPowerCycleUptimeReport added in v0.10.0

func VMPowerCycleUptimeReport(
	c *vim25.Client,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	uptimeSummary VirtualMachinePowerCycleUptimeStatus,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

VMPowerCycleUptimeReport generates a summary of VMs which exceed power cycle uptime thresholds along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func VMToolsOneLineCheckSummary

func VMToolsOneLineCheckSummary(
	stateLabel string,
	evaluatedVMs []mo.VirtualMachine,
	vmsWithIssues []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

VMToolsOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func VMToolsReport

func VMToolsReport(
	c *vim25.Client,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsWithIssues []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

VMToolsReport generates a comprehensive summary including any active issues along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func ValidateDCs added in v0.17.0

func ValidateDCs(ctx context.Context, c *vim25.Client, datacenters []string) error

ValidateDCs receives a list of Datacenter names and compares against all visible Datacenter objects within the vSphere environment. If any are not found an error is returned listing which ones. If an empty list of Datacenter names is provided validation is considered successful.

func ValidateRPs

func ValidateRPs(ctx context.Context, c *vim25.Client, includeRPs []string, excludeRPs []string) error

ValidateRPs is responsible for receiving two lists of resource pools, explicitly "included" (aka, "whitelisted") and explicitly "excluded" (aka, "blacklisted"). If any list entries are not found in the vSphere environment an error is returned listing which ones.

func VirtualCPUsOneLineCheckSummary

func VirtualCPUsOneLineCheckSummary(
	stateLabel string,
	vCPUsAllocated int32,
	vCPUsMax int,
	evaluatedVMs []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

VirtualCPUsOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func VirtualCPUsReport

func VirtualCPUsReport(
	c *vim25.Client,
	vCPUsAllocated int32,
	vCPUsMax int,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

VirtualCPUsReport generates a summary of vCPU usage along with various verbose details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

func VirtualHardwareOneLineCheckSummary

func VirtualHardwareOneLineCheckSummary(
	stateLabel string,
	hwvIndex HardwareVersionsIndex,
	minHardwareVersion int,
	evaluatedVMs []mo.VirtualMachine,
	rps []mo.ResourcePool,
) string

VirtualHardwareOneLineCheckSummary is used to generate a one-line Nagios service check results summary. This is the line most prominent in notifications.

func VirtualHardwareReport

func VirtualHardwareReport(
	c *vim25.Client,
	hwvIndex HardwareVersionsIndex,
	minHardwareVersion int,
	defaultHardwareVersion HardwareVersion,
	allVMs []mo.VirtualMachine,
	evaluatedVMs []mo.VirtualMachine,
	vmsToExclude []string,
	evalPoweredOffVMs bool,
	includeRPs []string,
	excludeRPs []string,
	rps []mo.ResourcePool,
) string

VirtualHardwareReport generates a summary of virtual hardware details intended to aid in troubleshooting check results at a glance. This information is provided for use with the Long Service Output field commonly displayed on the detailed service check results display in the web UI or in the body of many notifications.

Types

type AlarmEntity added in v0.16.0

type AlarmEntity struct {

	// Name is the name of the entity (e.g., HUSVM-DC1-vol6) associated with a
	// triggered alarm.
	Name string

	// OverallStatus is the entity's top-level or overall status. vSphere
	// represents this status (aka, ManagedEntityStatus) as a color (gray,
	// green, red or yellow) with green indicating "OK" and red "CRITICAL".
	OverallStatus types.ManagedEntityStatus

	// MOID is the Managed Object Reference of the entity.
	MOID types.ManagedObjectReference

	// ResourcePools are the names of the Resource Pool that the
	// TriggeredAlarm entity is part of. This applies to VirtualMachine and
	// ResourcePool types. VirtualMachine types have one entry and
	// ResourcePool types have two (self & parent).
	ResourcePools []string
}

AlarmEntity is the affected resource associated with an alarm. For example, for a triggered "Datastore usage on disk" alarm, AlarmEntity represents the affected datastore.

type CPUSpeed added in v0.9.0

type CPUSpeed float64

CPUSpeed represents the speed of a CPU

func (CPUSpeed) String added in v0.9.0

func (cpu CPUSpeed) String() string

type DatastoreIDToNameIndex added in v0.2.0

type DatastoreIDToNameIndex map[string]string

DatastoreIDToNameIndex maps a Datastore's ID value to its name.

type DatastoreUsageSummary added in v0.3.0

type DatastoreUsageSummary struct {
	Datastore               mo.Datastore
	StorageRemainingPercent float64
	StorageUsedPercent      float64
	StorageTotal            int64
	StorageUsed             int64
	StorageRemaining        int64
	CriticalThreshold       int
	WarningThreshold        int
}

DatastoreUsageSummary tracks usage details for a specific Datastore

func NewDatastoreUsageSummary added in v0.3.0

func NewDatastoreUsageSummary(ds mo.Datastore, criticalThreshold int, warningThreshold int) DatastoreUsageSummary

NewDatastoreUsageSummary receives a Datastore and generates summary information used to determine if usage levels have crossed user-specified thresholds.

func (DatastoreUsageSummary) IsCriticalState added in v0.3.0

func (dus DatastoreUsageSummary) IsCriticalState() bool

IsCriticalState indicates whether Datastore usage has crossed the CRITICAL level threshold.

func (DatastoreUsageSummary) IsWarningState added in v0.3.0

func (dus DatastoreUsageSummary) IsWarningState() bool

IsWarningState indicates whether Datastore usage has crossed the WARNING level threshold.

type DatastoreWithCA added in v0.2.0

type DatastoreWithCA struct {
	mo.Datastore
	CustomAttribute PairingCustomAttribute
}

DatastoreWithCA wraps the vSphere Datastore managed object type with a Custom Attribute key/value pair. This Custom Attribute is intended to link this datastore to a specific ESXi host.

type ErrHostDatastoreIdxIDToNameLookupFailed added in v0.2.0

type ErrHostDatastoreIdxIDToNameLookupFailed struct {
	Err         error
	DatastoreID string
}

ErrHostDatastoreIdxIDToNameLookupFailed is returned when a search of the host to datastore index fails to yield a name for a specified ID value. This can occur if the datastore for a VM is in a user-specified ignored datastores list.

func (ErrHostDatastoreIdxIDToNameLookupFailed) Error added in v0.2.0

type HardwareVersion

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

HardwareVersion represents the virtual hardware version of a VirtualMachine.

func DefaultHardwareVersion added in v0.13.0

func DefaultHardwareVersion(ctx context.Context, c *vim25.Client, hostName string, clusterName string, datacenterName string) (HardwareVersion, error)

DefaultHardwareVersion accepts optional host, cluster and datacenter names and returns the default hardware version. If not specified, an attempt will be made to use the default Datacenter and default ComputeResource (obtained using cluster name). If a host name is supplied, it will be used to obtain the default hardware version. If a host name and a cluster name are provided, an error will be returned.

The default version may not be the very latest version supported in the cluster (e.g., v14 is the default, but v15 is the latest supported).

func NewHardwareVersion added in v0.11.0

func NewHardwareVersion(verStr string) HardwareVersion

NewHardwareVersion creates a new HardwareVersion value using a provided string with "vmx-" prefix (e.g., vmx-15).

func (HardwareVersion) Count

func (hv HardwareVersion) Count() int

Count returns the number of VirtualMachines with this specific virtual hardware version.

func (HardwareVersion) IsHighest

func (hv HardwareVersion) IsHighest() bool

IsHighest indicates whether this HardwareVersion is the highest version in our inventory.

func (HardwareVersion) String

func (hv HardwareVersion) String() string

String is a Stringer implementation to return the original formatted string.

func (HardwareVersion) VersionNumber

func (hv HardwareVersion) VersionNumber() int

VersionNumber returns the numeric version number of a VirtualMachine or -1 if there was an issue converting the prefixed string value to a usable number.

type HardwareVersions

type HardwareVersions []HardwareVersion

HardwareVersions represents a collection of HardwareVersion.

func (HardwareVersions) MeetsMinVersion added in v0.11.0

func (hvs HardwareVersions) MeetsMinVersion(minVer int) bool

MeetsMinVersion accepts the minimum hardware version for all VMs and indicates whether all hardware versions meet or exceed the minimum.

func (HardwareVersions) Sum

func (hvs HardwareVersions) Sum() int

Sum provides the total count of all HardwareVersion entries.

func (HardwareVersions) VersionNames

func (hvs HardwareVersions) VersionNames() []string

VersionNames returns a list of all hardware versions in their original string format.

func (HardwareVersions) VersionNumbers

func (hvs HardwareVersions) VersionNumbers() []int

VersionNumbers returns a list of all hardware versions in numerical format. -1 is returned for each hardware version if there was an issue converting the prefixed string value to a usable number.

type HardwareVersionsIndex

type HardwareVersionsIndex map[string]int

HardwareVersionsIndex is a map of hardware version to number of VMs present with that hardware version. This index serves as just that, an index. Accessor methods are provided to obtain HardwareVersion and HardwareVersions types which provide most of the useful methods for working with hardware version entries.

func (HardwareVersionsIndex) Count

func (hvi HardwareVersionsIndex) Count() int

Count returns the number of hardware versions stored in the index.

func (HardwareVersionsIndex) Newest

Newest returns the highest hardware version stored in the index. This value is returned as a HardwareVersion type, providing both the original vmx-123 formatted string in addition to the actual version number.

func (HardwareVersionsIndex) Oldest

Oldest returns the highest hardware version stored in the index. This value is returned as a HardwareVersion type, providing both the original vmx-123 formatted string in addition to the actual version number.

func (HardwareVersionsIndex) Outdated

func (hvi HardwareVersionsIndex) Outdated() HardwareVersions

Outdated returns a collection of all older HardwareVersion.

func (HardwareVersionsIndex) Versions

func (hvi HardwareVersionsIndex) Versions() HardwareVersions

Versions returns a collection of all HardwareVersion entries from the index.

type HostDatastoresPairing added in v0.2.0

type HostDatastoresPairing struct {
	Host       HostWithCA
	Datastores []DatastoreWithCA
}

HostDatastoresPairing collects Host and Datastores pairings based on shared Custom Attribute name and value (literal) or prefix (if user-specified). This is intended to "pair" hosts and datastores within an environment that are known to work well together.

type HostSystemCPUSummary added in v0.9.0

type HostSystemCPUSummary struct {
	HostSystem          mo.HostSystem
	CPUUsedPercent      float64
	CPURemainingPercent float64

	// CPUUsed is the amount of CPU used by the host in Hz.
	CPUUsed float64

	// CPURemaining is the amount of CPU capacity remaining to the host in Hz.
	CPURemaining float64

	// CPUTotal is the total amount of CPU capacity for the host in Hz.
	CPUTotal          float64
	CriticalThreshold int
	WarningThreshold  int
}

HostSystemCPUSummary tracks CPU usage details for a specific HostSystem.

func NewHostSystemCPUUsageSummary added in v0.9.0

func NewHostSystemCPUUsageSummary(hs mo.HostSystem, criticalThreshold int, warningThreshold int) HostSystemCPUSummary

NewHostSystemCPUUsageSummary receives a HostSystem and generates summary information used to determine if usage levels have crossed user-specified thresholds.

func (HostSystemCPUSummary) IsCriticalState added in v0.9.0

func (hss HostSystemCPUSummary) IsCriticalState() bool

IsCriticalState indicates whether HostSystem CPU usage has crossed the CRITICAL level threshold.

func (HostSystemCPUSummary) IsWarningState added in v0.9.0

func (hss HostSystemCPUSummary) IsWarningState() bool

IsWarningState indicates whether HostSystem CPU usage has crossed the WARNING level threshold.

type HostSystemMemorySummary added in v0.9.0

type HostSystemMemorySummary struct {
	HostSystem             mo.HostSystem
	MemoryUsedPercent      float64
	MemoryRemainingPercent float64

	// MemoryUsed is the amount of memory used by the host in bytes.
	MemoryUsed int64

	// MemoryUsed is the amount of memory remaining to the host in bytes.
	MemoryRemaining int64

	// MemoryTotal is the total amount of memory for the host in bytes.
	MemoryTotal       int64
	CriticalThreshold int
	WarningThreshold  int
}

HostSystemMemorySummary tracks memory usage details for a specific HostSystem.

func NewHostSystemMemoryUsageSummary added in v0.9.0

func NewHostSystemMemoryUsageSummary(hs mo.HostSystem, criticalThreshold int, warningThreshold int) HostSystemMemorySummary

NewHostSystemMemoryUsageSummary receives a HostSystem and generates summary information used to determine if usage levels have crossed user-specified thresholds.

func (HostSystemMemorySummary) IsCriticalState added in v0.9.0

func (hss HostSystemMemorySummary) IsCriticalState() bool

IsCriticalState indicates whether HostSystem memory usage has crossed the CRITICAL level threshold.

func (HostSystemMemorySummary) IsWarningState added in v0.9.0

func (hss HostSystemMemorySummary) IsWarningState() bool

IsWarningState indicates whether HostSystem memory usage has crossed the WARNING level threshold.

type HostToDatastoreIndex added in v0.2.0

type HostToDatastoreIndex map[string]HostDatastoresPairing

HostToDatastoreIndex indexes HostDatastorePairings based on host id values.

func NewHostToDatastoreIndex added in v0.2.0

func NewHostToDatastoreIndex(
	hosts []HostWithCA,
	datastores []DatastoreWithCA,
	usingPrefixes bool,
	hostCASep string,
	datastoreCASep string,
) (HostToDatastoreIndex, error)

NewHostToDatastoreIndex receives a collection of hosts and datastores wrapped with user-specified Custom Attributes, prefix separators and a boolean flag indicating whether prefix matching will be used. The resulting HostToDatastoreIndex is returned if no errors occur, otherwise nil and the error.

func (HostToDatastoreIndex) DatastoreIDToName added in v0.2.0

func (hdi HostToDatastoreIndex) DatastoreIDToName(dsID string) (string, error)

DatastoreIDToName returns the name associated with a Datastore ID. An error is returned if the name could not be retrieved from the index.

func (HostToDatastoreIndex) DatastoreIDToNameIndex added in v0.2.0

func (hdi HostToDatastoreIndex) DatastoreIDToNameIndex() DatastoreIDToNameIndex

DatastoreIDToNameIndex returns an index of all Datastore IDs to names in the index.

func (HostToDatastoreIndex) DatastoreNames added in v0.2.0

func (hdi HostToDatastoreIndex) DatastoreNames() []string

DatastoreNames returns a list of all Datastore names in the index.

func (HostToDatastoreIndex) IsDatastoreIDInIndex added in v0.2.0

func (hdi HostToDatastoreIndex) IsDatastoreIDInIndex(dsID string) bool

IsDatastoreIDInIndex indicates whether a provided Datastore ID is in the index.

func (HostToDatastoreIndex) ValidateVirtualMachinePairings added in v0.2.0

func (hdi HostToDatastoreIndex) ValidateVirtualMachinePairings(
	vmHostID string,
	allDatastores []mo.Datastore,
	vmDatastoreRefs []types.ManagedObjectReference,
	dsNamesToIgnore []string,
) ([]string, error)

ValidateVirtualMachinePairings receives a VirtualMachine ID, a collection of Datastore IDs associated with the VM and an optional list of Datastore names to ignore. A list of mismatched datastores is returned along with any errors that may occur.

type HostWithCA added in v0.2.0

type HostWithCA struct {
	mo.HostSystem
	CustomAttribute PairingCustomAttribute
}

HostWithCA wraps the vSphere HostSystem managed object type with a Custom Attribute key/value pair. This Custom Attribute is intended to link this host to one or more datastores.

type PairingCustomAttribute added in v0.2.0

type PairingCustomAttribute struct {
	Name  string
	Value string
}

PairingCustomAttribute represents the key/value Custom Attribute pair used to relate specific hosts with specific datastores. Most often this takes the form of a "Location" or "Datacenter" field to indicate which Datastore a VirtualMachine should reside on when running on a specific HostSystem.

type SnapshotSummary added in v0.4.0

type SnapshotSummary struct {

	// Name of the snapshot in human readable format.
	Name string

	// MOID is the Managed Object Reference value for the snapshot.
	MOID string

	// Description of the snapshot in human readable format.
	Description string

	// VMName is the name of the VirtualMachine associated with the snapshot.
	VMName string

	// DatastoreName is the name of the associated datastore for the snapshot.
	DatastoreName string

	// Size is the size of the snapshot.
	Size int64

	// ID is the unique identifier that distinguishes this snapshot from other
	// snapshots of the virtual machine.
	ID int32
	// contains filtered or unexported fields
}

SnapshotSummary is intended to be a summary of the most commonly used snapshot details for a specific VirtualMachine snapshot.

func (SnapshotSummary) Age added in v0.4.0

func (ss SnapshotSummary) Age() string

Age returns the age of a snapshot in formatted days.

func (SnapshotSummary) AgeDays added in v0.4.0

func (ss SnapshotSummary) AgeDays() float64

AgeDays returns the age of a snapshot in days.

func (SnapshotSummary) IsAgeCriticalState added in v0.4.0

func (ss SnapshotSummary) IsAgeCriticalState() bool

IsAgeCriticalState indicates whether the snapshot has exceeded the age CRITICAL threshold.

func (SnapshotSummary) IsAgeExceeded added in v0.4.0

func (ss SnapshotSummary) IsAgeExceeded(days int) bool

IsAgeExceeded indicates whether the snapshot is older than the specified number of days.

func (SnapshotSummary) IsAgeWarningState added in v0.4.0

func (ss SnapshotSummary) IsAgeWarningState() bool

IsAgeWarningState indicates whether the snapshot has exceeded the age WARNING threshold.

func (SnapshotSummary) IsCriticalState added in v0.4.0

func (ss SnapshotSummary) IsCriticalState() bool

IsCriticalState indicates whether the snapshot has exceeded age or size CRITICAL thresholds.

func (SnapshotSummary) IsSizeCriticalState added in v0.4.0

func (ss SnapshotSummary) IsSizeCriticalState() bool

IsSizeCriticalState indicates whether the snapshot has exceeded the size CRITICAL threshold.

func (SnapshotSummary) IsSizeExceeded added in v0.5.0

func (ss SnapshotSummary) IsSizeExceeded(sizeGB int) bool

IsSizeExceeded indicates whether the snapshot is larger than the specified size in GB.

func (SnapshotSummary) IsSizeWarningState added in v0.4.0

func (ss SnapshotSummary) IsSizeWarningState() bool

IsSizeWarningState indicates whether the snapshot has exceeded the size WARNING threshold.

func (SnapshotSummary) IsWarningState added in v0.4.0

func (ss SnapshotSummary) IsWarningState() bool

IsWarningState indicates whether the snapshot has exceeded age or size WARNING thresholds.

func (SnapshotSummary) SizeHR added in v0.4.0

func (ss SnapshotSummary) SizeHR() string

SizeHR returns the human readable size of the snapshot.

type SnapshotSummarySet added in v0.4.0

type SnapshotSummarySet struct {

	// VM is the Managed Object Reference for the VirtualMachine associated
	// with the snapshots in this set.
	VM types.ManagedObjectReference

	// VMName is the name of the VirtualMachine associated with the snapshots
	// in this set.
	VMName string

	// Snapshots is the collection of higher level summary values for
	// snapshots associated with a specific VirtualMachine.
	Snapshots []SnapshotSummary
	// contains filtered or unexported fields
}

SnapshotSummarySet ties a collection of snapshot summary values to a specific VirtualMachine by way of a VirtualMachine Managed Object Reference.

func NewSnapshotSummarySet added in v0.4.0

func NewSnapshotSummarySet(
	vm mo.VirtualMachine,
	snapshotThresholds SnapshotThresholds,
) SnapshotSummarySet

NewSnapshotSummarySet returns a set of SnapshotSummary values for snapshots associated with a specified VirtualMachine.

func (SnapshotSummarySet) ExceedsAge added in v0.4.0

func (sss SnapshotSummarySet) ExceedsAge(days int) int

ExceedsAge indicates how many snapshots in the set are older than the specified number of days. Unlike the ExceedsAge method for SnapshotSummarySets, this method focuses specifically on individual snapshots.

func (SnapshotSummarySet) ExceedsSize added in v0.5.0

func (sss SnapshotSummarySet) ExceedsSize(sizeGB int) int

ExceedsSize indicates how many snapshots in the set are larger than the specified size in GB. Unlike the ExceedsSize method for SnapshotSummarySets, this method focuses specifically on individual snapshot size.

func (SnapshotSummarySet) IsAgeCriticalState added in v0.4.0

func (sss SnapshotSummarySet) IsAgeCriticalState() bool

IsAgeCriticalState indicates whether the snapshot set has exceeded the age CRITICAL threshold.

func (SnapshotSummarySet) IsAgeWarningState added in v0.4.0

func (sss SnapshotSummarySet) IsAgeWarningState() bool

IsAgeWarningState indicates whether the snapshot set has exceeded the age WARNING threshold.

func (SnapshotSummarySet) IsCountCriticalState added in v0.7.0

func (sss SnapshotSummarySet) IsCountCriticalState() bool

IsCountCriticalState indicates whether the snapshot set has exceeded the snapshots count CRITICAL threshold.

func (SnapshotSummarySet) IsCountWarningState added in v0.7.0

func (sss SnapshotSummarySet) IsCountWarningState() bool

IsCountWarningState indicates whether the snapshot set has exceeded the snapshots count WARNING threshold.

func (SnapshotSummarySet) IsCriticalState added in v0.4.0

func (sss SnapshotSummarySet) IsCriticalState() bool

IsCriticalState indicates whether the snapshot set has exceeded age, size or count CRITICAL thresholds.

func (SnapshotSummarySet) IsSizeCriticalState added in v0.4.0

func (sss SnapshotSummarySet) IsSizeCriticalState() bool

IsSizeCriticalState indicates whether the snapshot set has exceeded the size CRITICAL threshold.

func (SnapshotSummarySet) IsSizeWarningState added in v0.4.0

func (sss SnapshotSummarySet) IsSizeWarningState() bool

IsSizeWarningState indicates whether the snapshot set has exceeded the size WARNING threshold.

func (SnapshotSummarySet) IsWarningState added in v0.4.0

func (sss SnapshotSummarySet) IsWarningState() bool

IsWarningState indicates whether the snapshot set has exceeded age, size or count WARNING thresholds.

func (SnapshotSummarySet) Size added in v0.4.0

func (sss SnapshotSummarySet) Size() int64

Size returns the size of all snapshots in the set.

func (SnapshotSummarySet) SizeHR added in v0.4.0

func (sss SnapshotSummarySet) SizeHR() string

SizeHR returns the human readable size of all snapshots in the set.

type SnapshotSummarySets added in v0.4.0

type SnapshotSummarySets []SnapshotSummarySet

SnapshotSummarySets is a collection of SnapshotSummarySet types for bulk operations. Most often this is used when determining the overall state of all sets in the collection.

func (SnapshotSummarySets) ExceedsAge added in v0.4.0

func (sss SnapshotSummarySets) ExceedsAge(days int) (int, int)

ExceedsAge indicates how many sets and number of snapshots from all of those sets are older than the specified number of days.

func (SnapshotSummarySets) ExceedsSize added in v0.5.0

func (sss SnapshotSummarySets) ExceedsSize(sizeGB int) (int, int)

ExceedsSize indicates how many sets and number of snapshots from all of those sets have cumulative snapshots larger than the specified size in GB.

func (SnapshotSummarySets) ExcessSnapshots added in v0.7.0

func (sss SnapshotSummarySets) ExcessSnapshots(count int) (int, int, int)

ExcessSnapshots indicates how many sets have excess snapshots, how many excess snapshots there are and how many total snapshots there are.

func (SnapshotSummarySets) FilterByCount added in v0.7.0

func (sss SnapshotSummarySets) FilterByCount(count int) SnapshotSummarySets

FilterByCount returns a SnapshotSummarySets value containing only sets which have snapshots in excess of the specified number.

func (SnapshotSummarySets) HasNotYetExceededAge added in v0.5.0

func (sss SnapshotSummarySets) HasNotYetExceededAge(days int) bool

HasNotYetExceededAge indicates whether any of the snapshots in any of the sets have yet to exceed the threshold for the specified number of days.

func (SnapshotSummarySets) HasNotYetExceededCount added in v0.7.0

func (sss SnapshotSummarySets) HasNotYetExceededCount(count int) bool

HasNotYetExceededCount indicates whether any of the sets have yet to exceed the threshold for the specified number of snapshots.

func (SnapshotSummarySets) HasNotYetExceededSize added in v0.5.0

func (sss SnapshotSummarySets) HasNotYetExceededSize(sizeGB int) bool

HasNotYetExceededSize indicates whether any snapshot set (all snapshots for a specific VM) has yet to exceed the threshold for the specified size in GB.

func (SnapshotSummarySets) IsAgeCriticalState added in v0.4.0

func (sss SnapshotSummarySets) IsAgeCriticalState() bool

IsAgeCriticalState indicates whether the snapshot sets have exceeded the age CRITICAL threshold.

func (SnapshotSummarySets) IsAgeWarningState added in v0.4.0

func (sss SnapshotSummarySets) IsAgeWarningState() bool

IsAgeWarningState indicates whether the snapshot sets have exceeded the age WARNING threshold.

func (SnapshotSummarySets) IsCountCriticalState added in v0.7.0

func (sss SnapshotSummarySets) IsCountCriticalState() bool

IsCountCriticalState indicates whether the snapshot sets have exceeded the count CRITICAL threshold.

func (SnapshotSummarySets) IsCountWarningState added in v0.7.0

func (sss SnapshotSummarySets) IsCountWarningState() bool

IsCountWarningState indicates whether the snapshot sets have exceeded the count WARNING threshold.

func (SnapshotSummarySets) IsCriticalState added in v0.4.0

func (sss SnapshotSummarySets) IsCriticalState() bool

IsCriticalState indicates whether the snapshot sets have exceeded age, size or count CRITICAL thresholds.

func (SnapshotSummarySets) IsSizeCriticalState added in v0.4.0

func (sss SnapshotSummarySets) IsSizeCriticalState() bool

IsSizeCriticalState indicates whether the snapshot sets have exceeded the size CRITICAL threshold.

func (SnapshotSummarySets) IsSizeWarningState added in v0.4.0

func (sss SnapshotSummarySets) IsSizeWarningState() bool

IsSizeWarningState indicates whether the snapshot sets have exceeded the size WARNING threshold.

func (SnapshotSummarySets) IsWarningState added in v0.4.0

func (sss SnapshotSummarySets) IsWarningState() bool

IsWarningState indicates whether the snapshot sets have exceeded age, size or count WARNING thresholds.

func (SnapshotSummarySets) Snapshots added in v0.5.1

func (sss SnapshotSummarySets) Snapshots() int

Snapshots indicates how many snapshots are in all of the sets.

type SnapshotThresholds added in v0.7.0

type SnapshotThresholds struct {
	AgeCritical   int
	AgeWarning    int
	SizeCritical  int
	SizeWarning   int
	CountCritical int
	CountWarning  int
}

SnapshotThresholds represents the specific thresholds used to determine whether one or many snapshots are considered to be in a CRITICAL or WARNING state.

type SnapshotsIndex added in v0.4.0

type SnapshotsIndex map[string]types.VirtualMachineSnapshotTree

SnapshotsIndex is a mapping of Snapshot ManagedObjectReference to a tree of snapshot details. This type is intended to help with producing a superset type combining a summary of snapshot metadata with the original VirtualMachine object.

Deprecated ?

type TriggeredAlarm added in v0.16.0

type TriggeredAlarm struct {

	// Entity is the affected resource associated with the triggered alarm.
	Entity AlarmEntity

	// AcknowledgedTime is the time when the triggered alarm was acknowledged
	// by an admin. Defaults to zero value if the triggered alarm has not been
	// acknowledged.
	AcknowledgedTime time.Time

	// Time is when the alarm was triggered.
	Time time.Time

	// Name is the name of the defined alarm.
	Name string

	// MOID is the Managed Object Reference to the defined alarm.
	MOID types.ManagedObjectReference

	// Key is the unique identifier for the triggered alarm or alarm "state"
	// (AlarmState), not the defined alarm (AlarmInfo).
	Key string

	// Description is the description of the defined alarm.
	Description string

	// Datacenter is the datacenter where the alarm was triggered.
	Datacenter string

	// AcknowledgedByUser is the user which acknowledged the alarm.
	AcknowledgedByUser string

	// ExcludeReason gives a brief explanation of why a TriggeredAlarm is
	// excluded.
	ExcludeReason string

	// OverallStatus is the alarm's top-level or overall status of the alarm.
	// vSphere represents this status (aka, ManagedEntityStatus) as a color
	// (gray, green, red or yellow) with green indicating "OK" and red
	// "CRITICAL".
	OverallStatus types.ManagedEntityStatus

	// Acknowledged indicates whether the triggered alarm has been
	// acknowledged by an admin user.
	Acknowledged bool

	// Exclude indicates whether the TriggeredAlarm has been excluded from
	// final evaluation. During processing multiple filters are applied. We
	// track exclusion state through the filtering pipeline so that any
	// explicit inclusions chosen by the sysadmin will have the opportunity to
	// reset this state and have the TriggeredAlarm considered for evaluation.
	Exclude bool

	// ExplicitlyIncluded indicates whether the TriggeredAlarm has been marked
	// for explicit inclusion by a step in the filtering pipeline. A
	// TriggeredAlarm marked in this way is not "dropped" by later explicit
	// inclusion filtering steps in the pipeline.
	ExplicitlyIncluded bool

	// ExplicitlyExcluded indicates whether the TriggeredAlarm has been marked
	// for explicit exclusion by a step in the filtering pipeline.
	ExplicitlyExcluded bool
}

TriggeredAlarm represents the state of an alarm along with the affected resource associated with the alarm.

func (TriggeredAlarm) Excluded added in v0.17.0

func (ta TriggeredAlarm) Excluded() bool

Excluded indicates whether a TriggeredAlarm has been excluded implicitly (for now) or explicitly (permanently) from further evaluation.

func (TriggeredAlarm) ExcludedFinal added in v0.17.0

func (ta TriggeredAlarm) ExcludedFinal() bool

ExcludedFinal indicates whether a TriggeredAlarm has been permanently excluded from further evaluation.

type TriggeredAlarmFilters added in v0.17.0

type TriggeredAlarmFilters struct {
	IncludedAlarmEntityTypes         []string
	ExcludedAlarmEntityTypes         []string
	IncludedAlarmEntityNames         []string
	ExcludedAlarmEntityNames         []string
	IncludedAlarmEntityResourcePools []string
	ExcludedAlarmEntityResourcePools []string
	IncludedAlarmNames               []string
	ExcludedAlarmNames               []string
	IncludedAlarmDescriptions        []string
	ExcludedAlarmDescriptions        []string
	IncludedAlarmStatuses            []string
	ExcludedAlarmStatuses            []string
	EvaluateAcknowledgedAlarms       bool
}

TriggeredAlarmFilters is a collection of the options specified by the user for filtering detected TriggeredAlarms. This is most often used for providing summary information in logging or user-facing output.

type TriggeredAlarms added in v0.16.0

type TriggeredAlarms []TriggeredAlarm

TriggeredAlarms is a collection of alarms which have been triggered across one or more Datacenters.

func GetTriggeredAlarms added in v0.16.0

func GetTriggeredAlarms(ctx context.Context, c *govmomi.Client, datacenters []mo.Datacenter, propsSubset bool) (TriggeredAlarms, error)

GetTriggeredAlarms accepts a list of Datacenters and a boolean value indicating whether only a subset of properties for datacenters and alarms should be returned. If requested, a subset of all available properties will be retrieved (faster) instead of recursively fetching all properties (about 2x as slow). Any TriggeredAlarms found are returned or an error if an empty list is provided or if there are issues retrieving properties for any TriggeredAlarms.

func (TriggeredAlarms) CountPerDatacenter added in v0.16.0

func (tas TriggeredAlarms) CountPerDatacenter() map[string]int

CountPerDatacenter returns a map of Datacenter name to triggered alarms associated with the Datacenter name.

func (TriggeredAlarms) Datacenters added in v0.16.0

func (tas TriggeredAlarms) Datacenters() []string

Datacenters returns a list of Datacenter names associated with the collection of TriggeredAlarms.

func (*TriggeredAlarms) Filter added in v0.17.0

func (tas *TriggeredAlarms) Filter(filters TriggeredAlarmFilters)

Filter explicitly includes or excludes TriggeredAlarms based on specified filter settings.

func (*TriggeredAlarms) FilterByAcknowledgedState added in v0.17.0

func (tas *TriggeredAlarms) FilterByAcknowledgedState(includeAcknowledged bool)

FilterByAcknowledgedState accepts a boolean value to indicate whether previously acknowledged alarms should be included in the final evaluation.

If false, previously acknowledged TriggeredAlarms are marked as explicitly excluded and will be "dropped" from further evaluation in the filtering pipeline. If true, no changes are made. Further evaluation in the filtering pipeline can still mark the TriggeredAlarm as excluded.

func (*TriggeredAlarms) FilterByExcludedDescriptionSubstring added in v0.17.0

func (tas *TriggeredAlarms) FilterByExcludedDescriptionSubstring(exclude []string)

FilterByExcludedDescriptionSubstring accepts a slice of substrings to use in comparisons against TriggeredAlarm descriptions in order to explicitly mark TriggeredAlarms for exclusion in the final evaluation. Flag evaluation logic prevents sysadmins from providing both an inclusion and exclusion list.

func (*TriggeredAlarms) FilterByExcludedEntityResourcePool added in v0.17.0

func (tas *TriggeredAlarms) FilterByExcludedEntityResourcePool(exclude []string)

FilterByExcludedEntityResourcePool accepts a slice of Resource Pool names to use in comparison against the Resource Pool for an entity associated with a TriggeredAlarm. For any matches, the TriggeredAlarm is marked as explicitly excluded. This will result in "dropping" the TriggeredAlarm from further evaluation in the filtering pipeline.

func (*TriggeredAlarms) FilterByExcludedEntityType added in v0.17.0

func (tas *TriggeredAlarms) FilterByExcludedEntityType(excludeTypes []string)

FilterByExcludedEntityType accepts a slice of entity type keywords to use in comparison against the entity type associated with a TriggeredAlarm. For any matches, the TriggeredAlarm is marked as explicitly excluded. This will result in "dropping" the TriggeredAlarm from further evaluation in the filtering pipeline.

func (*TriggeredAlarms) FilterByExcludedNameSubstring added in v0.17.0

func (tas *TriggeredAlarms) FilterByExcludedNameSubstring(exclude []string)

FilterByExcludedNameSubstring accepts a slice of substrings to use in comparisons against TriggeredAlarm names in order to explicitly mark TriggeredAlarms for exclusion in the final evaluation. Flag evaluation logic prevents sysadmins from providing both an inclusion and exclusion list.

func (*TriggeredAlarms) FilterByExcludedStatus added in v0.17.0

func (tas *TriggeredAlarms) FilterByExcludedStatus(exclude []string)

FilterByExcludedStatus accepts a slice of ManagedEntityStatus keywords to use in comparisons against TriggeredAlarm statuses in order to explicitly mark TriggeredAlarms for exclusion in the final evaluation. Flag evaluation logic prevents sysadmins from providing both an inclusion and exclusion list.

func (*TriggeredAlarms) FilterByIncludedDescriptionSubstring added in v0.17.0

func (tas *TriggeredAlarms) FilterByIncludedDescriptionSubstring(include []string)

FilterByIncludedDescriptionSubstring accepts a slice of substrings to use in comparisons against TriggeredAlarm descriptions.

For any matches, the TriggeredAlarm is marked as explicitly included. This will prevent later filtering from implicitly excluding the TriggeredAlarm, but will not stop explicit exclusions from "dropping" the TriggeredAlarm from further evaluation in the filtering pipeline.

func (*TriggeredAlarms) FilterByIncludedEntityResourcePool added in v0.17.0

func (tas *TriggeredAlarms) FilterByIncludedEntityResourcePool(include []string)

FilterByIncludedEntityResourcePool accepts a slice of Resource Pool names to use in comparison against the Resource Pool for an entity associated with a TriggeredAlarm. For any matches, the TriggeredAlarm is marked as explicitly included. This will prevent later filtering from implicitly excluding the TriggeredAlarm, but will not stop explicit exclusions from "dropping" the TriggeredAlarm from further evaluation in the filtering pipeline.

func (*TriggeredAlarms) FilterByIncludedEntityType added in v0.17.0

func (tas *TriggeredAlarms) FilterByIncludedEntityType(includeTypes []string)

FilterByIncludedEntityType accepts a slice of entity type keywords to use in comparison against the entity type associated with a TriggeredAlarm. For any matches, the TriggeredAlarm is marked as explicitly included. This will prevent later filtering from implicitly excluding the TriggeredAlarm, but will not stop explicit exclusions from "dropping" the TriggeredAlarm from further evaluation in the filtering pipeline.

func (*TriggeredAlarms) FilterByIncludedNameSubstring added in v0.17.0

func (tas *TriggeredAlarms) FilterByIncludedNameSubstring(include []string)

FilterByIncludedNameSubstring accepts a slice of substrings to use in comparisons against TriggeredAlarm names. For any matches, the TriggeredAlarm is marked as explicitly included. This will prevent later filtering from implicitly excluding the TriggeredAlarm, but will not stop explicit exclusions from "dropping" the TriggeredAlarm from further evaluation in the filtering pipeline.

func (*TriggeredAlarms) FilterByIncludedStatus added in v0.17.0

func (tas *TriggeredAlarms) FilterByIncludedStatus(include []string)

FilterByIncludedStatus accepts a slice of ManagedEntityStatus keywords to use in comparisons against TriggeredAlarm statuses. For any matches, the TriggeredAlarm is marked as explicitly included. This will prevent later filtering from implicitly excluding the TriggeredAlarm, but will not stop explicit exclusions from "dropping" the TriggeredAlarm from further evaluation in the filtering pipeline.

func (TriggeredAlarms) FilterByKey added in v0.16.0

func (tas TriggeredAlarms) FilterByKey(key string) (TriggeredAlarm, error)

FilterByKey returns the matching TriggeredAlarm for the provided unique identifier (key) for a TriggeredAlarm.

func (TriggeredAlarms) HasCriticalState added in v0.16.0

func (tas TriggeredAlarms) HasCriticalState(evalExcluded bool) bool

HasCriticalState indicates whether the collection of TriggeredAlarms contains an alarm considered to be in a CRITICAL state. A boolean value is accepted which indicates whether TriggeredAlarm values marked for exclusion (during filtering) should also be considered. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) HasUnknownState added in v0.16.0

func (tas TriggeredAlarms) HasUnknownState(evalExcluded bool) bool

HasUnknownState indicates whether the collection of TriggeredAlarms contains an alarm considered to be in an UNKNOWN state. A boolean value is accepted which indicates whether TriggeredAlarm values marked for exclusion (during filtering) should also be considered. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) HasWarningState added in v0.16.0

func (tas TriggeredAlarms) HasWarningState(evalExcluded bool) bool

HasWarningState indicates whether the collection of TriggeredAlarms contains an alarm considered to be in a WARNING state. A boolean value is accepted which indicates whether TriggeredAlarm values marked for exclusion (during filter) should also be considered. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) IsOKState added in v0.16.0

func (tas TriggeredAlarms) IsOKState(evalExcluded bool) bool

IsOKState indicates whether all alarms in the collection of TriggeredAlarms are considered to be in an OK state. A boolean value is accepted to control whether all TriggeredAlarm values are evaluated or only those not marked for exclusion. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) Keys added in v0.16.0

func (tas TriggeredAlarms) Keys(evalAcknowledged bool, evalExcluded bool) []string

Keys returns a list of TriggeredAlarm keys or unique identifiers associated with each TriggeredAlarm in the collection. If specified, keys are also returned for acknowledged triggered alarms. Keys are returned in ascending order.

func (TriggeredAlarms) KeysExcluded added in v0.17.0

func (tas TriggeredAlarms) KeysExcluded() []string

KeysExcluded returns a list of TriggeredAlarm keys or unique identifiers associated with each TriggeredAlarm in the collection that has been excluded. Keys are returned in ascending order.

func (TriggeredAlarms) NumCriticalState added in v0.16.0

func (tas TriggeredAlarms) NumCriticalState(evalExcluded bool) int

NumCriticalState indicates how many TriggeredAlarms in the collection are considered to be in a CRITICAL state. A boolean value is accepted which indicates whether all TriggeredAlarm values are evaluated or only those not marked for exclusion. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) NumExcluded added in v0.17.0

func (tas TriggeredAlarms) NumExcluded() int

NumExcluded returns the number of TriggeredAlarms that have been implicitly or explicitly excluded.

func (TriggeredAlarms) NumExcludedFinal added in v0.17.0

func (tas TriggeredAlarms) NumExcludedFinal() int

NumExcludedFinal returns the number of TriggeredAlarms that have been explicitly excluded from further evaluation.

func (TriggeredAlarms) NumOKState added in v0.16.0

func (tas TriggeredAlarms) NumOKState(evalExcluded bool) int

NumOKState indicates how many TriggeredAlarms in the collection are considered to be in an OK state. A boolean value is accepted which indicates whether TriggeredAlarm values marked for exclusion (during filtering) should also be considered. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) NumUnknownState added in v0.16.0

func (tas TriggeredAlarms) NumUnknownState(evalExcluded bool) int

NumUnknownState indicates how many TriggeredAlarms in the collection are considered to be in an UNKNOWN state. A boolean value is accepted which indicates whether TriggeredAlarm values marked for exclusion (during filtering) should also be considered. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) NumWarningState added in v0.16.0

func (tas TriggeredAlarms) NumWarningState(evalExcluded bool) int

NumWarningState indicates how many TriggeredAlarms in the collection are considered to be in a WARNING state. A boolean value is accepted which indicates whether TriggeredAlarm values marked for exclusion (during filtering) should also be considered. The caller is responsible for filtering the collection; processing of inclusion or exclusion lists should be performed prior to calling this method.

func (TriggeredAlarms) ResourcePools added in v0.17.0

func (tas TriggeredAlarms) ResourcePools() []string

ResourcePools returns a list of ResourcePool names associated with the collection of TriggeredAlarms.

type VMHostDatastoresPairing added in v0.2.0

type VMHostDatastoresPairing struct {
	HostName       string
	DatastoreNames []string
}

VMHostDatastoresPairing collects HostSystem, VirtualMachine and Datastore name pairings.

type VMToMismatchedDatastoreNames added in v0.2.0

type VMToMismatchedDatastoreNames map[string]VMHostDatastoresPairing

VMToMismatchedDatastoreNames indexes VirtualMachine name to VMHostDatastoresPairing type. This index reflects mismatched Datastore names based on the current host for the VirtualMachine.

type VirtualMachinePowerCycleUptimeStatus added in v0.10.0

type VirtualMachinePowerCycleUptimeStatus struct {
	VMsCritical       []mo.VirtualMachine
	VMsWarning        []mo.VirtualMachine
	VMsOK             []mo.VirtualMachine
	WarningThreshold  int
	CriticalThreshold int
}

VirtualMachinePowerCycleUptimeStatus tracks VirtualMachines with power cycle uptimes that exceed specified thresholds while retaining a list of the VirtualMachines that have yet to exceed thresholds.

func GetVMPowerCycleUptimeStatusSummary added in v0.10.0

func GetVMPowerCycleUptimeStatusSummary(
	vms []mo.VirtualMachine,
	warningThreshold int,
	criticalThreshold int,
) VirtualMachinePowerCycleUptimeStatus

GetVMPowerCycleUptimeStatusSummary accepts a list of VirtualMachines and threshold values and generates a collection of VirtualMachines that exceeds given thresholds along with those given thresholds.

func (VirtualMachinePowerCycleUptimeStatus) BottomTenOK added in v0.12.0

BottomTenOK is a helper method that returns at most ten VMs with the lowest power cycle uptime values that have yet to exceed specified thresholds. Only powered on VMs are considered.

func (VirtualMachinePowerCycleUptimeStatus) TopTenOK added in v0.11.0

TopTenOK is a helper method that returns at most ten VMs with the highest power cycle uptime values that have yet to exceed specified thresholds.

func (VirtualMachinePowerCycleUptimeStatus) VMNames added in v0.10.0

VMNames returns a list of sorted VirtualMachine names which have exceeded specified power cycle uptime thresholds. VirtualMachines which have yet to exceed specified thresholds are not listed.

Jump to

Keyboard shortcuts

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