~ubuntu-branches/ubuntu/vivid/ceilometer/vivid

« back to all changes in this revision

Viewing changes to ceilometer/hardware/pollsters/cpu.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 14:44:28 UTC
  • mto: (28.1.1 utopic-proposed) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20140306144428-rvphsh4igwyulzf0
Tags: upstream-2014.1~b3
Import upstream version 2014.1~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
#
 
3
# Copyright © 2013 ZHAW SoE
 
4
# Copyright © 2014 Intel Corp.
 
5
#
 
6
# Authors: Lucas Graf <graflu0@students.zhaw.ch>
 
7
#          Toni Zehnder <zehndton@students.zhaw.ch>
 
8
#          Lianhao Lu <lianhao.lu@intel.com>
 
9
#
 
10
# Licensed under the Apache License, Version 2.0 (the "License"); you may
 
11
# not use this file except in compliance with the License. You may obtain
 
12
# a copy of the License at
 
13
#
 
14
#      http://www.apache.org/licenses/LICENSE-2.0
 
15
#
 
16
# Unless required by applicable law or agreed to in writing, software
 
17
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
18
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
19
# License for the specific language governing permissions and limitations
 
20
# under the License.
 
21
 
 
22
from ceilometer.hardware import plugin
 
23
from ceilometer.hardware.pollsters import util
 
24
from ceilometer import sample
 
25
 
 
26
 
 
27
class _Base(plugin.HardwarePollster):
 
28
 
 
29
    CACHE_KEY = 'cpu'
 
30
    INSPECT_METHOD = 'inspect_cpu'
 
31
 
 
32
 
 
33
class CPUUtil1MinPollster(_Base):
 
34
 
 
35
    @staticmethod
 
36
    def generate_one_sample(host, c_data):
 
37
        return util.make_sample_from_host(host,
 
38
                                          name='cpu.util.1min',
 
39
                                          type=sample.TYPE_GAUGE,
 
40
                                          unit='%',
 
41
                                          volume=c_data.cpu_1_min,
 
42
                                          )
 
43
 
 
44
 
 
45
class CPUUtil5MinPollster(_Base):
 
46
 
 
47
    @staticmethod
 
48
    def generate_one_sample(host, c_data):
 
49
        return util.make_sample_from_host(host,
 
50
                                          name='cpu.util.5min',
 
51
                                          type=sample.TYPE_GAUGE,
 
52
                                          unit='%',
 
53
                                          volume=c_data.cpu_5_min,
 
54
                                          )
 
55
 
 
56
 
 
57
class CPUUtil15MinPollster(_Base):
 
58
 
 
59
    @staticmethod
 
60
    def generate_one_sample(host, c_data):
 
61
        return util.make_sample_from_host(host,
 
62
                                          name='cpu.util.15min',
 
63
                                          type=sample.TYPE_GAUGE,
 
64
                                          unit='%',
 
65
                                          volume=c_data.cpu_15_min,
 
66
                                          )