How to calculate the Power/Energy Consumption of each Host

  • The power consumption is calculated for the amount of resources utilized by the Host. Here the power consumption is calculated based on the amount of cpu resource utilized by each Host.
  • Power Model:

    public class ModelPower extends PowerModelCubic{
    double max=1; //Maximum amount of power a host can utilize
    double k=0.5; // 50% of the power is utilized when a host is in idle state.
    ……;
    ……..;
    public double getPower(double utilization) throws IllegalArgumentException {
    if (utilization < 0 || utilization > 1) {
    throw new IllegalArgumentException("Utilization value must be between 0 and 1");
    }
    if (utilization == 0) {
    return 0;
    }
    double s=k*max+(1-k)*max*utilization; // Example Power Model.
    return s;
    }
    }

  • After the execution of the VM in Host, calculate the average cpu utilized value, and call the getPower() method by passing the cpu utilization value as a parameter.
  • int size = getHostList().size();
    double[] power = new double[size];
    for( int i=0; i<size; i++ ) {
    host     = getHostList().get(j); // get each Host from the list
    int hid = host.getId();
    double availmip=host.getAvailableMips(); //retrieves the available Cpu capacity
    avgCPU[i]=((mips-availmip)/mips)*100 power[i]=host.getPower(Math.abs(avgCPU[i])); // Energy consumped the host
    System.out.println("Average power consumption: "+power);
    }