diff --git a/README.md b/README.md index 131bbca..fc2e66f 100644 --- a/README.md +++ b/README.md @@ -12,25 +12,18 @@ and logging levels. ## Example { - "id" : "mon_agent", - "dimensions" : "service:mini-mon, group:group_a", - "log_level" : "DEBUG", - "api" : { - "mon_api_url" : "http://192.168.10.4:8080/v2.0", - "mon_api_username" : "joe_user", - "mon_api_password" : "correcthorsebatterystaple", - "mon_api_project_id" : "12345678901234", - "keystone_url" : "http://192.168.10.4:5000/v2.0" - } + "id": "mon_agent", + "keystone_url": "http://192.168.10.4:5000/v2.0", + "username": "joe_user", + "password": "correcthorsebatterystaple", + "mon_api_url": "http://192.168.10.4:8080/v2.0", + "service": "mini-mon" } # Recipes ## default -The default recipe sets up the Monitoring Agent environment by installing -the dependencies, then the mon-agent package itself, setting up logging -directory and init script, and populating the configuration files with the -contents of `data_bag_item(node[:mon_agent][:data_bag], 'mon_agent')` +The default recipe sets up the Monitoring Agent and runs mon-setup to configure. ## plugin_cfg mon-agent plugins are configured in `/etc/mon-agent/conf.d/` as YAML files ending diff --git a/attributes/default.rb b/attributes/default.rb index cec45bf..07bd1b7 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,41 +1,2 @@ -# Agent Version -default['mon-agent']['agent_version'] = nil - -# Boolean to enable debug_mode, which outputs massive amounts of log messages -# to the /tmp/ directory. -default['mon-agent']['debug'] = false - -# Global dimensions, to be included in every metric. Use comma-delimited -# name:value pairs, like "name1:value1, name2:value2" -default['mon-agent']['dimensions'] = nil - -# How often you want the agent to collect data, in seconds. Any value between -# 15 and 60 is a reasonable interval. -default['mon-agent']['check_freq'] = 15 - -# Use mount points instead of volumes to track disk and fs metrics -default['mon-agent']['use_mount'] = false - -# Change port the agent is listening to -default['mon-agent']['agent_port'] = 17123 - -# Monstatsd configuration -default['mon-agent']['monstatsd'] = false -default['mon-agent']['monstatsd_port'] = 8125 -default['mon-agent']['monstatsd_interval'] = 30 -default['mon-agent']['monstatsd_normalize'] = "yes" - -# log-parsing configuration -default['mon-agent']['dogstreams'] = [] - -# Logging configuration -default['mon-agent']['disable_file_logging'] = false -default['mon-agent']['syslog']['active'] = false -default['mon-agent']['syslog']['udp'] = false -default['mon-agent']['syslog']['host'] = nil -default['mon-agent']['syslog']['port'] = nil - # daemon settings -default['mon_agent']['group'] = "root" -default['mon_agent']['owner'] = "mon-agent" default['mon_agent']['data_bag'] = "mon_agent" diff --git a/metadata.rb b/metadata.rb index b1010b1..009fe6f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,6 +3,6 @@ maintainer "HP_Cloud_Monitoring" maintainer_email "hpcs-mon@hp.com" description "Installs/Configures mon-agent components" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "1.0.12" +version "1.1.0" depends 'python' recipe "mon_api::default", "Default" diff --git a/recipes/default.rb b/recipes/default.rb index 3ce8ba5..3fd819f 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -11,56 +11,12 @@ python_pip 'mon-agent' do action :upgrade end -user node['mon_agent']['owner'] do - action :create - system true - gid node['mon_agent']['group'] -end - -%w[/var/log/mon-agent /etc/mon-agent /etc/mon-agent/conf.d ].each do |dir_name| - directory dir_name do - recursive true - owner node['mon_agent']['owner'] - group node['mon_agent']['group'] - mode 0755 - action :create - end -end - -link "/etc/mon-agent/supervisor.conf" do - action :create - to '/usr/local/share/mon/agent/supervisor.conf' -end - -link "/etc/init.d/mon-agent" do - action :create - to '/usr/local/share/mon/agent/mon-agent.init' -end - -# Make the init script executable -file '/usr/local/share/mon/agent/mon-agent.init' do - action :create - mode "0755" -end - +# todo what is with the multiple levels and the repetition in the names in the data bag, fix +# todo service is a new setting in the databag setting = data_bag_item(node[:mon_agent][:data_bag], 'mon_agent') - -template "/etc/mon-agent/agent.conf" do - action :create - owner node['mon_agent']['owner'] - group node['mon_agent']['group'] - mode '644' - source "agent.conf.erb" - variables( - :setting => setting - ) - notifies :restart, "service[mon-agent]" +execute 'mon-setup' do + action :run + cmd "/usr/local/bin/mon-setup -u #{settings['username']} -p #{settings['password']} -s #{settings['service']} --keystone_url #{settings['keystone_url']} --mon_url #{settings['mon_api_url']}" end include_recipe 'mon_agent::plugin_cfg' - -service 'mon-agent' do - action [ :enable, :start ] - provider Chef::Provider::Service::Init::Debian -end - diff --git a/templates/default/agent.conf.erb b/templates/default/agent.conf.erb deleted file mode 100644 index 00b201e..0000000 --- a/templates/default/agent.conf.erb +++ /dev/null @@ -1,92 +0,0 @@ -# ========================================================================== # -# Mon-API Configuration -# ========================================================================== # -[Api] -# Monitoring API URL: URL for the monitoring API -# Example: https://region-a.geo-1.monitoring.hpcloudsvc.com/v1.1/metrics -url: <%= @setting['api']['mon_api_url']%> -# Monitoring API Project Id: Project Id for the monitoring API -project_name: <%= @setting['api']['mon_api_project_id'] %> -# Monitoring API Username: Username for the monitoring API -username: <%= @setting['api']['mon_api_username'] %> -# Monitoring API Password: Password for the monitoring API -password: <%= @setting['api']['mon_api_password'] %> -# Use Keystone for Authentication?: Use Keystone for authentication -# True or False -use_keystone: <%= @setting['api']['use_keystone'] %> -# Keystone API URL: URL for the Keystone server to use -# Example: https://region-a.geo-1.identity.hpcloudsvc.com:35357/v3/auth/tokens -keystone_url: <%= @setting['api']['keystone_url'] %> - - -[Main] -debug_mode: <%= node['mon-agent']['debug'] %> -check_freq: <%= node['mon-agent']['check_freq'] %> -hostname: <%= node.name %> -use_mount: <%= node['mon-agent']['use_mount'] ? "yes" : "no" %> -listen_port: <%= node['mon-agent']['agent_port'] %> - -# Optional dimensions to be sent with every metric from this node -# They should be in the format name:value and seperated by a comma -# Example (dimensions: service:nova, group:group_a, ...) -<% -# Dimensions may exist globally in data bags, or per-node in attributes. -# Combine as needed into a single comma-delimited string. -if @setting['dimensions'].to_s != '' and - node['mon-agent']['dimensions'].to_s != '' - dimensions = [@setting['dimensions'], - node['mon-agent']['dimensions']].join(', ') -elsif @setting['dimensions'].to_s != '' - dimensions = @setting['dimensions'] -elsif node['mon-agent']['dimensions'].to_s != '' - dimensions = node['mon-agent']['dimensions'] -end --%> -dimensions: <%= dimensions -%> - -<% if !node['mon-agent']['dogstreams'].empty? -%> -dogstreams: <%= node['mon-agent']['dogstreams'].join(', ') %> -<% end -%> - -<% if node['mon-agent']['monstatsd'] -%> -# ========================================================================== # -# MonStatsd configuration # -# ========================================================================== # -# MonStatsd is a small server that aggregates your custom app metrics. -# Make sure your client is sending to the same port. -monstatsd_port : <%= node['mon-agent']['monstatsd_port'] %> - -## The monstatsd flush period. -monstatsd_interval : <%= node['mon-agent']['monstatsd_interval'] %> - -## If 'yes', counters and rates will be normalized to 1 second (that is divided -## by the monstatsd_interval) before being sent to the server. Defaults to 'yes' -monstatsd_normalize : <%= node['mon-agent']['monstatsd_normalize'] %> - -# If you want to forward every packet received by the monstatsd server -# to another statsd server, uncomment these lines. -# WARNING: Make sure that forwarded packets are regular statsd packets and not "momonnstatsd" packets, -# as your other statsd server might not be able to handle them. -# statsd_forward_host: address_of_own_statsd_server -# statsd_forward_port: 8125 -<% end -%> - -# ========================================================================== # -# Logging -# ========================================================================== # - -log_level: <%= @setting['log_level']%> - -collector_log_file: /var/log/mon-agent/collector.log -forwarder_log_file: /var/log/mon-agent/forwarder.log -monstatsd_log_file: /var/log/mon-agent/monstatsd.log - -# if syslog is enabled but a host and port are not set, a local domain socket -# connection will be attempted -# -log_to_syslog: <%= node['mon-agent']['syslog']['active'] ? 'yes' : 'no' %> -<% if node['mon-agent']['syslog']['udp'] -%> -syslog_host: <%= node['mon-agent']['syslog']['host'] %> -syslog_port: <%= node['mon-agent']['syslog']['port'] %> -<% end -%> -disable_file_logging: <%= node['mon-agent']['disable_file_logging'] %>