@wxt9861 I have many questions for you!
First: how to you monitor multiple hosts? If this component used - platform: esxi_stats
I know I could have multiple instances…
Second question: this is not working for me. What am I doing wrong?
Server running: ESXi-6.7.0-8169922-standard (VMware, Inc.)
Here is the exception I am getting:
Traceback (most recent call last):
File "/root/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
await entity.async_device_update(warning=False)
File "/root/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 378, in async_device_update
await self.async_update()
File "/root/.homeassistant/custom_components/esxi_stats/sensor.py", line 30, in async_update
await self.hass.data[DOMAIN_DATA]["client"].update_data()
File "/root/.homeassistant/custom_components/esxi_stats/__init__.py", line 169, in update_data
self.hass.data[DOMAIN_DATA]["vms"][vm_name] = get_vm_info(vm)
File "/root/.homeassistant/custom_components/esxi_stats/esxi.py", line 91, in get_vm_info
((vm_sum.quickStats.overallCpuUsage / vm_run.maxCpuUsage) * 100), 0
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
I added some logs and got this for _LOGGER.info(vm_sum)
(quickStats
towards the bottom):
2019-08-14 23:52:53 INFO (MainThread) [custom_components.esxi_stats.esxi] (vim.vm.Summary) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
vm = 'vim.VirtualMachine:1',
runtime = (vim.vm.RuntimeInfo) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
device = (vim.vm.DeviceRuntimeInfo) [
(vim.vm.DeviceRuntimeInfo) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
runtimeState = (vim.vm.DeviceRuntimeInfo.VirtualEthernetCardRuntimeState) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
vmDirectPathGen2Active = false,
vmDirectPathGen2InactiveReasonVm = (str) [],
vmDirectPathGen2InactiveReasonOther = (str) [
'vmNptIncompatibleNetwork'
],
vmDirectPathGen2InactiveReasonExtended = <unset>,
reservationStatus = <unset>,
attachmentStatus = '',
featureRequirement = (vim.vm.FeatureRequirement) []
},
key = 4000
}
],
host = 'vim.HostSystem:ha-host',
connectionState = 'connected',
powerState = 'poweredOn',
faultToleranceState = 'notConfigured',
dasVmProtection = <unset>,
toolsInstallerMounted = false,
suspendTime = <unset>,
bootTime = 2019-04-26T09:21:39.837314Z,
suspendInterval = 0,
question = <unset>,
memoryOverhead = <unset>,
maxCpuUsage = 9575,
maxMemoryUsage = 4096,
numMksConnections = 0,
recordReplayState = 'inactive',
cleanPowerOff = <unset>,
needSecondaryReason = <unset>,
onlineStandby = false,
minRequiredEVCModeKey = <unset>,
consolidationNeeded = false,
offlineFeatureRequirement = (vim.vm.FeatureRequirement) [
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.lm',
featureName = 'cpuid.lm',
value = 'Bool:Min:1'
}
],
featureRequirement = (vim.vm.FeatureRequirement) [
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.SSE3',
featureName = 'cpuid.SSE3',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.PCLMULQDQ',
featureName = 'cpuid.PCLMULQDQ',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.SSSE3',
featureName = 'cpuid.SSSE3',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.CMPXCHG16B',
featureName = 'cpuid.CMPXCHG16B',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.SSE41',
featureName = 'cpuid.SSE41',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.SSE42',
featureName = 'cpuid.SSE42',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.POPCNT',
featureName = 'cpuid.POPCNT',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.AES',
featureName = 'cpuid.AES',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.SS',
featureName = 'cpuid.SS',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.LAHF64',
featureName = 'cpuid.LAHF64',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.NX',
featureName = 'cpuid.NX',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.RDTSCP',
featureName = 'cpuid.RDTSCP',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.LM',
featureName = 'cpuid.LM',
value = 'Bool:Min:1'
},
(vim.vm.FeatureRequirement) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'cpuid.Intel',
featureName = 'cpuid.Intel',
value = 'Bool:Min:1'
}
],
featureMask = (vim.host.FeatureMask) [],
vFlashCacheAllocation = 0,
paused = false,
snapshotInBackground = false,
quiescedForkParent = <unset>,
instantCloneFrozen = false,
cryptoState = <unset>
},
guest = (vim.vm.Summary.GuestSummary) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
guestId = 'ubuntu64Guest',
guestFullName = 'Ubuntu Linux (64-bit)',
toolsStatus = 'toolsOk',
toolsVersionStatus = 'guestToolsUnmanaged',
toolsVersionStatus2 = 'guestToolsUnmanaged',
toolsRunningStatus = 'guestToolsRunning',
hostName = 'ubi1',
ipAddress = '192.168.1.209'
},
config = (vim.vm.Summary.ConfigSummary) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
name = 'ubi1',
template = false,
vmPathName = '[datastore1] ubi1/ubi1.vmx',
memorySizeMB = 4096,
cpuReservation = 0,
memoryReservation = 0,
numCpu = 4,
numEthernetCards = 1,
numVirtualDisks = 1,
uuid = '564d3649-de04-f415-674e-0677fac35318',
instanceUuid = '52055b81-7ef0-a171-2e7f-a424fbf5172c',
guestId = 'ubuntu64Guest',
guestFullName = 'Ubuntu Linux (64-bit)',
annotation = '',
product = <unset>,
installBootRequired = <unset>,
ftInfo = <unset>,
managedBy = <unset>,
tpmPresent = false,
numVmiopBackings = 0
},
storage = (vim.vm.Summary.StorageSummary) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
committed = 111785995493,
uncommitted = 500,
unshared = 111785995493,
timestamp = 2019-08-14T02:07:58.912464Z
},
quickStats = (vim.vm.Summary.QuickStats) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
overallCpuUsage = <unset>,
overallCpuDemand = <unset>,
guestMemoryUsage = <unset>,
hostMemoryUsage = -1,
guestHeartbeatStatus = 'green',
distributedCpuEntitlement = <unset>,
distributedMemoryEntitlement = <unset>,
staticCpuEntitlement = <unset>,
staticMemoryEntitlement = <unset>,
privateMemory = 0,
sharedMemory = <unset>,
swappedMemory = <unset>,
balloonedMemory = <unset>,
consumedOverheadMemory = <unset>,
ftLogBandwidth = <unset>,
ftSecondaryLatency = <unset>,
ftLatencyStatus = <unset>,
compressedMemory = <unset>,
uptimeSeconds = <unset>,
ssdSwappedMemory = <unset>
},
overallStatus = 'green',
customValue = (vim.CustomFieldsManager.Value) []
}
Sorry about the extra work. I’m not sure my ESXI server is returning quite the info I would need…