Documentation ¶
Overview ¶
Package vsphere provides various wrapper functions and types for interacting with and monitoring VMware vSphere environments.
Index ¶
- Constants
- Variables
- func AlarmsOneLineCheckSummary(stateLabel string, triggeredAlarms TriggeredAlarms, ...) string
- func AlarmsReport(c *vim25.Client, triggeredAlarms TriggeredAlarms, ...) string
- func AnnotateError(err error) error
- func CustomAttrKeyToValue(caKey int32, customValue []types.BaseCustomFieldValue) (string, error)
- func CustomAttrNameToKey(caName string, availableField []types.CustomFieldDef) (int32, error)
- func DatastoreIDsToNames(dsRefs []types.ManagedObjectReference, dss []mo.Datastore) []string
- func DatastoreUsageOneLineCheckSummary(stateLabel string, dsUsageSummary DatastoreUsageSummary) string
- func DatastoreUsageReport(c *vim25.Client, dsUsageSummary DatastoreUsageSummary) string
- func DisableLogging()
- func EnableLogging()
- func EntityStatusToNagiosState(entityStatus types.ManagedEntityStatus) (string, int)
- func ExceedsAge(snapshotCreated time.Time, days int) bool
- func ExceedsSize(snapshotSize int64, thresholdSize int64) bool
- func ExcludeVMsByName(allVMs []mo.VirtualMachine, ignoreList []string) ([]mo.VirtualMachine, int)
- func FilterDatastoresByID(dss []mo.Datastore, dsID string) (mo.Datastore, int, error)
- func FilterDatastoresByName(dss []mo.Datastore, dsName string) (mo.Datastore, int, error)
- func FilterHostSystemsByID(hss []mo.HostSystem, hsID string) (mo.HostSystem, int, error)
- func FilterHostSystemsByName(hss []mo.HostSystem, hsName string) (mo.HostSystem, int, error)
- func FilterNetworksByID(nets []mo.Network, netID string) (mo.Network, int, error)
- func FilterNetworksByName(nets []mo.Network, netName string) (mo.Network, int, error)
- func FilterVMsByDiskConsolidationState(vms []mo.VirtualMachine) ([]mo.VirtualMachine, int)
- func FilterVMsByID(vms []mo.VirtualMachine, vmID string) (mo.VirtualMachine, int, error)
- func FilterVMsByInteractiveQuestionStatus(vms []mo.VirtualMachine) ([]mo.VirtualMachine, int)
- func FilterVMsByName(vms []mo.VirtualMachine, vmName string) (mo.VirtualMachine, int, error)
- func FilterVMsByPowerCycleUptime(vms []mo.VirtualMachine, warningThreshold int, criticalThreshold int) ([]mo.VirtualMachine, int)
- func FilterVMsByPowerState(vms []mo.VirtualMachine, includePoweredOff bool) ([]mo.VirtualMachine, int)
- func FilterVMsWithOldHardware(vms []mo.VirtualMachine, hwIndex HardwareVersionsIndex) ([]mo.VirtualMachine, int)
- func FilterVMsWithSnapshots(vms []mo.VirtualMachine) ([]mo.VirtualMachine, int)
- func FilterVMsWithToolsIssues(vms []mo.VirtualMachine, includePoweredOff bool) ([]mo.VirtualMachine, int)
- func GetDatacenters(ctx context.Context, c *vim25.Client, dcNames []string, propsSubset bool) ([]mo.Datacenter, error)
- func GetDatastoreByName(ctx context.Context, c *vim25.Client, dsName string, datacenter string, ...) (mo.Datastore, error)
- func GetDatastores(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.Datastore, error)
- func GetEligibleRPs(ctx context.Context, c *vim25.Client, includeRPs []string, excludeRPs []string, ...) ([]mo.ResourcePool, error)
- func GetHostSystemByName(ctx context.Context, c *vim25.Client, hsName string, datacenter string, ...) (mo.HostSystem, error)
- func GetHostSystems(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.HostSystem, error)
- func GetHostSystemsTotalMemory(ctx context.Context, c *vim25.Client, excludeOffline bool) (int64, error)
- func GetNetworkByName(ctx context.Context, c *vim25.Client, netName string, datacenter string, ...) (mo.Network, error)
- func GetNetworks(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.Network, error)
- func GetObjectCAVal(caName string, obj mo.ManagedEntity) (string, error)
- func GetRPByName(ctx context.Context, c *vim25.Client, rpName string, datacenter string, ...) (mo.ResourcePool, error)
- func GetVMByName(ctx context.Context, c *vim25.Client, vmName string, datacenter string, ...) (mo.VirtualMachine, error)
- func GetVMToolsStatusSummary(vms []mo.VirtualMachine) nagios.ServiceState
- func GetVMs(ctx context.Context, c *vim25.Client, propsSubset bool) ([]mo.VirtualMachine, error)
- func GetVMsFromContainer(ctx context.Context, c *vim25.Client, propsSubset bool, ...) ([]mo.VirtualMachine, error)
- func GetVMsFromDatastore(ctx context.Context, c *vim25.Client, ds mo.Datastore, propsSubset bool) ([]mo.VirtualMachine, error)
- func H2D2VMsOneLineCheckSummary(stateLabel string, evaluatedVMs []mo.VirtualMachine, ...) string
- func H2D2VMsReport(c *vim25.Client, h2dIdx HostToDatastoreIndex, allVMs []mo.VirtualMachine, ...) string
- func HostSystemCPUUsageOneLineCheckSummary(stateLabel string, hsVMs []mo.VirtualMachine, ...) string
- func HostSystemCPUUsageReport(c *vim25.Client, hsVMs []mo.VirtualMachine, ...) string
- func HostSystemMemoryUsageOneLineCheckSummary(stateLabel string, hsVMs []mo.VirtualMachine, ...) string
- func HostSystemMemoryUsageReport(c *vim25.Client, hsVMs []mo.VirtualMachine, ...) string
- func ListVMSnapshots(vm mo.VirtualMachine, w io.Writer)
- func Login(ctx context.Context, server string, port int, trustCert bool, username string, ...) (*govmomi.Client, error)
- func MemoryUsedPercentage(aggregateMemoryUsageInBytesInBytes int64, maxMemoryUsageInBytes int64) float64
- func RPMemoryUsageOneLineCheckSummary(stateLabel string, aggregateMemoryUsageInBytes int64, ...) string
- func ResourcePoolsMemoryReport(c *vim25.Client, aggregateMemoryUsageInBytes int64, ...) string
- func SnapshotsAgeOneLineCheckSummary(stateLabel string, snapshotSets SnapshotSummarySets, ...) string
- func SnapshotsAgeReport(c *vim25.Client, snapshotSummarySets SnapshotSummarySets, ...) string
- func SnapshotsCountOneLineCheckSummary(stateLabel string, snapshotSets SnapshotSummarySets, ...) string
- func SnapshotsCountReport(c *vim25.Client, snapshotSummarySets SnapshotSummarySets, ...) string
- func SnapshotsSizeOneLineCheckSummary(stateLabel string, snapshotSets SnapshotSummarySets, ...) string
- func SnapshotsSizeReport(c *vim25.Client, snapshotSummarySets SnapshotSummarySets, ...) string
- func TriggerEntityStateReload(ctx context.Context, c *vim25.Client, entities []mo.ManagedEntity) error
- func VMDiskConsolidationOneLineCheckSummary(stateLabel string, evaluatedVMs []mo.VirtualMachine, ...) string
- func VMDiskConsolidationReport(c *vim25.Client, allVMs []mo.VirtualMachine, evaluatedVMs []mo.VirtualMachine, ...) string
- func VMInteractiveQuestionOneLineCheckSummary(stateLabel string, evaluatedVMs []mo.VirtualMachine, ...) string
- func VMInteractiveQuestionReport(c *vim25.Client, allVMs []mo.VirtualMachine, evaluatedVMs []mo.VirtualMachine, ...) string
- func VMNames(vmsList []mo.VirtualMachine) []string
- func VMPowerCycleUptimeOneLineCheckSummary(stateLabel string, evaluatedVMs []mo.VirtualMachine, ...) string
- func VMPowerCycleUptimeReport(c *vim25.Client, allVMs []mo.VirtualMachine, evaluatedVMs []mo.VirtualMachine, ...) string
- func VMToolsOneLineCheckSummary(stateLabel string, evaluatedVMs []mo.VirtualMachine, ...) string
- func VMToolsReport(c *vim25.Client, allVMs []mo.VirtualMachine, evaluatedVMs []mo.VirtualMachine, ...) string
- func ValidateDCs(ctx context.Context, c *vim25.Client, datacenters []string) error
- func ValidateRPs(ctx context.Context, c *vim25.Client, includeRPs []string, excludeRPs []string) error
- func VirtualCPUsOneLineCheckSummary(stateLabel string, vCPUsAllocated int32, vCPUsMax int, ...) string
- func VirtualCPUsReport(c *vim25.Client, vCPUsAllocated int32, vCPUsMax int, ...) string
- func VirtualHardwareOneLineCheckSummary(stateLabel string, hwvIndex HardwareVersionsIndex, minHardwareVersion int, ...) string
- func VirtualHardwareReport(c *vim25.Client, hwvIndex HardwareVersionsIndex, minHardwareVersion int, ...) string
- type AlarmEntity
- type CPUSpeed
- type DatastoreIDToNameIndex
- type DatastoreUsageSummary
- type DatastoreVM
- type DatastoreVMs
- type DatastoreWithCA
- type ErrHostDatastoreIdxIDToNameLookupFailed
- type HardwareVersion
- type HardwareVersions
- type HardwareVersionsIndex
- type HostDatastoresPairing
- type HostSystemCPUSummary
- type HostSystemMemorySummary
- type HostToDatastoreIndex
- func (hdi HostToDatastoreIndex) DatastoreIDToName(dsID string) (string, error)
- func (hdi HostToDatastoreIndex) DatastoreIDToNameIndex() DatastoreIDToNameIndex
- func (hdi HostToDatastoreIndex) DatastoreNames() []string
- func (hdi HostToDatastoreIndex) IsDatastoreIDInIndex(dsID string) bool
- func (hdi HostToDatastoreIndex) ValidateVirtualMachinePairings(vmHostID string, allDatastores []mo.Datastore, ...) ([]string, error)
- type HostWithCA
- type PairingCustomAttribute
- type SnapshotSummary
- func (ss SnapshotSummary) Age() string
- func (ss SnapshotSummary) AgeDays() float64
- func (ss SnapshotSummary) IsAgeCriticalState() bool
- func (ss SnapshotSummary) IsAgeExceeded(days int) bool
- func (ss SnapshotSummary) IsAgeWarningState() bool
- func (ss SnapshotSummary) IsCriticalState() bool
- func (ss SnapshotSummary) IsSizeCriticalState() bool
- func (ss SnapshotSummary) IsSizeExceeded(sizeGB int) bool
- func (ss SnapshotSummary) IsSizeWarningState() bool
- func (ss SnapshotSummary) IsWarningState() bool
- func (ss SnapshotSummary) SizeHR() string
- type SnapshotSummarySet
- func (sss SnapshotSummarySet) ExceedsAge(days int) int
- func (sss SnapshotSummarySet) ExceedsSize(sizeGB int) int
- func (sss SnapshotSummarySet) IsAgeCriticalState() bool
- func (sss SnapshotSummarySet) IsAgeWarningState() bool
- func (sss SnapshotSummarySet) IsCountCriticalState() bool
- func (sss SnapshotSummarySet) IsCountWarningState() bool
- func (sss SnapshotSummarySet) IsCriticalState() bool
- func (sss SnapshotSummarySet) IsSizeCriticalState() bool
- func (sss SnapshotSummarySet) IsSizeWarningState() bool
- func (sss SnapshotSummarySet) IsWarningState() bool
- func (sss SnapshotSummarySet) Size() int64
- func (sss SnapshotSummarySet) SizeHR() string
- type SnapshotSummarySets
- func (sss SnapshotSummarySets) AgeCriticalSnapshots() (int, int)
- func (sss SnapshotSummarySets) AgeWarningSnapshots() (int, int)
- func (sss SnapshotSummarySets) CountCriticalSnapshots() (int, int)
- func (sss SnapshotSummarySets) CountWarningSnapshots() (int, int)
- func (sss SnapshotSummarySets) ExceedsAge(days int) (int, int)
- func (sss SnapshotSummarySets) ExceedsSize(sizeGB int) (int, int)
- func (sss SnapshotSummarySets) ExcessSnapshots(count int) (int, int, int)
- func (sss SnapshotSummarySets) FilterByCount(count int) SnapshotSummarySets
- func (sss SnapshotSummarySets) HasNotYetExceededAge(days int) bool
- func (sss SnapshotSummarySets) HasNotYetExceededCount(count int) bool
- func (sss SnapshotSummarySets) HasNotYetExceededSize(sizeGB int) bool
- func (sss SnapshotSummarySets) IsAgeCriticalState() bool
- func (sss SnapshotSummarySets) IsAgeWarningState() bool
- func (sss SnapshotSummarySets) IsCountCriticalState() bool
- func (sss SnapshotSummarySets) IsCountWarningState() bool
- func (sss SnapshotSummarySets) IsCriticalState() bool
- func (sss SnapshotSummarySets) IsSizeCriticalState() bool
- func (sss SnapshotSummarySets) IsSizeWarningState() bool
- func (sss SnapshotSummarySets) IsWarningState() bool
- func (sss SnapshotSummarySets) SizeCriticalSnapshots() (int, int)
- func (sss SnapshotSummarySets) SizeWarningSnapshots() (int, int)
- func (sss SnapshotSummarySets) Snapshots() int
- type SnapshotThresholds
- type SnapshotsIndex
- type TriggeredAlarm
- type TriggeredAlarmFilters
- type TriggeredAlarms
- func (tas TriggeredAlarms) CountPerDatacenter() map[string]int
- func (tas TriggeredAlarms) Datacenters() []string
- func (tas *TriggeredAlarms) Filter(filters TriggeredAlarmFilters)
- func (tas *TriggeredAlarms) FilterByAcknowledgedState(includeAcknowledged bool)
- func (tas *TriggeredAlarms) FilterByExcludedDescriptionSubstring(exclude []string)
- func (tas *TriggeredAlarms) FilterByExcludedEntityResourcePool(exclude []string)
- func (tas *TriggeredAlarms) FilterByExcludedEntityType(excludeTypes []string)
- func (tas *TriggeredAlarms) FilterByExcludedNameSubstring(exclude []string)
- func (tas *TriggeredAlarms) FilterByExcludedStatus(exclude []string)
- func (tas *TriggeredAlarms) FilterByIncludedDescriptionSubstring(include []string)
- func (tas *TriggeredAlarms) FilterByIncludedEntityResourcePool(include []string)
- func (tas *TriggeredAlarms) FilterByIncludedEntityType(includeTypes []string)
- func (tas *TriggeredAlarms) FilterByIncludedNameSubstring(include []string)
- func (tas *TriggeredAlarms) FilterByIncludedStatus(include []string)
- func (tas TriggeredAlarms) FilterByKey(key string) (TriggeredAlarm, error)
- func (tas TriggeredAlarms) HasCriticalState(evalExcluded bool) bool
- func (tas TriggeredAlarms) HasUnknownState(evalExcluded bool) bool
- func (tas TriggeredAlarms) HasWarningState(evalExcluded bool) bool
- func (tas TriggeredAlarms) IsOKState(evalExcluded bool) bool
- func (tas TriggeredAlarms) Keys(evalAcknowledged bool, evalExcluded bool) []string
- func (tas TriggeredAlarms) KeysExcluded() []string
- func (tas TriggeredAlarms) NumCriticalState(evalExcluded bool) int
- func (tas TriggeredAlarms) NumExcluded() int
- func (tas TriggeredAlarms) NumExcludedFinal() int
- func (tas TriggeredAlarms) NumOKState(evalExcluded bool) int
- func (tas TriggeredAlarms) NumUnknownState(evalExcluded bool) int
- func (tas TriggeredAlarms) NumWarningState(evalExcluded bool) int
- func (tas TriggeredAlarms) ResourcePools() []string
- type VMHostDatastoresPairing
- type VMToMismatchedDatastoreNames
- type VirtualMachinePowerCycleUptimeStatus
Constants ¶
const ( MgObjRefTypeFolder string = "Folder" MgObjRefTypeDatacenter string = "Datacenter" MgObjRefTypeComputeResource string = "ComputeResource" MgObjRefTypeResourcePool string = "ResourcePool" MgObjRefTypeHostSystem string = "HostSystem" MgObjRefTypeVirtualMachine string = "VirtualMachine" MgObjRefTypeVirtualApp string = "VirtualApp" )
Managed Object Reference types
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
const CustomAttributeValNotSet string = "NotSet"
CustomAttributeValNotSet is used to indicate that a Custom Attribute value was not set on an object.
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 ¶
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.
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.
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.
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.
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.
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.
var ErrDatacenterNotFound = errors.New("specified Datacenters not found")
ErrDatacenterNotFound indicates that one or more specified datacenters were not located.
var ErrDatastoreUsageThresholdCrossed = errors.New("datastore usage exceeds specified threshold")
ErrDatastoreUsageThresholdCrossed indicates that specified resource pools have exceeded a given threshold
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.
var ErrHostSystemCPUUsageThresholdCrossed = errors.New("host CPU usage exceeds specified threshold")
ErrHostSystemCPUUsageThresholdCrossed indicates that specified host CPU usage has exceeded a given threshold
ErrHostSystemHardwarePropertiesUnavailable indicates that specified host hardware properties are unavailable. This is likely due to permission issues for the service account or a shallow host properties retrieval request (coding error).
var ErrHostSystemMemoryUsageThresholdCrossed = errors.New("host memory usage exceeds specified threshold")
ErrHostSystemMemoryUsageThresholdCrossed indicates that specified host memory usage has exceeded a given threshold
var ErrResourcePoolMemoryUsageThresholdCrossed = errors.New("memory usage exceeds specified threshold")
ErrResourcePoolMemoryUsageThresholdCrossed indicates that specified resource pools have exceeded a given threshold
var ErrRuntimeTimeoutReached = errors.New("plugin runtime exceeded specified timeout value")
ErrRuntimeTimeoutReached indicates that plugin runtime exceeded specified timeout value.
var ErrSnapshotAgeThresholdCrossed = errors.New("snapshot exceeds specified age threshold")
ErrSnapshotAgeThresholdCrossed indicates that a snapshot is older than a specified age threshold
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.
var ErrSnapshotSizeThresholdCrossed = errors.New("snapshot exceeds specified size threshold")
ErrSnapshotSizeThresholdCrossed indicates that a snapshot is larger than a specified size threshold
var ErrVCPUsUsageThresholdCrossed = errors.New("vCPUS allocation exceeds specified threshold")
ErrVCPUsUsageThresholdCrossed indicates that specified vCPUs allocation has exceeded a given threshold
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.
var ErrVirtualHardwareOutdatedVersionsFound = errors.New("outdated hardware versions found")
ErrVirtualHardwareOutdatedVersionsFound indicates that hardware versions older than the minimum have been found.
var ErrVirtualMachineDiskConsolidationNeeded = errors.New("disk consolidation needed")
ErrVirtualMachineDiskConsolidationNeeded indicates that disk consolidation is needed for one or more Virtual Machines.
var ErrVirtualMachineInteractiveResponseNeeded = errors.New("interactive response needed")
ErrVirtualMachineInteractiveResponseNeeded indicates that an interactive response is needed for one or more Virtual Machines.
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 AnnotateError ¶ added in v0.25.0
AnnotateError is a helper function used to add additional human-readable explanation for errors commonly emitted by dependencies. This function receives an error, evaluates whether it contains specific errors in its chain and then (potentially) appends additional details for later use. This updated error chain is returned to the caller, preserving the original wrapped error. The original error is returned unmodified if no annotations were deemed necessary.
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, 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
ExceedsAge indicates whether a given snapshot creation date is older than the specified number of days.
func ExceedsSize ¶ added in v0.5.0
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, int)
ExcludeVMsByName receives a collection of VirtualMachines and a list of VMs that should be ignored. A new collection minus ignored VirtualMachines is returned along with the number of VMs that were excluded.
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 FilterDatastoresByID ¶ added in v0.21.0
FilterDatastoresByID 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. The matching Datastore is returned along with the number of Datastores that were excluded.
func FilterDatastoresByName ¶ added in v0.21.0
FilterDatastoresByName 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. The matching Datastore is returned along with the number of Datastores that were excluded.
func FilterHostSystemsByID ¶ added in v0.21.0
func FilterHostSystemsByID(hss []mo.HostSystem, hsID string) (mo.HostSystem, int, error)
FilterHostSystemsByID 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. The matching HostSystem is returned along with the number of HostSystems that were excluded.
func FilterHostSystemsByName ¶ added in v0.21.0
func FilterHostSystemsByName(hss []mo.HostSystem, hsName string) (mo.HostSystem, int, error)
FilterHostSystemsByName 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. The matching HostSystem is returned along with the number of HostSystems that were excluded.
func FilterNetworksByID ¶ added in v0.21.0
FilterNetworksByID 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. The matching Network is returned along with the number of Networks that were excluded.
func FilterNetworksByName ¶ added in v0.21.0
FilterNetworksByName 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. The matching Network is returned along with the number of Networks that were excluded.
func FilterVMsByDiskConsolidationState ¶ added in v0.23.0
func FilterVMsByDiskConsolidationState(vms []mo.VirtualMachine) ([]mo.VirtualMachine, int)
FilterVMsByDiskConsolidationState accepts a collection of VirtualMachines and evaluates whether their ConsolidationNeeded flag is set. This function assumes that the caller has already initiated a "reload" of each VirtualMachine in order to retrieve the most current status of its ConsolidationNeeded field. If the collection of provided VirtualMachines is empty, an empty collection is returned. The collection is returned along with the number of VirtualMachines that were excluded.
func FilterVMsByID ¶ added in v0.21.0
func FilterVMsByID(vms []mo.VirtualMachine, vmID string) (mo.VirtualMachine, int, error)
FilterVMsByID 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. The matching VirtualMachine is returned along with the number of VirtualMachines that were excluded.
func FilterVMsByInteractiveQuestionStatus ¶ added in v0.23.0
func FilterVMsByInteractiveQuestionStatus(vms []mo.VirtualMachine) ([]mo.VirtualMachine, int)
FilterVMsByInteractiveQuestionStatus accepts a collection of VirtualMachines and evaluates whether their Question flag is set. If the collection of provided VirtualMachines is empty, an empty collection is returned. The collection is returned along with the number of VirtualMachines that were excluded.
func FilterVMsByName ¶ added in v0.21.0
func FilterVMsByName(vms []mo.VirtualMachine, vmName string) (mo.VirtualMachine, int, error)
FilterVMsByName 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. The matching VirtualMachine is returned along with the number of VirtualMachines that were excluded.
func FilterVMsByPowerCycleUptime ¶ added in v0.10.0
func FilterVMsByPowerCycleUptime(vms []mo.VirtualMachine, warningThreshold int, criticalThreshold int) ([]mo.VirtualMachine, int)
FilterVMsByPowerCycleUptime filters the provided collection of VirtualMachines to just those with WARNING or CRITICAL values based on provided thresholds. The collection is returned along with the number of VirtualMachines that were excluded.
func FilterVMsByPowerState ¶
func FilterVMsByPowerState(vms []mo.VirtualMachine, includePoweredOff bool) ([]mo.VirtualMachine, int)
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. The collection is returned along with the number of VirtualMachines that were excluded.
func FilterVMsWithOldHardware ¶
func FilterVMsWithOldHardware(vms []mo.VirtualMachine, hwIndex HardwareVersionsIndex) ([]mo.VirtualMachine, int)
FilterVMsWithOldHardware filters the provided collection of VirtualMachines to just those with older hardware versions. The collection is returned along with the number of VirtualMachines that were excluded.
func FilterVMsWithSnapshots ¶ added in v0.4.0
func FilterVMsWithSnapshots(vms []mo.VirtualMachine) ([]mo.VirtualMachine, int)
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. The collection is returned along with the number of VirtualMachines that were excluded.
func FilterVMsWithToolsIssues ¶
func FilterVMsWithToolsIssues(vms []mo.VirtualMachine, includePoweredOff bool) ([]mo.VirtualMachine, int)
FilterVMsWithToolsIssues filters the provided collection of VirtualMachines to just those with non-OK status, unless powered off VMs are also evaluated. In that case, ignore any powered off VirtualMachines with VMware Tools in a "not running" state which are otherwise current or unmanaged. The collection is returned along with the number of VirtualMachines that were excluded.
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 ¶
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 in bytes. 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 ¶
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) nagios.ServiceState
GetVMToolsStatusSummary accepts a collection of VirtualMachines and checks the VMware Tools status for each one, providing an overall Nagios state label and exit code for the collection.
NOTE: This function does *NOT* differentiate between VirtualMachines that are powered on and those that are powered off. If only powered on VirtualMachines should be evaluated, the caller should perform this filtering first before passing the collection to this function.
func GetVMs ¶
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, VirtualApp 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( aggregateMemoryUsageInBytesInBytes int64, maxMemoryUsageInBytes int64, ) 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, aggregateMemoryUsageInBytes int64, maxMemoryUsageInBytes int64, clusterMemoryInBytes 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, aggregateMemoryUsageInBytes int64, maxMemoryUsageInBytes int64, clusterMemoryInBytes 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 TriggerEntityStateReload ¶ added in v0.23.0
func TriggerEntityStateReload(ctx context.Context, c *vim25.Client, entities []mo.ManagedEntity) error
TriggerEntityStateReload accepts a context, a client and a collection of ManagedEntity values whose state should be reloaded. This function is used when we need to ensure that we are working with the very latest state data for a vSphere object.
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
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 DatastoreIDToNameIndex ¶ added in v0.2.0
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 VMs DatastoreVMs }
DatastoreUsageSummary tracks usage details for a specific Datastore.
func NewDatastoreUsageSummary ¶ added in v0.3.0
func NewDatastoreUsageSummary( ctx context.Context, c *vim25.Client, ds mo.Datastore, criticalThreshold int, warningThreshold int, ) (DatastoreUsageSummary, error)
NewDatastoreUsageSummary receives a Datastore and generates summary information used to determine if usage levels have crossed user-specified thresholds. func NewDatastoreUsageSummary(ds mo.Datastore, dsVMs []mo.VirtualMachine, criticalThreshold int, warningThreshold int) DatastoreUsageSummary {
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 DatastoreVM ¶ added in v0.21.0
type DatastoreVM struct { // Name is the display name of the VirtualMachine. Name string // VMSize is the human readable or formatted size of the VirtualMachine. VMSize string // DatastoreUsage is the human readable or formatted percentage of the // Datastore space consumed by this VirtualMachine. DatastoreUsage string // PowerState tracks the current power state for a VirtualMachine. PowerState types.VirtualMachinePowerState // DatastoreMOID is the MOID or MoRef ID for the Datastore where this // VirtualMachine resides. DatastoreMOID types.ManagedObjectReference }
DatastoreVM is a summary of details for a VirtualMachine found on a specific datastore.
type DatastoreVMs ¶ added in v0.21.0
type DatastoreVMs []DatastoreVM
DatastoreVMs provides an overview of all (visible) VirtualMachines residing on a specific Datastore.
func DatastoreVMsSummary ¶ added in v0.21.0
func DatastoreVMsSummary(ds mo.Datastore, vms []mo.VirtualMachine) DatastoreVMs
DatastoreVMsSummary evaluates provided Datastore and collection of VirtualMachines and provides a basic human readable / formatted summary of VirtualMachine details.
func (DatastoreVMs) NumVMsPoweredOff ¶ added in v0.21.0
func (dsVMs DatastoreVMs) NumVMsPoweredOff() int
NumVMsPoweredOff indicates how many VirtualMachines on a specific Datastore are powered off OR suspended.
func (DatastoreVMs) NumVMsPoweredOn ¶ added in v0.21.0
func (dsVMs DatastoreVMs) NumVMsPoweredOn() int
NumVMsPoweredOn indicates how many VirtualMachines on a specific Datastore are powered on.
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.
func GetDatastoresWithCA ¶ added in v0.22.0
func GetDatastoresWithCA(allDS []mo.Datastore, ignoredDatastoreNames []string, dsCustomAttributeName string, ignoreMissingCA bool) ([]DatastoreWithCA, error)
GetDatastoresWithCA receives a collection of Datastores, a list of datastore names that should be ignored or excluded from evaluation, a Custom Attribute to filter Datastores by and a boolean flag indicating whether datastores missing a Custom Attribute should be ignored. A collection of DatastoreWithCA is returned along with an error (if applicable).
type ErrHostDatastoreIdxIDToNameLookupFailed ¶ added in v0.2.0
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
func (dsIDFail ErrHostDatastoreIdxIDToNameLookupFailed) Error() string
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, hardwareVersionsIdx HardwareVersionsIndex, ) (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 (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 ¶
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 NewHardwareVersionsIndex ¶ added in v0.26.0
func NewHardwareVersionsIndex(vms []mo.VirtualMachine) (HardwareVersionsIndex, error)
NewHardwareVersionsIndex creates an index of hardware version to number of Virtual Machines present with that hardware version. An error is returned if there is an issue accessing a Virtual Machine's configuration.
func (HardwareVersionsIndex) Count ¶
func (hvi HardwareVersionsIndex) Count() int
Count returns the number of hardware versions stored in the index.
func (HardwareVersionsIndex) Newest ¶
func (hvi HardwareVersionsIndex) Newest() HardwareVersion
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 ¶
func (hvi HardwareVersionsIndex) Oldest() HardwareVersion
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, error)
NewHostSystemCPUUsageSummary receives a HostSystem and generates summary information used to determine if usage levels have crossed user-specified thresholds. If required information is not accessible (e.g., permissions issue for service account) an error is returned indicating this.
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, error)
NewHostSystemMemoryUsageSummary receives a HostSystem and generates summary information used to determine if usage levels have crossed user-specified thresholds. If required information is not accessible (e.g., permissions issue for service account) an error is returned indicating this.
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 index is created using each ESXi host's MOID as the key and a HostDatastoresPairing type as the value. This effectively provides a mapping between a host and all datastores with matching specified custom attribute. If no datastores are found with a matching specified custom attribute, an empty list of datastores is recorded for the host to indicate this.
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 all Datastores to evaluate, the 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.
func GetHostsWithCA ¶ added in v0.22.0
func GetHostsWithCA(allHosts []mo.HostSystem, hostCustomAttributeName string, ignoreMissingCA bool) ([]HostWithCA, error)
GetHostsWithCA receives a collection of Hosts, a Custom Attribute to filter Hosts by and a boolean flag indicating whether Hosts missing a Custom Attribute should be ignored. A collection of HostWithCA is returned along with an error (if applicable).
type PairingCustomAttribute ¶ added in v0.2.0
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 but NOT the CRITICAL age 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 but NOT the CRITICAL size 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 but NOT age or size CRITICAL 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, but NOT the age CRITICAL 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, but NOT the snapshots count CRITICAL 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, but NOT the size CRITICAL threshold.
func (SnapshotSummarySet) IsWarningState ¶ added in v0.4.0
func (sss SnapshotSummarySet) IsWarningState() bool
IsWarningState indicates whether the snapshot set has snapshots which have an age, size or count WARNING state.
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) AgeCriticalSnapshots ¶ added in v0.25.0
func (sss SnapshotSummarySets) AgeCriticalSnapshots() (int, int)
AgeCriticalSnapshots returns the number of sets and number of snapshots from all of those sets that are older than the specified CRITICAL age threshold. This effectively provides the number of VirtualMachines with (age) CRITICAL snapshots and the total (age) CRITICAL snapshots across all VirtualMachines.
func (SnapshotSummarySets) AgeWarningSnapshots ¶ added in v0.25.0
func (sss SnapshotSummarySets) AgeWarningSnapshots() (int, int)
AgeWarningSnapshots returns the number of sets and number of snapshots from all of those sets that are older than the specified WARNING age threshold but have *not* yet crossed the CRITICAL threshold. This effectively provides the number of VirtualMachines with (age) WARNING snapshots and the total (age) WARNING snapshots across all VirtualMachines.
func (SnapshotSummarySets) CountCriticalSnapshots ¶ added in v0.25.0
func (sss SnapshotSummarySets) CountCriticalSnapshots() (int, int)
CountCriticalSnapshots returns the number of sets and number of snapshots from all of those sets that are greater than the specified CRITICAL count threshold. This effectively provides the number of VirtualMachines with CRITICAL snapshots and the total CRITICAL snapshots across all VirtualMachines.
func (SnapshotSummarySets) CountWarningSnapshots ¶ added in v0.25.0
func (sss SnapshotSummarySets) CountWarningSnapshots() (int, int)
CountWarningSnapshots returns the number of sets and number of snapshots from all of those sets that are greater than the specified WARNING age threshold but have *not* yet crossed the CRITICAL threshold. This effectively provides the number of VirtualMachines with WARNING snapshots and the total WARNING snapshots across all VirtualMachines.
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, but NOT the age CRITICAL 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, but NOT the count CRITICAL 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, but NOT the size CRITICAL 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, but NOT CRITICAL thresholds.
func (SnapshotSummarySets) SizeCriticalSnapshots ¶ added in v0.25.0
func (sss SnapshotSummarySets) SizeCriticalSnapshots() (int, int)
SizeCriticalSnapshots returns the number of sets and number of snapshots from all of those sets whose cumulative size is larger than the specified CRITICAL size threshold. This effectively provides the number of VirtualMachines with (size) CRITICAL snapshots and the total (size) CRITICAL snapshots across all VirtualMachines.
func (SnapshotSummarySets) SizeWarningSnapshots ¶ added in v0.25.0
func (sss SnapshotSummarySets) SizeWarningSnapshots() (int, int)
SizeWarningSnapshots returns the number of sets and number of snapshots from all of those sets whose cumulative size is larger than the specified WARNING age threshold but have *not* yet crossed the CRITICAL threshold. This effectively provides the number of VirtualMachines with (size) WARNING snapshots and the total (size) WARNING snapshots across all VirtualMachines.
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
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.
func GetVMDatastorePairingIssues ¶ added in v0.22.0
func GetVMDatastorePairingIssues(vms []mo.VirtualMachine, h2dIdx HostToDatastoreIndex, dss []mo.Datastore, ignoredDatastoreNames []string) (VMToMismatchedDatastoreNames, error)
GetVMDatastorePairingIssues receives a list of VirtualMachines and a HostToDatastoreIndex to evaluate each VirtualMachine by. A VMHostDatastoresPairing index is returned noting improperly paired VirtualMachines (if any) and an error (if applicable).
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
func (vpcs VirtualMachinePowerCycleUptimeStatus) BottomTenOK() []mo.VirtualMachine
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
func (vpcs VirtualMachinePowerCycleUptimeStatus) TopTenOK() []mo.VirtualMachine
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
func (vpcs VirtualMachinePowerCycleUptimeStatus) VMNames() string
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.