From dce7dc91edca75e3a4668f5197a8dc269d9b8e88 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Mon, 18 Aug 2014 14:48:31 +0200 Subject: [PATCH] Adding another set of hardware metrics These metrics are being used in TripleO-UI Change-Id: I8e096f28535c96f982bb37744f63cd8ead4b5397 Closes-bug: #1365552 --- ceilometer/hardware/inspector/snmp.py | 51 +++++++++++++++++++ ceilometer/hardware/pollsters/memory.py | 8 +++ .../hardware/pollsters/network_aggregated.py | 38 ++++++++++++++ ceilometer/hardware/pollsters/system.py | 50 ++++++++++++++++++ setup.cfg | 7 +++ 5 files changed, 154 insertions(+) create mode 100644 ceilometer/hardware/pollsters/network_aggregated.py create mode 100644 ceilometer/hardware/pollsters/system.py diff --git a/ceilometer/hardware/inspector/snmp.py b/ceilometer/hardware/inspector/snmp.py index 46a7f68b..826fff12 100644 --- a/ceilometer/hardware/inspector/snmp.py +++ b/ceilometer/hardware/inspector/snmp.py @@ -66,6 +66,8 @@ class SNMPInspector(base.Inspector): # Memory OIDs _memory_total_oid = "1.3.6.1.4.1.2021.4.5.0" _memory_used_oid = "1.3.6.1.4.1.2021.4.6.0" + _memory_total_swap_oid = "1.3.6.1.4.1.2021.4.3.0" + _memory_avail_swap_oid = "1.3.6.1.4.1.2021.4.4.0" # Disk OIDs _disk_index_oid = "1.3.6.1.4.1.2021.9.1.1" _disk_path_oid = "1.3.6.1.4.1.2021.9.1.2" @@ -81,6 +83,13 @@ class SNMPInspector(base.Inspector): _interface_received_oid = "1.3.6.1.2.1.2.2.1.10" _interface_transmitted_oid = "1.3.6.1.2.1.2.2.1.16" _interface_error_oid = "1.3.6.1.2.1.2.2.1.20" + # System stats + _system_stats_cpu_idle_oid = "1.3.6.1.4.1.2021.11.11.0" + _system_stats_io_raw_sent_oid = "1.3.6.1.4.1.2021.11.57.0" + _system_stats_io_raw_received_oid = "1.3.6.1.4.1.2021.11.58.0" + # Network stats + _network_ip_out_requests_oid = "1.3.6.1.2.1.4.10.0" + _network_ip_in_receives_oid = "1.3.6.1.2.1.4.3.0" # Default port _port = 161 @@ -186,6 +195,18 @@ class SNMPInspector(base.Inspector): 'metadata': {}, 'post_op': None, }, + 'memory.swap.total': { + 'matching_type': EXACT, + 'metric_oid': (_memory_total_swap_oid, int), + 'metadata': {}, + 'post_op': None, + }, + 'memory.swap.avail': { + 'matching_type': EXACT, + 'metric_oid': (_memory_avail_swap_oid, int), + 'metadata': {}, + 'post_op': None, + }, 'disk.size.total': { 'matching_type': PREFIX, 'metric_oid': (_disk_size_oid, int), @@ -216,6 +237,36 @@ class SNMPInspector(base.Inspector): 'metadata': _net_metadata, 'post_op': "_post_op_net", }, + 'network.ip.outgoing.datagrams': { + 'matching_type': EXACT, + 'metric_oid': (_network_ip_out_requests_oid, int), + 'metadata': {}, + 'post_op': None, + }, + 'network.ip.incoming.datagrams': { + 'matching_type': EXACT, + 'metric_oid': (_network_ip_in_receives_oid, int), + 'metadata': {}, + 'post_op': None, + }, + 'system_stats.cpu.idle': { + 'matching_type': EXACT, + 'metric_oid': (_system_stats_cpu_idle_oid, int), + 'metadata': {}, + 'post_op': None, + }, + 'system_stats.io.outgoing.blocks': { + 'matching_type': EXACT, + 'metric_oid': (_system_stats_io_raw_sent_oid, int), + 'metadata': {}, + 'post_op': None, + }, + 'system_stats.io.incoming.blocks': { + 'matching_type': EXACT, + 'metric_oid': (_system_stats_io_raw_received_oid, int), + 'metadata': {}, + 'post_op': None, + }, } def __init__(self): diff --git a/ceilometer/hardware/pollsters/memory.py b/ceilometer/hardware/pollsters/memory.py index f1149c07..bb2bcb64 100644 --- a/ceilometer/hardware/pollsters/memory.py +++ b/ceilometer/hardware/pollsters/memory.py @@ -44,3 +44,11 @@ class MemoryTotalPollster(_Base): class MemoryUsedPollster(_Base): IDENTIFIER = 'memory.used' + + +class MemorySwapTotalPollster(_Base): + IDENTIFIER = 'memory.swap.total' + + +class MemorySwapAvailPollster(_Base): + IDENTIFIER = 'memory.swap.avail' diff --git a/ceilometer/hardware/pollsters/network_aggregated.py b/ceilometer/hardware/pollsters/network_aggregated.py new file mode 100644 index 00000000..89647932 --- /dev/null +++ b/ceilometer/hardware/pollsters/network_aggregated.py @@ -0,0 +1,38 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from ceilometer.hardware import plugin +from ceilometer.hardware.pollsters import util +from ceilometer import sample + + +class _Base(plugin.HardwarePollster): + + CACHE_KEY = 'network' + + def generate_one_sample(self, host, c_data): + value, metadata, extra = c_data + return util.make_sample_from_host(host, + name=self.IDENTIFIER, + sample_type=sample.TYPE_CUMULATIVE, + unit='datagrams', + volume=value, + res_metadata=metadata, + extra=extra) + + +class NetworkAggregatedIPOutRequests(_Base): + IDENTIFIER = 'network.ip.outgoing.datagrams' + + +class NetworkAggregatedIPInReceives(_Base): + IDENTIFIER = 'network.ip.incoming.datagrams' diff --git a/ceilometer/hardware/pollsters/system.py b/ceilometer/hardware/pollsters/system.py new file mode 100644 index 00000000..9063a9d2 --- /dev/null +++ b/ceilometer/hardware/pollsters/system.py @@ -0,0 +1,50 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from ceilometer.hardware import plugin +from ceilometer.hardware.pollsters import util +from ceilometer import sample + + +class _Base(plugin.HardwarePollster): + + CACHE_KEY = 'system' + + +class _SystemBase(_Base): + def generate_one_sample(self, host, c_data): + value, metadata, extra = c_data + return util.make_sample_from_host(host, + name=self.IDENTIFIER, + sample_type=self.TYPE, + unit=self.UNIT, + volume=value, + res_metadata=metadata, + extra=extra) + + +class SystemCpuIdlePollster(_SystemBase): + IDENTIFIER = 'system_stats.cpu.idle' + TYPE = sample.TYPE_GAUGE + UNIT = '%' + + +class SystemIORawSentPollster(_SystemBase): + IDENTIFIER = 'system_stats.io.outgoing.blocks' + TYPE = sample.TYPE_CUMULATIVE, + UNIT = 'blocks' + + +class SystemIORawReceivedPollster(_SystemBase): + IDENTIFIER = 'system_stats.io.incoming.blocks' + TYPE = sample.TYPE_CUMULATIVE, + UNIT = 'blocks' diff --git a/setup.cfg b/setup.cfg index 63bcb368..0ce3c591 100644 --- a/setup.cfg +++ b/setup.cfg @@ -163,6 +163,13 @@ ceilometer.poll.central = hardware.network.outgoing.errors = ceilometer.hardware.pollsters.net:OutgoingErrorsPollster hardware.memory.total = ceilometer.hardware.pollsters.memory:MemoryTotalPollster hardware.memory.used = ceilometer.hardware.pollsters.memory:MemoryUsedPollster + hardware.memory.swap.total = ceilometer.hardware.pollsters.memory:MemorySwapTotalPollster + hardware.memory.swap.avail = ceilometer.hardware.pollsters.memory:MemorySwapAvailPollster + hardware.system_stats.cpu.idle = ceilometer.hardware.pollsters.system:SystemCpuIdlePollster + hardware.system_stats.io.outgoing.blocks = ceilometer.hardware.pollsters.system:SystemIORawSentPollster + hardware.system_stats.io.incoming.blocks = ceilometer.hardware.pollsters.system:SystemIORawReceivedPollster + hardware.network.ip.outgoing.datagrams = ceilometer.hardware.pollsters.network_aggregated:NetworkAggregatedIPOutRequests + hardware.network.ip.incoming.datagrams = ceilometer.hardware.pollsters.network_aggregated:NetworkAggregatedIPInReceives network.services.lb.pool = ceilometer.network.services.lbaas:LBPoolPollster network.services.lb.vip = ceilometer.network.services.lbaas:LBVipPollster network.services.lb.member = ceilometer.network.services.lbaas:LBMemberPollster