Merge pull request #6 from hpcloud-mon/feature/mon_setup
Switch to using mon-setup
This commit is contained in:
commit
5fa86b9ec4
22
README.md
22
README.md
|
@ -12,25 +12,19 @@ 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",
|
||||
"project_name": "worldpeace",
|
||||
"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
|
||||
|
|
|
@ -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"
|
||||
default['mon_agent']['plugin'] = {}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
default['mon-agent']['network']['instances'] = [
|
||||
{
|
||||
'collect_connection_state' => 'false',
|
||||
'excluded_interfaces' => ['lo', 'lo0']
|
||||
}
|
||||
]
|
|
@ -1,64 +0,0 @@
|
|||
#### agent plugin checks for basenode
|
||||
|
||||
# Host alive check for api server
|
||||
|
||||
node.default[:mon_agent][:plugin][:host_alive][:init_config] = {
|
||||
:ssh_port => 22,
|
||||
:ssh_timeout => 0.5,
|
||||
:ping_timeout => 1
|
||||
}
|
||||
|
||||
node.default[:mon_agent][:plugin][:host_alive][:instances][:api_with_ssh] = {
|
||||
:name => "api_ssh_port",
|
||||
:host_name => "192.168.10.4",
|
||||
:alive_test => "ssh"
|
||||
}
|
||||
|
||||
# Process checks: Everyone should be running ssh/sshd and ntpd
|
||||
|
||||
node.default[:mon_agent][:plugin][:process][:init_config] = {
|
||||
}
|
||||
|
||||
node.default[:mon_agent][:plugin][:process][:instances][:ssh] = {
|
||||
:name => "ssh",
|
||||
:search_string => ["ssh", "sshd"]
|
||||
}
|
||||
node.default[:mon_agent][:plugin][:process][:instances][:ntpd] = {
|
||||
:name => "ntpd",
|
||||
:search_string => ["/usr/sbin/ntpd"],
|
||||
:exact_match => "True"
|
||||
}
|
||||
|
||||
# Service checks: For demo, everyone can check mon api
|
||||
|
||||
node.default[:mon_agent][:plugin][:http_check][:init_config] = {
|
||||
}
|
||||
|
||||
node.default[:mon_agent][:plugin][:http_check][:instances][:monapi] = {
|
||||
:name => "mon_api",
|
||||
:url => "http://192.168.10.4:8080",
|
||||
:timeout => 10,
|
||||
:collect_response_time => "true",
|
||||
:match_pattern => '.*status.*CURRENT.*',
|
||||
}
|
||||
node.default[:mon_agent][:plugin][:http_check][:instances][:monapi_health] = {
|
||||
:name => "mon_api_health",
|
||||
:url => "http://192.168.10.4:8081/healthcheck",
|
||||
:timeout => 10,
|
||||
:include_content => "true",
|
||||
:collect_response_time => "true",
|
||||
:match_pattern => '.*"healthy":true.*"healthy":true.*"healthy":true.*',
|
||||
}
|
||||
|
||||
# mon_nagios_wrapper checks: For demo, everyone can check disk
|
||||
#
|
||||
#node.default[:mon_agent][:plugin][:nagios_wrapper][:init_config] = {
|
||||
# :check_path => "/usr/lib/nagios/plugins:/usr/local/bin/nagios"
|
||||
#}
|
||||
#
|
||||
#node.default[:mon_agent][:plugin][:nagios_wrapper][:instances][:check_disk] = {
|
||||
# :name => "local_disk"
|
||||
# :service_name => "disk",
|
||||
# :check_command => "check_disk -w 15\\% -c 5\\% -A -i /srv/node",
|
||||
# :check_interval => 300
|
||||
#}
|
|
@ -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"
|
||||
|
|
|
@ -1,66 +1,21 @@
|
|||
include_recipe "python"
|
||||
|
||||
# Pre-reqs that when installed by os package avoid compilation by pip
|
||||
%w[python-psutil python-pymongo python-yaml supervisor sysstat].each do |pkg_name|
|
||||
%w[python-pymongo python-yaml supervisor sysstat].each do |pkg_name|
|
||||
package pkg_name do
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
||||
settings = data_bag_item(node[:mon_agent][:data_bag], 'mon_agent')
|
||||
execute 'mon-setup' do
|
||||
action :nothing
|
||||
command "/usr/local/bin/mon-setup -u #{settings['username']} -p #{settings['password']} -s #{settings['service']} --keystone_url #{settings['keystone_url']} --project_name #{settings['project_name']} --mon_url #{settings['mon_api_url']}"
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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]"
|
||||
action :install
|
||||
notifies :run, "execute[mon-setup]"
|
||||
end
|
||||
|
||||
include_recipe 'mon_agent::plugin_cfg'
|
||||
|
||||
service 'mon-agent' do
|
||||
action [ :enable, :start ]
|
||||
provider Chef::Provider::Service::Init::Debian
|
||||
end
|
||||
|
||||
|
|
|
@ -3,30 +3,18 @@
|
|||
# Recipe:: plugin_cfg
|
||||
#
|
||||
|
||||
# Common configuration
|
||||
service "mon-agent" do
|
||||
action :enable
|
||||
supports :restart => true
|
||||
end
|
||||
|
||||
# Load nagios-plugins package if it's needed
|
||||
package 'nagios-plugins-basic' do
|
||||
action :install
|
||||
only_if { node[:mon_agent][:plugin].has_key?(:nagios_wrapper) }
|
||||
end
|
||||
|
||||
# Make sure the datadog conf.d directory exists
|
||||
directory "/etc/mon-agent/conf.d" do
|
||||
recursive true
|
||||
action :create
|
||||
owner node['mon_agent']['owner']
|
||||
group node['mon_agent']['group']
|
||||
mode 0755
|
||||
end
|
||||
|
||||
# Configures the plugin yaml files based on node[:mon_agent][:plugin]
|
||||
# attributes
|
||||
node[:mon_agent][:plugin].each_key do |plugin|
|
||||
if not node[:mon_agent][:plugin][plugin].has_key?(:init_config):
|
||||
node[:mon_agent][:plugin][plugin][:init_config] = {}
|
||||
end
|
||||
template "/etc/mon-agent/conf.d/#{plugin}.yaml" do
|
||||
source "plugin_yaml.erb"
|
||||
action :create
|
||||
|
@ -37,6 +25,6 @@ node[:mon_agent][:plugin].each_key do |plugin|
|
|||
:init_config => node[:mon_agent][:plugin][plugin][:init_config],
|
||||
:instances => node[:mon_agent][:plugin][plugin][:instances]
|
||||
)
|
||||
notifies :restart, "service[mon-agent]"
|
||||
notifies :run, "execute[mon-setup]"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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'] %>
|
|
@ -15,14 +15,18 @@ instances:
|
|||
<% inst.sort.each do |key, value| %>
|
||||
<% if new_item %>
|
||||
<% if value.is_a?(Array) %>
|
||||
<%= " - #{key}: "%> [<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>]
|
||||
<%= " - #{key}: "%>[<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>]
|
||||
<% elsif value.is_a?(Hash) %>
|
||||
<%= " - #{key}: "%><%= value.sort.map { |hkey, hval| %Q/#{hkey}:#{hval}/ }.join(', ') %>
|
||||
<% else %>
|
||||
<%= " - #{key}: #{value}" %>
|
||||
<% end %>
|
||||
<% new_item = FALSE %>
|
||||
<% else %>
|
||||
<% if value.is_a?(Array) %>
|
||||
<%= " #{key}: "%> [<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>]
|
||||
<%= " #{key}: "%>[<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>]
|
||||
<% elsif value.is_a?(Hash) %>
|
||||
<%= " #{key}: "%>[<%= value.sort.map { |hkey, hval| %Q/#{hkey}:#{hval}/ }.join(', ') %>
|
||||
<% else %>
|
||||
<%= " #{key}: #{value}" %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue