wxt9861 / esxi_stats

ESXi component for Home Assistant
MIT License
145 stars 40 forks source link

Memory_used_mb vs memory_allocated_mb vs real life #86

Closed lukaszzyla closed 10 months ago

lukaszzyla commented 12 months ago

Hi, I am not sure whether this is a bug or intended operation, but it leaves me somehow unhappy. In my case, both memory sensors (allocated and used) show almost same values with mem used being slightly bigger. This results in having 2 memory reading, but none close to what the vms really use: Like here: ESXI_STATS: name: chw-haos status: green state: running uptime_hours: 232 cpu_count: 2 cpu_use_pct: 2.49 memory_allocated_mb: 4096 memory_used_mb: 4129 used_space_gb: 8.67 tools_status: toolsOk guest_os: Other 5.x Linux (64-bit) guest_ip: x.x.x.x snapshots: 0 unit_of_measurement: Cpu Use Pct friendly_name: ESXi vm chw-haos

While real memory use from within the vm is 0.6GB image

This is not HA only - the same values I get for ubuntu vm: name: chw_ubuntu status: green state: running uptime_hours: 329.3 cpu_count: 16 cpu_use_pct: 0.46 memory_allocated_mb: 16384 memory_used_mb: 16495 used_space_gb: 80.11 tools_status: toolsOk guest_os: Ubuntu Linux (64-bit)

wxt9861 commented 11 months ago

memory_allocated_mb - shows how much memory you have allocated to the virtual machine, it is similar to cpu_count which shows how many CPUs are allocated to the virtual machine.

memory_used_mb - shows host memory utilization statistics, in MB. This is also known as consumed host memory. This is between 0 and the configured resource limit. Valid while the virtual machine is running. This includes the overhead memory of the VM.

So as you can see, these are 2 different stats. memory_used_mb is runtime specific, while memory_allocated_mb is a configuration item.

That being said, you also have to keep in mind, memory_used_mb are statistics reported from the host perspective, it is not reporting memory usages inside of the VM.

0.7.0 beta introduces another memory statistic: memory_active_mb - shows guest memory utilization statistics, in MB. This is also known as active guest memory. The number can be between 0 and the configured memory size of the virtual machine. Valid while the virtual machine is running.