Package haizea :: Package pluggable :: Package accounting :: Module utilization
[hide private]
[frames] | no frames]

Source Code for Module haizea.pluggable.accounting.utilization

 1  # -------------------------------------------------------------------------- # 
 2  # Copyright 2006-2009, University of Chicago                                 # 
 3  # Copyright 2008-2009, Distributed Systems Architecture Group, Universidad   # 
 4  # Complutense de Madrid (dsa-research.org)                                   # 
 5  #                                                                            # 
 6  # Licensed under the Apache License, Version 2.0 (the "License"); you may    # 
 7  # not use this file except in compliance with the License. You may obtain    # 
 8  # a copy of the License at                                                   # 
 9  #                                                                            # 
10  # http://www.apache.org/licenses/LICENSE-2.0                                 # 
11  #                                                                            # 
12  # Unless required by applicable law or agreed to in writing, software        # 
13  # distributed under the License is distributed on an "AS IS" BASIS,          # 
14  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   # 
15  # See the License for the specific language governing permissions and        # 
16  # limitations under the License.                                             # 
17  # -------------------------------------------------------------------------- # 
18   
19  """Accounting probes that collect data on resource utilization""" 
20   
21  from haizea.core.accounting import AccountingProbe, AccountingDataCollection 
22  from haizea.common.utils import get_clock 
23   
24 -class CPUUtilizationProbe(AccountingProbe):
25 """ 26 Collects information on CPU utilization 27 28 * Counters 29 30 - "CPU utilization": Amount of CPU resources used in the entire site 31 at a given time. The value ranges between 0 and 1. 32 33 """ 34 COUNTER_UTILIZATION="CPU utilization" 35
36 - def __init__(self, accounting):
40
41 - def at_timestep(self, lease_scheduler):
42 """See AccountingProbe.at_timestep""" 43 util = lease_scheduler.vm_scheduler.get_utilization(get_clock().get_time()) 44 utilization = sum([v for k,v in util.items() if k != None]) 45 self.accounting.append_to_counter(CPUUtilizationProbe.COUNTER_UTILIZATION, utilization)
46 47
48 -class DiskUsageProbe(AccountingProbe):
49 """ 50 Collects information on disk usage 51 52 * Counters 53 54 - "Disk usage": Maximum disk space used across nodes. 55 56 """ 57 COUNTER_DISKUSAGE="Disk usage" 58
59 - def __init__(self, accounting):
63
64 - def at_timestep(self, lease_scheduler):
65 """See AccountingProbe.at_timestep""" 66 usage = lease_scheduler.vm_scheduler.resourcepool.get_max_disk_usage() 67 self.accounting.append_to_counter(DiskUsageProbe.COUNTER_DISKUSAGE, usage)
68