working agent

This commit is contained in:
Ramon Melero 2016-11-14 03:03:59 +00:00
parent 41852e7215
commit 5c318ea4d3
10 changed files with 221 additions and 1 deletions

View File

@ -1 +1,11 @@
# openstack-ansible-os_monasca-agent
# openstack-ansible-os_monasca-agent
steps for install
add python-monascaclient to 'utility_pip_packages' in /opt/openstack-ansible/playbooks/utility-install.yml
add packages for repo-build
make file called user_variables_monasca.yml with the following con

8
defaults/main.yml Normal file
View File

@ -0,0 +1,8 @@
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_check_frequency: 60
monasca_agent_system_only: false
monasca_log_level: "WARN"

0
tasks/configure.yml Normal file
View File

0
tasks/install.yml Normal file
View File

38
tasks/main.yml Normal file
View File

@ -0,0 +1,38 @@
---
- 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}}
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" }
- 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: Enable rabbitmq api
command: /usr/sbin/rabbitmq-plugins enable rabbitmq_management
when: ansible_hostname | search("rabbit")
- 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()

2
templates/.apache.cnf.j2 Normal file
View File

@ -0,0 +1,2 @@
[client]
url=https://localhost/server-status?auto

6
templates/.my.cnf.j2 Normal file
View File

@ -0,0 +1,6 @@
[client]
user=root
password=pass
host=server
socket=/var/run/mysqld/mysqld.sock
ssl_ca=/etc/ssl/certs/ca-certificates.crt

View File

@ -0,0 +1,6 @@
[client]
user=guest
password=pass
nodes=rabbit@devstack
queues=conductor
exchanges=nova,cinder,ceilometer,glance,keystone,neutron,heat,ironic,openstack

137
templates/agent.yml.j2 Normal file
View File

@ -0,0 +1,137 @@
Api:
# To configure Keystone correctly, a project-scoped token must be acquired.
# To accomplish this, the configuration must be set up with one of the
# following scenarios:
# Set username and password and you have a default project set in keystone.
# Set username, password and project id.
# Set username, password, project name and (domain id or domain name).
#
# Monitoring API URL: URL for the monitoring API, if undefined it will be pulled from the keystone service catalog
# Example: https://region-a.geo-1.monitoring.hpcloudsvc.com:8080/v2.0
url: {args.monasca_url}
# Keystone Username
username: {args.username}
# Keystone Password
password: "{args.password}"
# Keystone API URL: URL for the Keystone server to use
# Example: https://region-a.geo-1.identity.hpcloudsvc.com:35357/v3/
keystone_url: {args.keystone_url}
# Domain id to be used to resolve username
user_domain_id: {args.user_domain_id}
# Domain name to be used to resolve username
user_domain_name: {args.user_domain_name}
# Project name to be used by this agent
project_name: {args.project_name}
# Project domain id to be used by this agent
project_domain_id: {args.project_domain_id}
# Project domain id to be used by this agent
project_domain_name: {args.project_domain_name}
# Project id to be used by this agent
project_id: {args.project_id}
# Set whether certificates are used for Keystone
# *******************************************************************************************
# **** CAUTION ****: The insecure flag should NOT be set to True in a production environment!
# *******************************************************************************************
# If insecure is set to False, a ca_file name must be set to authenticate with Keystone
insecure: {args.insecure}
# Name of the ca certs file
ca_file: {args.ca_file}
# The following 3 options are for handling buffering and reconnection to the monasca-api
# If the agent forwarder is consuming too much memory, you may want to set
# max_measurement_buffer_size to a lower value. If you have a larger system with many agents,
# you may want to throttle the number of messages sent to the API by setting the
# backlog_send_rate to a lower number.
# DEPRECATED - please use max_measurement_buffer_size instead
# Maximum number of messages (batches of measurements) to buffer when unable to communicate
# with the monasca-api (-1 means no limit)
max_buffer_size: {args.max_buffer_size}
# Maximum number of measurements to buffer when unable to communicate with the monasca-api
# (-1 means no limit)
max_measurement_buffer_size: {args.max_measurement_buffer_size}
# Maximum number of messages to send at one time when communication with the monasca-api is restored
backlog_send_rate: {args.backlog_send_rate}
# Publish extra metrics to the API by adding this number of 'amplifier' dimensions.
# For load testing purposes only; set to 0 for production use.
amplifier: {args.amplifier}
Main:
# Force the hostname to whatever you want.
hostname: {hostname}
# Optional dimensions to be sent with every metric from this node
# They should be in the format name: value
# Example of dimensions below
# dimensions:
# service: nova
# group: group_a
# environment: production
dimensions: {args.dimensions}
# Set the threshold for accepting points to allow anything
# with recent_point_threshold seconds
# Defaults to 30 seconds if no value is provided
#recent_point_threshold: 30
# time to wait between collection runs
check_freq: {args.check_frequency}
# Number of Collector Threads to run
num_collector_threads: {args.num_collector_threads}
# Maximum number of collection cycles where all of the threads in the pool are
# still running plugins before the collector will exit
pool_full_max_retries: {args.pool_full_max_retries}
# Threshold value for warning on collection time of each check (in seconds)
sub_collection_warn: {args.plugin_collect_time_warn}
# Collector restart interval (in hours)
collector_restart_interval: 24
# Change port the Agent is listening to
# listen_port: 17123
# Allow non-local traffic to this Agent
# This is required when using this Agent as a proxy for other Agents
# that might not have an internet connection
# For more information, please see
# https://github.com/DataDog/dd-agent/wiki/Network-Traffic-and-Proxy-Configuration
# non_local_traffic: no
Statsd:
# ========================================================================== #
# Monasca Statsd configuration #
# ========================================================================== #
# Monasca Statsd is a small server that aggregates your custom app metrics.
# Make sure your client is sending to the same port.
monasca_statsd_port : {args.monasca_statsd_port}
## The monasca_statsd flush period.
# monasca_statsd_interval : 20
# If you want to forward every packet received by the monasca_statsd server
# to another statsd server, uncomment these lines.
# WARNING: Make sure that forwarded packets are regular statsd packets and not "monasca_statsd" packets,
# as your other statsd server might not be able to handle them.
# monasca_statsd_forward_host: address_of_own_statsd_server
# monasca_statsd_statsd_forward_port: 8125
Logging:
# ========================================================================== #
# Logging
# ========================================================================== #
log_level: {args.log_level}
collector_log_file: /var/log/monasca/agent/collector.log
forwarder_log_file: /var/log/monasca/agent/forwarder.log
statsd_log_file: /var/log/monasca/agent/statsd.log
# if syslog is enabled but a host and port are not set, a local domain socket
# connection will be attempted
#
# log_to_syslog: yes
# syslog_host:
# syslog_port:

View File

@ -0,0 +1,13 @@
#!/bin/sh
'/opt/monasca/bin/monasca-setup' \
-u '{{monasca_agent_user}}' \
-p '{{monasca_agent_password}}' \
{% if monasca_agent_service is defined %} -s '{{monasca_agent_service}}' {% endif %} \
--keystone_url '{{keystone_url}}' \
--project_name '{{monasca_agent_project}}' \
{% 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 %} \
{% if monasca_agent_system_only %} --system_only {% endif %} \
{% if monasca_log_level is defined %} --log_level '{{monasca_log_level}}' {% endif %} \
--overwrite