Use ceilometer API

Why do I need ?

First, get Nova instance name from Nova. Since this is not mandatory, it permit you to get VM names. More elegant.

Then get a ceilometer object and perform a request.

Get the server list from Nova

Retrieve environment variables

os_username = os.environ.get('OS_USERNAME')
os_password = os.environ.get('OS_PASSWORD')
os_regionname = os.environ.get('OS_REGION_NAME')
os_project_name = os.environ.get('OS_PROJECT_NAME')
os_auth_url = os.environ.get('OS_AUTH_URL')

Then, create a nova client object :

novaclient = client.Client(os_username,
             os_password, 
             os_project_name, 
             os_auth_url, 
             service_type="compute", 
             region_name=os_regionname)

Get server list :

servers = novaclient.servers.list(detailed=True)

Ceilometer

Get now a ceilometer object :

ceilometerclient = ceilometerclient.client.get_client(2,
         os_username=os_username,
         os_password=os_password,
         os_tenant_name=os_project_name,
         os_auth_url=os_auth_url,
         region_name=os_regionname)

Create the query

Pick a server id from the list you just obtain the step before.

query = [dict(field='resource_id', op='eq', value=server.id)]

Get the results

cpu_util = ceilometerclient.samples.list(meter_name='cpu_util', limit=1, q=query)    

Full script is here :