fabriziosalmi / proxmox-vm-autoscale

Automatically scale virtual machines resources on Proxmox hosts
MIT License
153 stars 6 forks source link

ERROR: Error processing VM 121 on host host1: '>' not supported between instances of 'tuple' and 'int' #10

Closed jmbenevise closed 4 weeks ago

jmbenevise commented 1 month ago

Describe the bug ERROR: Error processing VM 121 on host host1: '>' not supported between instances of 'tuple' and 'int'

Proxmox: Virtual Environment 8.2.7 proxmox-vm-autoscale: fresh install on LXC Debian 12

fabriziosalmi commented 4 weeks ago

Finally I have a full free weekend to handle issues 🤞🍻🎉

MatrixMagician commented 4 weeks ago

I have the same bug with the same VM ID :D

Oct 25 21:28:00 armitage python3[10213]: ERROR: Error processing VM 121 on host host1: '>' not supported between instances of 'tuple' and 'int'

Proxmox 8.2.7

fabriziosalmi commented 4 weeks ago

fixed

def get_resource_usage(self):
    """
    Retrieves the CPU and RAM usage of the VM using Proxmox host metrics.
    :return: Tuple of (cpu_usage, ram_usage) as percentages.
    """
    try:
        if not self.is_vm_running():
            return 0.0, 0.0  # Return zero usage if VM is not running

        # Get the current status of the VM
        command = f"qm status {self.vm_id} --verbose"
        output = self.ssh_client.execute_command(command)

        # Log the output for debugging purposes
        self.logger.debug(f"Raw output from 'qm status {self.vm_id} --verbose':\n{output}")

        # Parse RAM and CPU usage from the output
        success, cpu_usage = self._parse_cpu_usage(output)
        if not success:
            cpu_usage = 0.0  # Default to 0.0 if parsing fails

        ram_usage = self._parse_ram_usage(output)

        return cpu_usage, ram_usage

    except Exception as e:
        self.logger.error(f"Failed to get resource usage for VM {self.vm_id}: {str(e)}")
        raise