Tuesday, December 29, 2015

Openstack billing
Ceilometer measures the usage of resources in terms of disk usage, network usage and CPU usage. For each instance the usage details for following meters will be shown: 
  1. Disk Read Bytes 
  1. Disk Write Bytes 
  1. Disk Write Requests 
  1. Disk Read Requests 
  1. Network outgoing bytes 
  1. Network incoming bytes 
  1. Network outgoing packets 
  1. Network incoming packets 
  1. CPU 
 
Ceilometer arranges all the data in terms of resources and their meters. 
We can get a list of all the meters using  
GET /v2/resources/ and  
GET /v2/resources/(resource_id)  
 Where resource contains links such as a url to identify itself and a url for its meters such as http://localhost:8777/v2/meters/volume?q.field=resource_id&q.value=bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 
  
GET /v2/meters/ that returns all know meters and  
GET /v2/meters/(meter_name) which even come with statistics 
GET /v2/meters/(meter_name)/statistics 
  
Samples and statistics can also be drawn from  
GET /v2/samples 
And GET /v2/            samples/(sample_id) 
 
Tables can be created in the following manner: 
RatePlan
  1. Id 
  1. Name  
  1. CPU cost per second 
  1. Disk cost per MB 
  1. Network cost per MB 
  1. Cost for flavors 

Table for instance-bill will have the following attributes 
  1. Resource_id 
  1. Rateplan_id 
  1. Date and time at which the bill was calculated 
  1. Resource_bill 
Openstack provides three  types of meters:  
Cumulative -  those that increase over time 
Delta -  those that change over time  
and Gauge - those that are discrete items and fluctuating values 
When we pick the metrics for compute and storage, we are typically interested in the first and the last of the above. These will come in helpful to provide information on an instance basis. For example, compute has instance, number of vcpus and memory as gauge and cpu time as cumulative. This theme is common to Openstack as well as Amazon as we have seen.

#codingexercise
Given pairs of numbers which correspond to number of unit-heights on  two vertical lines  and the pair representing starting and ending points for a connecting line, find the number of intersection points in the list of pairs. At every intersection points there are only two connectors. There is only one connector at each starting or ending point

int GetNumberOfIntersections(List<Tuple<int,int>> pairs)
{
int total = 0;
for (int i = 0; i < pairs.Count; i++)
{
if (pairs[i].Item1 > pairs[i].Item2)
{
int start = pairs[i].Item2;
int end = pairs[i].Item1;
int count = 0;
for (int j = 0; j< pairs.Count; j++)
{
if (j == i ) continue;
if (pairs[j].Item2 >= pairs[start] &&
     pairs[j].Item2 < pairs[end])
    count++;
}
total += count;
}
else
{
int start = pairs[i].Item1;
int end = pairs[i].Item2;
int count = 0;
for (int j = 0; j< pairs.Count; j++)
{
if (j == i) continue;
if (pairs[j].Item1 > pairs[start] &&
     pairs[j].Item1 <= pairs[end])
    count++;
}
total += count;
}
return total;
}

 

No comments:

Post a Comment