fixes and added host_alive check templating

This commit is contained in:
Ramon Melero 2016-11-15 07:27:58 +00:00
parent 5c318ea4d3
commit a34df3e9b9
6 changed files with 125 additions and 113 deletions

89
.gitignore vendored
View File

@ -1,89 +0,0 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject

View File

@ -8,4 +8,36 @@ add python-monascaclient to 'utility_pip_packages' in /opt/openstack-ansible/pl
add packages for repo-build
make file called user_variables_monasca.yml with the following con
make file called user_variables_monasca.yml with the following:
monasca_requires_pip_packages:
- monasca-agent
- gevent==1.1.1
- msgpack-python
- netaddr
- psutil==3.0.1
By default, this skips the repo and utility containers as they do not host openstack services. Set skip_repo_utility_hosts to false to install on those hosts as well.
To create host_alive checks for all hosts in the Openstack-Ansible inventory,
populate host_alive_check_hosts with a list of hosts that should do the checking, ideally the monasca hosts.
host_alive_check_hosts:
- monasca-1
- monasca-2
- monasca-3
To add extra hosts to the ssh host checks,
cd
To regen the list of hosts after inventory changes, re-run the playbook with the tag regen_host_alive_checks:
openstack-ansible os-monasca-agent.yml -t regen_host_alive_checks
TODO
Fix process I/O access issue.
2016-11-14 07:16:07 UTC | DEBUG | collector | monasca_agent.collector.checks.check.process(process.py:123) | monasca-agent user does not have access to I/O counters for process 4699: <bound method Process.name of <psutil.Process(pid=4699, name='supervisord') at 140220130336016>>

View File

@ -2,7 +2,16 @@ monasca_agent_user: "monasca-agent"
monasca_agent_password: "password"
monasca_agent_service: "service"
keystone_url: "http://{{internal_lb_vip_address}}:5000/v3"
monasca_agent_project: "tbd"
monasca_agent_project: "monasca-agent"
monasca_agent_check_frequency: 60
monasca_agent_system_only: false
monasca_log_level: "WARN"
monasca_agent_user_name: monasca-agent
monasca_agent_password: test
monasca_agent_project_name: monasca-agent
monasca_agent_role_name: monasca-agent
host_alive_check_hosts:
extra_host_alive_checks:
# implement
skip_repo_utility_hosts: true

View File

@ -1,38 +1,80 @@
---
- name: Ensure monasca project exists
run_once: true
keystone:
command: "ensure_project"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
project_name: "{{ monasca_agent_project_name }}"
- name: Ensure monasca-agent role exists
run_once: true
keystone:
command: "ensure_role"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
role_name: "{{ monasca_agent_role_name }}"
- name: Ensure monasca-agent user exists
run_once: true
keystone:
command: "ensure_user"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
user_name: "{{ monasca_agent_user_name }}"
password: "{{ monasca_agent_password }}"
project_name: "{{ monasca_agent_project_name }}"
- name: Ensure monasca-agent user assigned to monasca-agent role
run_once: true
keystone:
command: "ensure_user_role"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
user_name: "{{ monasca_agent_user_name }}"
tenant_name: "{{ monasca_agent_project_name }}"
role_name: "{{ monasca_agent_role_name }}"
- name: Template monasca-setup
template: dest=/usr/local/bin/monasca-reconfigure src=monasca-reconfigure.j2 owner=root mode=750
- name: Template plugin specific configuration files
template: dest={{item.dest}} src={{item.src}} owner=root mode={{item.mode}}
template: dest={{item.dest}} src={{item.src}} owner=root mode=640
when: ansible_hostname | search("{{item.hostname}}")
with_items:
- { hostname: "rabbit" , dest: "/root/.rabbitmq.cnf" , src: ".rabbitmq.cnf.j2" , mode: "640" }
- { hostname: "galera" , dest: "/root/.my.cnf" , src: ".my.cnf.j2" , mode: "640" }
- { hostname: "horizon" , dest: "/root/.apache.cnf" , src: ".apache.cnf.j2" , mode: "640" }
- { hostname: "rabbit" , dest: "/root/.rabbitmq.cnf" , src: ".rabbitmq.cnf.j2" }
- { hostname: "galera" , dest: "/root/.my.cnf" , src: ".my.cnf.j2" }
- { hostname: "horizon" , dest: "/root/.apache.cnf" , src: ".apache.cnf.j2" }
- name: Grant permissions for process metrics collection
user: name=mon-agent groups={{item.groups}}
when: ansible_hostname | search("{{item.hostname}}")
with_items:
- { hostname: "horizon", groups: "www-data" }
- { hostname: "rabbit", groups: "rabbitmq" }
# - name: Grant permissions for process metrics collection
# user: name=mon-agent groups={{item.groups}}
# when: ansible_hostname | search("{{item.hostname}}")
# with_items:
# - { hostname: "horizon", groups: "www-data" }
# - { hostname: "rabbit", groups: "rabbitmq" }
# - { hostname: "swift-proxy", groups: "swift" }
- name: check if rabbitmq api is enabled
command: grep rabbitmq_management /etc/rabbitmq/enabled_plugins
register: rabbitmq_api_enabled
when: ansible_hostname | search("rabbit")
- name: Enable rabbitmq api
command: /usr/sbin/rabbitmq-plugins enable rabbitmq_management
when: ansible_hostname | search("rabbit")
when: ansible_hostname | search("rabbit") and rabbitmq_api_enabled.rc == 1
- name: Generate host_alive configuration
tags: regen_host_alive_checks
template: dest=/etc/monasca/agent/conf.d/host_alive.yaml src=host_alive.yaml.j2 owner=mon-agent group=mon-agent mode=640
when: inventory_hostname in host_alive_check_hosts
- name: Run initial monasca-setup
command: /usr/local/bin/monasca-reconfigure
# Reduce agent permissions
# * remove shell from agent
# *
- name: Enable monasca-agent service
service: name=monasca-agent state=started enabled=yes
# import psutil
# p=psutil.Process(560)
# p.num_fds()

View File

@ -0,0 +1,18 @@
init_config:
ssh_port: 22
ssh_timeout: 1
instances:
{% for h in groups['all']%}
- alive_test: ssh
host_name: {{ h }}
name: ssh check for {{ h }}
target_hostname: {{ hostvars[h]['ansible_default_ipv4']['address'] }}
{% endfor %}
{% if extra_host_alive_checks[0] is defined %}
{% for h in extra_host_alive_checks%}
- alive_test: ssh
host_name: {{ h.hostname }}
name: ssh check for {{ h.hostname }}
target_hostname: {{ h.ip }}
{% endfor %}
{% endif %}

View File

@ -4,7 +4,7 @@
-p '{{monasca_agent_password}}' \
{% if monasca_agent_service is defined %} -s '{{monasca_agent_service}}' {% endif %} \
--keystone_url '{{keystone_url}}' \
--project_name '{{monasca_agent_project}}' \
--project_name '{{monasca_agent_project_name}}' \
{% if monasca_api_url is defined %} --monasca_url '{{monasca_api_url}}' {% endif %} \
{% if monasca_agent_dimensions is defined %} --dimensions '{{monasca_agent_dimensions}}' {% endif %} \
{% if monasca_agent_check_frequency is defined %} --check_frequency '{{monasca_agent_check_frequency}}' {% endif %} \