Measure load on physical host?

asked 2017-04-17 05:53:51 -0500

ShubhamMeshram gravatar image

I developed a health monitoring application which basically finds out the AVG value of CPU utilization using the command ceilometer statistics -m cpu_util and some condition checking is done based on that value and I am migrating the VM ( nova migrate $IDOfTheVM ) from one node to another based on the outcome of the condition. I need statistics like how much load was there before migration and how much is there after migration?

How can I get these values?

To give a clear idea my code does this :

    ceilometer statistics -m cpu_util > /root/hello.txt
    var=0
    echo -e "\nExtracting Avg CPU utilization value...."
    sleep 2
   #Sed is used to extract the value.
    str="$(sed -n '4'p /root/hello.txt)"
             for i in ${str//|/ }
            do
                ((var++))
                if [ $var -eq 6 ]
                   then Avg=$i
                     echo -e "Average CPU utilization : $Avg %\n"
                fi
            done
    if [ "$Avg > 15" ]
        then
          nova migrate $IDOfTheVM
    fi

The command ceilometer statistics -m cpu gives the following output

-------+----------------------------+
| Period | Period Start               | Period End                 | Max           | Min            | Avg           | Sum           | Count | Duration    | Duration Start             | Duration End               |
+--------+----------------------------+----------------------------+---------------+----------------+---------------+---------------+-------+-------------+----------------------------+----------------------------+
| 0      | 2017-03-21T08:48:22.195000 | 2017-04-17T10:33:08.608000 | 100.036525402 | 0.010083457597 | 15.9442731336 | 27886.5337108 | 1749  | 2334928.037 | 2017-03-21T09:57:40.571000 | 2017-04-17T10:33:08.608000 |
+--------+----------------------------+----------------------------+---------------+----------------+---------------+---------------+-------+-------------+----------------------------+----------------------------+
edit retag flag offensive close merge delete