Poll Swift for Account stats via a collectd plugin.
Change-Id: Icc76ef0c0a6535c009407686878239994008fabf
This commit is contained in:
parent
8043094e6f
commit
243b1e652a
@ -251,6 +251,13 @@ controller_monitored_queues:
|
||||
- "notifications.error"
|
||||
- "notifications.critical"
|
||||
|
||||
########################
|
||||
# Swift stat plugin
|
||||
########################
|
||||
# Provides metrics on Swift Account using Gnocchi Swift Configuration
|
||||
swift_stat_controller_collectd_plugin: false
|
||||
swift_stat_controller_collectd_interval: 10
|
||||
|
||||
########################
|
||||
# tail plugin
|
||||
########################
|
||||
|
@ -122,6 +122,13 @@ controller_monitored_queues:
|
||||
- "notifications.error"
|
||||
- "notifications.critical"
|
||||
|
||||
########################
|
||||
# Swift stat plugin
|
||||
########################
|
||||
# Provides metrics on Swift Account using Gnocchi Swift Configuration
|
||||
swift_stat_controller_collectd_plugin: false
|
||||
swift_stat_controller_collectd_interval: 10
|
||||
|
||||
########################
|
||||
# tail plugin
|
||||
########################
|
||||
|
@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python
|
||||
# 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.
|
||||
#
|
||||
"""Collectd python plugin to read swift stat on an OpenStack Controller."""
|
||||
from swiftclient.client import Connection
|
||||
import collectd
|
||||
import os
|
||||
import time
|
||||
|
||||
|
||||
class CollectdSwiftStat(object):
|
||||
SWIFT_STATS = {
|
||||
'x-account-object-count': 'objects',
|
||||
'x-account-container-count': 'containers',
|
||||
'x-account-bytes-used': 'bytes'}
|
||||
|
||||
def __init__(self):
|
||||
self.interval = 10
|
||||
self.prefix = None
|
||||
self.user = None
|
||||
self.password = None
|
||||
self.authurl = None
|
||||
self.project = None
|
||||
self.swift_conn = None
|
||||
|
||||
def configure_callback(self, configobj):
|
||||
for node in configobj.children:
|
||||
val = str(node.values[0])
|
||||
if node.key == 'Interval':
|
||||
self.interval = int(float(val))
|
||||
elif node.key == 'Prefix':
|
||||
self.prefix = val
|
||||
elif node.key == 'User':
|
||||
self.user = val
|
||||
elif node.key == 'Password':
|
||||
self.password = val
|
||||
elif node.key == 'AuthURL':
|
||||
self.authurl = val
|
||||
elif node.key == 'Project':
|
||||
self.project = val
|
||||
else:
|
||||
collectd.warning(
|
||||
'collectd-swift-stat: Unknown config key: {}'
|
||||
.format(node.key))
|
||||
|
||||
read_plugin = True
|
||||
if not self.prefix:
|
||||
collectd.error('collectd-swift-stat: Prefix Undefined')
|
||||
read_plugin = False
|
||||
if not self.user:
|
||||
collectd.error('collectd-swift-stat: User Undefined')
|
||||
read_plugin = False
|
||||
if not self.password:
|
||||
collectd.error('collectd-swift-stat: Password Undefined')
|
||||
read_plugin = False
|
||||
if not self.authurl:
|
||||
collectd.error('collectd-swift-stat: AuthURL Undefined')
|
||||
read_plugin = False
|
||||
if not self.project:
|
||||
collectd.error('collectd-swift-stat: Project Undefined')
|
||||
read_plugin = False
|
||||
|
||||
if read_plugin:
|
||||
collectd.info(
|
||||
'swift_stat: Connecting with user={}, password={}, tenant={},'
|
||||
' auth_url={}'.format(
|
||||
self.user, self.password, self.project, self.authurl))
|
||||
|
||||
self.swift_conn = self.create_swift_session()
|
||||
collectd.register_read(self.read_swift_stat, self.interval)
|
||||
else:
|
||||
collectd.error('collectd_swift_stat: Invalid configuration')
|
||||
|
||||
def read_swift_stat(self, data=None):
|
||||
starttime = time.time()
|
||||
|
||||
stats = self.swift_conn.head_account()
|
||||
|
||||
for m_instance, name in CollectdSwiftStat.SWIFT_STATS.iteritems():
|
||||
if m_instance in stats:
|
||||
metric = collectd.Values()
|
||||
metric.plugin = 'swift_stat'
|
||||
metric.interval = self.interval
|
||||
metric.type = 'gauge'
|
||||
metric.type_instance = '{}-{}'.format(self.prefix, name)
|
||||
metric.values = [stats[m_instance]]
|
||||
metric.dispatch()
|
||||
else:
|
||||
collectd.error(
|
||||
'swift_stat: Can not find: {}'.format(m_instance))
|
||||
|
||||
timediff = time.time() - starttime
|
||||
if timediff > self.interval:
|
||||
collectd.warning(
|
||||
'swift_stat: Took: {} > {}'
|
||||
.format(round(timediff, 2), self.interval))
|
||||
|
||||
def create_swift_session(self):
|
||||
return Connection(
|
||||
authurl=self.authurl, user=self.user, key=self.password,
|
||||
tenant_name=self.project, auth_version='2.0')
|
||||
|
||||
|
||||
collectd_swift_stat = CollectdSwiftStat()
|
||||
collectd.register_config(collectd_swift_stat.configure_callback)
|
@ -182,12 +182,14 @@
|
||||
mode: 0755
|
||||
become: true
|
||||
with_items:
|
||||
- src: collectd_ceph_storage.py
|
||||
dest: /usr/local/bin/collectd_ceph_storage.py
|
||||
- src: collectd_gnocchi_status.py
|
||||
dest: /usr/local/bin/collectd_gnocchi_status.py
|
||||
- src: collectd_rabbitmq_monitoring.py
|
||||
dest: /usr/local/bin/collectd_rabbitmq_monitoring.py
|
||||
- src: collectd_ceph_storage.py
|
||||
dest: /usr/local/bin/collectd_ceph_storage.py
|
||||
- src: collectd_swift_stat.py
|
||||
dest: /usr/local/bin/collectd_swift_stat.py
|
||||
when: "('controller' in group_names and inventory_hostname == groups['controller'][0]) or ('undercloud' in group_names)"
|
||||
|
||||
# Rabbitmq monitoring
|
||||
@ -233,6 +235,26 @@
|
||||
when: "('controller' in group_names and {{rabbitmq_controller_collectd_plugin}} == true and '{{inventory_hostname}}' == groups['controller'][0])"
|
||||
# End Rabbitmq monitoring
|
||||
|
||||
# Gnocchi Swift Stat Service monitoring
|
||||
- name: Get Gnocchi Swift AuthURL
|
||||
command: hiera -c /etc/puppet/hiera.yaml gnocchi::storage::swift::swift_authurl
|
||||
register: controller0_gnocchi_swift_authurl
|
||||
become: true
|
||||
when: "('controller' in group_names and {{swift_stat_controller_collectd_plugin}} == true and '{{inventory_hostname}}' == groups['controller'][0])"
|
||||
|
||||
- name: Get Gnocchi Swift User
|
||||
shell: hiera -c /etc/puppet/hiera.yaml gnocchi::storage::swift::swift_user | sed 's/service://'
|
||||
register: controller0_gnocchi_swift_user
|
||||
become: true
|
||||
when: "('controller' in group_names and {{swift_stat_controller_collectd_plugin}} == true and '{{inventory_hostname}}' == groups['controller'][0])"
|
||||
|
||||
- name: Get Gnocchi Swift Key
|
||||
command: hiera -c /etc/puppet/hiera.yaml gnocchi::storage::swift::swift_key
|
||||
register: controller0_gnocchi_swift_auth_key
|
||||
become: true
|
||||
when: "('controller' in group_names and {{swift_stat_controller_collectd_plugin}} == true and '{{inventory_hostname}}' == groups['controller'][0])"
|
||||
# End Swift Stat Service monitoring
|
||||
|
||||
# CephStorage OSD monitoring
|
||||
# Only Monitors a single OSD on each CephStorage Node
|
||||
- name: Get 1st OSD socket
|
||||
|
@ -392,6 +392,27 @@ PreCacheChain "PreCache"
|
||||
# Rabbitmq plugin installed and enabled on {{groups['controller'][0]}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{%if swift_stat_controller_collectd_plugin %}
|
||||
{%if inventory_hostname == groups['controller'][0] %}
|
||||
|
||||
<Plugin python>
|
||||
ModulePath "/usr/local/bin/"
|
||||
LogTraces true
|
||||
Interactive false
|
||||
Import "collectd_swift_stat"
|
||||
<Module collectd_swift_stat>
|
||||
Interval {{swift_stat_controller_collectd_interval}}
|
||||
Prefix "gnocchi"
|
||||
AuthURL "{{controller0_gnocchi_swift_authurl.stdout}}"
|
||||
User "{{controller0_gnocchi_swift_user.stdout}}"
|
||||
Password "{{controller0_gnocchi_swift_auth_key.stdout}}"
|
||||
Project "service"
|
||||
</Module>
|
||||
</Plugin>
|
||||
{% else %}
|
||||
# swift_stat plugin installed and enabled on {{groups['controller'][0]}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<Plugin swap>
|
||||
ReportBytes true
|
||||
|
@ -5,6 +5,7 @@
|
||||
{% set ironic_groups = ['undercloud'] %}
|
||||
{% set mariadb_groups = ['undercloud', 'controller', '*'] %}
|
||||
{% set rabbitmq_groups = ['undercloud', 'controller', '*'] %}
|
||||
{% set swift_stat_groups = ['controller', '*'] %}
|
||||
{
|
||||
"dashboard": {
|
||||
"annotations": {
|
||||
@ -8020,6 +8021,241 @@
|
||||
"titleSize": "h6"
|
||||
},
|
||||
{% endif %}
|
||||
{% if item.template_node_type in swift_stat_groups %}
|
||||
{
|
||||
"collapse": true,
|
||||
"height": "200px",
|
||||
"panels": [
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"datasource": null,
|
||||
"fill": 0,
|
||||
{% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %}
|
||||
"id": {{vars.panel_idx}},
|
||||
"legend": {
|
||||
"alignAsTable": true,
|
||||
"avg": false,
|
||||
"current": true,
|
||||
"max": true,
|
||||
"min": true,
|
||||
"rightSide": true,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": true
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"span": 12,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"target": "aliasByNode(aliasSub(aliasSub($Cloud.$Node.swift_stat.gauge-*-bytes, 'gauge-', ''), '-bytes', ''), 3)"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Byte Total",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "bytes",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"datasource": null,
|
||||
"fill": 0,
|
||||
{% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %}
|
||||
"id": {{vars.panel_idx}},
|
||||
"legend": {
|
||||
"alignAsTable": true,
|
||||
"avg": false,
|
||||
"current": true,
|
||||
"max": true,
|
||||
"min": true,
|
||||
"rightSide": true,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": true
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"span": 6,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"target": "aliasByNode(aliasSub(aliasSub($Cloud.$Node.swift_stat.gauge-*-containers, 'gauge-', ''), '-containers', ''), 3)",
|
||||
"textEditor": false
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Container Count",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"datasource": null,
|
||||
"fill": 0,
|
||||
{% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %}
|
||||
"id": {{vars.panel_idx}},
|
||||
"legend": {
|
||||
"alignAsTable": true,
|
||||
"avg": false,
|
||||
"current": true,
|
||||
"max": true,
|
||||
"min": true,
|
||||
"rightSide": true,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": true
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"span": 6,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"target": "aliasByNode(aliasSub(aliasSub($Cloud.$Node.swift_stat.gauge-*-objects, 'gauge-', ''), '-objects', ''), 3)",
|
||||
"textEditor": false
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Object Count",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"repeat": null,
|
||||
"repeatIteration": null,
|
||||
"repeatRowId": null,
|
||||
"showTitle": true,
|
||||
"title": "Swift Stat",
|
||||
"titleSize": "h6"
|
||||
},
|
||||
{% endif %}
|
||||
{% if item.template_node_type in ironic_groups %}
|
||||
{
|
||||
"collapse": true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user