Creating Collectd Networking Monitoring

This work will monitor resources that Neutron plugins create on the
baremetal hosts.

Change-Id: I89fe330d133449e3cc141696f71127b689819eb6
This commit is contained in:
Joe Talerico 2017-11-01 07:35:04 -04:00 committed by akrzos
parent 0cc47241ed
commit 70c2a22731
7 changed files with 256 additions and 0 deletions

View File

@ -249,6 +249,22 @@ controller_monitored_queues:
- "notifications.error"
- "notifications.critical"
########################
# ovsagent monitoring
########################
ovsagent_compute_monitor: false
ovsagent_controller_monitor: false
controller_monitored_ints:
- "tap"
compute_monitored_ints:
- "qvo"
controller_monitored_ns:
- "qrouter"
- "qdhcp"
########################
# Swift stat plugin
########################

View File

@ -122,6 +122,22 @@ controller_monitored_queues:
- "notifications.error"
- "notifications.critical"
########################
# ovsagent monitoring
########################
ovsagent_compute_monitor: false
ovsagent_controller_monitor: false
controller_monitored_ints:
- "tap"
compute_monitored_ints:
- "qvo"
controller_monitored_ns:
- "qrouter"
- "qdhcp"
########################
# Swift stat plugin
########################

View File

@ -0,0 +1,82 @@
#!/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.
#
"""
"""
import collectd
import os
import subprocess
import time
def configure(cfg):
global INTERVAL
global interfaces
global namespaces
interfaces = []
namespaces = []
config = {c.key: c.values for c in cfg.children}
INTERVAL = config['interval'][0]
collectd.register_read(read, INTERVAL)
if 'interfaces' in config:
interfaces = config['interfaces']
if 'namespaces' in config :
namespaces = config['namespaces']
def run_command(command):
output = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE)
return output.communicate()
def read(data=None):
starttime = time.time()
ifs = []
ns = []
if len(interfaces) > 0 :
collectd.debug("Interfaces : {}".format(interfaces))
for interface in interfaces :
ifs.append({interface: run_command("ovs-vsctl show | grep 'Port \\\"{}' | wc -l".format(interface))[0].replace("\n","")})
if len(namespaces) > 0 :
collectd.debug("Namespaces : {}".format(namespaces))
for namespace in namespaces :
ns.append({namespace: run_command("sudo ip netns | grep {} | wc -l".format(namespace))[0].replace("\n","")})
if len(ifs) > 0 :
for i in ifs :
for value in i:
metric = collectd.Values()
metric.plugin = 'ovsagent_monitoring'
metric.interval = INTERVAL
metric.type = 'gauge'
metric.type_instance = "{}_interface_total-count".format(value)
metric.values = [i[value]]
metric.dispatch()
if len(ns) > 0 :
for n in ns :
for value in n:
metric = collectd.Values()
metric.plugin = 'ovsagent_monitoring'
metric.interval = INTERVAL
metric.type = 'gauge'
metric.type_instance = "{}_ns_total-count".format(value)
metric.values = [n[value]]
metric.dispatch()
timediff = time.time() - starttime
if timediff > INTERVAL:
collectd.warning(
'ovsagent_monitoring: Took: {} > {}'.format(
round(timediff, 2),
INTERVAL)
)
collectd.register_config(configure)

View File

@ -228,6 +228,19 @@
dest: /usr/local/bin/collectd_swift_stat.py
when: "('controller' in group_names and inventory_hostname == groups['controller'][0]) or ('undercloud' in group_names)"
- name: Copy python plugins
copy:
src: "{{item.src}}"
dest: "{{item.dest}}"
owner: root
group: root
mode: 0755
become: true
with_items:
- src: collectd_ovsagent.py
dest: /usr/local/bin/collectd_ovsagent.py
when: "('controller' in group_names ) or ('compute' in group_names)"
# Rabbitmq monitoring
- name: Install pyrabbit
easy_install:

View File

@ -318,5 +318,20 @@ PreCacheChain "PreCache"
</Plugin>
{% if ovsagent_compute_monitor %}
<Plugin python>
ModulePath "/usr/local/bin/"
LogTraces true
Interactive false
Import "collectd_ovsagent"
<Module collectd_ovsagent>
prefix ovsagent
interval 10
interfaces {% for int in compute_monitored_ints %} {{int}} {% endfor %}
</Module>
</Plugin>
{% endif %}
# Include other collectd configuration files
Include "/etc/collectd.d"

View File

@ -2060,5 +2060,23 @@ LoadPlugin "org.collectd.java.GenericJMX"
</Plugin>
</Plugin>
{% endif %}
{% if ovsagent_controller_monitor %}
<Plugin python>
ModulePath "/usr/local/bin/"
LogTraces true
Interactive false
Import "collectd_ovsagent"
<Module collectd_ovsagent>
interval 10
prefix ovsagent
interfaces {% for int in controller_monitored_ints %} {{int}} {% endfor %}
namespaces {% for ns in controller_monitored_ns %} {{ns}} {% endfor %}
</Module>
</Plugin>
{% endif %}
# Include other collectd configuration files
Include "/etc/collectd.d"

View File

@ -7,6 +7,7 @@
{% set rabbitmq_groups = ['undercloud', 'controller', '*'] %}
{% set swift_stat_groups = ['controller', '*'] %}
{% set odl_groups = ['controller', '*'] %}
{% set ovsagent_groups = ['controller', 'compute', '*'] %}
{
"dashboard": {
@ -9135,7 +9136,102 @@
"titleSize": "h6"
},
{% endif %}
{% if item.template_node_type in ovsagent_groups %}
{
"collapse": true,
"height": 200,
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fill": 1,
{% if vars.update({'panel_idx': (vars.panel_idx + 1)}) %} {% endif %}
"id": {{vars.panel_idx}},
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [
{
"refId": "A",
"target": "$Cloud.$Node.ovsagent_monitoring.gauge-qdhcp_ns_total-count"
},
{
"refId": "B",
"target": "$Cloud.$Node.ovsagent_monitoring.gauge-qrouter_ns_total-count"
},
{
"refId": "C",
"target": "$Cloud.$Node.ovsagent_monitoring.gauge-tap_interface_total-count"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "$Cloud - Neutron $Node Resources",
"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": "Neutron Resources",
"titleSize": "h6"
},
{% endif %}
{
"collapse": true,
"editable": true,
"height": "200px",