Name changes for the agent package.
Added initial ChefSpec files Change-Id: I7ee471dfef4e592672046e0543727216cf664a82
This commit is contained in:
parent
0058373a3d
commit
f0979a143a
|
@ -0,0 +1,2 @@
|
||||||
|
.project
|
||||||
|
Berksfile.lock
|
30
README.md
30
README.md
|
@ -1,23 +1,23 @@
|
||||||
cookbooks-mon-agent
|
cookbooks-monasca-agent
|
||||||
===================
|
===================
|
||||||
|
|
||||||
# Overview
|
# Overview
|
||||||
This cookbook installs and configures the [Monitoring Agent](https://github.com/hpcloud-mon/mon-agent)
|
This cookbook installs and configures the [Monasca Monitoring Agent](https://github.com/stackforge/monasca-agent)
|
||||||
|
|
||||||
# Data Bags
|
# Data Bags
|
||||||
For use with configuration, the `mon_agent` data bag contains parameters
|
For use with configuration, the `monasca_agent` data bag contains parameters
|
||||||
for interfacing with the Monitoring API, global dimensions (a set of
|
for interfacing with the Monitoring API, global dimensions (a set of
|
||||||
comma-delimited name:value pairs to be included in the Agent metrics),
|
comma-delimited name:value pairs to be included in the Agent metrics),
|
||||||
and logging levels.
|
and logging levels.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
{
|
{
|
||||||
"id": "mon_agent",
|
"id": "monasca_agent",
|
||||||
"keystone_url": "http://192.168.10.4:5000/v2.0",
|
"keystone_url": "http://192.168.10.4:5000/v2.0",
|
||||||
"username": "joe_user",
|
"username": "joe_user",
|
||||||
"password": "correcthorsebatterystaple",
|
"password": "correcthorsebatterystaple",
|
||||||
"project_name": "worldpeace",
|
"project_name": "worldpeace",
|
||||||
"mon_api_url": "http://192.168.10.4:8080/v2.0",
|
"monasca_api_url": "http://192.168.10.4:8080/v2.0",
|
||||||
"service": "mini-mon"
|
"service": "mini-mon"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,23 +27,23 @@ and logging levels.
|
||||||
The default recipe sets up the Monitoring Agent and runs mon-setup to configure.
|
The default recipe sets up the Monitoring Agent and runs mon-setup to configure.
|
||||||
|
|
||||||
## plugin_cfg
|
## plugin_cfg
|
||||||
mon-agent plugins are configured in `/etc/mon-agent/conf.d/` as YAML files ending
|
monasca-agent plugins are configured in `/etc/monasca-agent/conf.d/` as YAML files ending
|
||||||
in .yaml which are created by this recipe. The Agent will walk through these
|
in .yaml which are created by this recipe. The Agent will walk through these
|
||||||
files when the Collector (`/usr/local/bin/mon-collector`) starts. The name of
|
files when the Collector (`/usr/local/bin/monasca-collector`) starts. The name of
|
||||||
the file must match a Python plugin in `/etc/mon-agent/checks.d/` or
|
the file must match a Python plugin in `/etc/monasca-agent/checks.d/` or
|
||||||
`/usr/local/lib/python2.7/dist-packages/monagent/collector/checks_d/`
|
`/usr/local/lib/python2.7/dist-packages/monagent/collector/checks_d/`
|
||||||
|
|
||||||
- `conf.d/` file: `process.yaml`
|
- `conf.d/` file: `process.yaml`
|
||||||
- `checks_d/` file: `process.py`
|
- `checks_d/` file: `process.py`
|
||||||
- data bag item: `node.default[:mon_agent][:plugin][:process]`
|
- data bag item: `node.default[:monasca_agent][:plugin][:process]`
|
||||||
|
|
||||||
The .yaml files are comprised of two different sections, `init_config`
|
The .yaml files are comprised of two different sections, `init_config`
|
||||||
containing global configuration parameters, and 'instances' containing one or
|
containing global configuration parameters, and 'instances' containing one or
|
||||||
more stanzas containing details about the particular check to run. These are
|
more stanzas containing details about the particular check to run. These are
|
||||||
defined in
|
defined in
|
||||||
`node.default[:mon_agent][:plugin][:process][:init_config]`
|
`node.default[:monasca_agent][:plugin][:process][:init_config]`
|
||||||
and
|
and
|
||||||
`node.default[:mon_agent][:plugin][:process][:instances]`
|
`node.default[:monasca_agent][:plugin][:process][:instances]`
|
||||||
respectively.
|
respectively.
|
||||||
|
|
||||||
The `nagios_wrapper` is a special case in the `plugin_cfg` recipe in that
|
The `nagios_wrapper` is a special case in the `plugin_cfg` recipe in that
|
||||||
|
@ -55,8 +55,8 @@ installed to provide many standard Nagios plugins.
|
||||||
These are global attributes for use with the agent.conf file and installation
|
These are global attributes for use with the agent.conf file and installation
|
||||||
settings.
|
settings.
|
||||||
|
|
||||||
With the case of dimensions, `default['mon-agent']['dimensions'] = nil` appends
|
With the case of dimensions, `default['monasca-agent']['dimensions'] = nil` appends
|
||||||
to the list of dimensions, if any, specified in the `mon_agent` data bag.
|
to the list of dimensions, if any, specified in the `monasca_agent` data bag.
|
||||||
|
|
||||||
## network
|
## network
|
||||||
These attributes configure the network plugin.
|
These attributes configure the network plugin.
|
||||||
|
@ -64,11 +64,11 @@ These attributes configure the network plugin.
|
||||||
## plugin_config_basenode
|
## plugin_config_basenode
|
||||||
These attributes configure a basic set of plugins to be installed on every instance.
|
These attributes configure a basic set of plugins to be installed on every instance.
|
||||||
These are in addition to the Monitoring Agent's existing set of basic metrics, listed
|
These are in addition to the Monitoring Agent's existing set of basic metrics, listed
|
||||||
on the [mon-agent wiki](https://github.com/hpcloud-mon/mon-agent/wiki/mon-agent-User-Guide#standard-set-of-dimensions)
|
on the [monasca-agent wiki](https://github.com/hpcloud-mon/mon-agent/wiki/mon-agent-User-Guide#standard-set-of-dimensions)
|
||||||
|
|
||||||
# Templates
|
# Templates
|
||||||
## agent.conf.erb
|
## agent.conf.erb
|
||||||
This is the primary configuration file for the Agent, in `/etc/mon-agent/agent.conf`
|
This is the primary configuration file for the Agent, in `/etc/monasca-agent/agent.conf`
|
||||||
|
|
||||||
## plugin_yaml.erb
|
## plugin_yaml.erb
|
||||||
This template provides the basis for plugin .yaml configuration files.
|
This template provides the basis for plugin .yaml configuration files.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# encoding: UTF-8#
|
# encoding: UTF-8#
|
||||||
#
|
#
|
||||||
default[:mon_agent][:data_bag] = 'mon_agent'
|
default[:monasca_agent][:data_bag] = 'monasca_agent'
|
||||||
default[:mon_agent][:plugin] = {}
|
default[:monasca_agent][:plugin] = {}
|
||||||
|
|
10
metadata.rb
10
metadata.rb
|
@ -1,10 +1,10 @@
|
||||||
# encoding: UTF-8#
|
# encoding: UTF-8#
|
||||||
#
|
#
|
||||||
name 'mon_agent'
|
name 'monasca_agent'
|
||||||
maintainer 'HP_Cloud_Monitoring'
|
maintainer 'monasca'
|
||||||
maintainer_email 'hpcs-mon@hp.com'
|
maintainer_email 'monasca@lists.launchpad.net'
|
||||||
description 'Installs/Configures mon-agent components'
|
description 'Installs/Configures monasca-agent components'
|
||||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||||
version '1.1.2'
|
version '1.1.3'
|
||||||
depends 'python'
|
depends 'python'
|
||||||
recipe 'mon_api::default', 'Default'
|
recipe 'mon_api::default', 'Default'
|
||||||
|
|
|
@ -9,15 +9,15 @@ include_recipe 'python'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
settings = data_bag_item(node[:mon_agent][:data_bag], 'mon_agent')
|
settings = data_bag_item(node[:monasca_agent][:data_bag], 'monasca_agent')
|
||||||
execute 'mon-setup' do
|
execute 'monasca-setup' do
|
||||||
action :nothing
|
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']}"
|
command "/usr/local/bin/monasca-setup -u #{settings['username']} -p #{settings['password']} -s #{settings['service']} --keystone_url #{settings['keystone_url']} --project_name #{settings['project_name']} --monasca_url #{settings['monasca_api_url']}"
|
||||||
end
|
end
|
||||||
|
|
||||||
python_pip 'mon-agent' do
|
python_pip 'monasca-agent' do
|
||||||
action :install
|
action :install
|
||||||
notifies :run, 'execute[mon-setup]'
|
notifies :run, 'execute[monasca-setup]'
|
||||||
end
|
end
|
||||||
|
|
||||||
include_recipe 'mon_agent::plugin_cfg'
|
include_recipe 'monasca_agent::plugin_cfg'
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
# encoding: UTF-8#
|
# encoding: UTF-8#
|
||||||
#
|
#
|
||||||
# Cookbook Name:: mon_agent
|
# Cookbook Name:: monasca_agent
|
||||||
# Recipe:: plugin_cfg
|
# Recipe:: plugin_cfg
|
||||||
#
|
#
|
||||||
|
|
||||||
# Load nagios-plugins package if it's needed
|
# Load nagios-plugins package if it's needed
|
||||||
package 'nagios-plugins-basic' do
|
package 'nagios-plugins-basic' do
|
||||||
action :install
|
action :install
|
||||||
only_if { node[:mon_agent][:plugin].key?(:nagios_wrapper) }
|
only_if { node[:monasca_agent][:plugin].key?(:nagios_wrapper) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Configures the plugin yaml files based on node[:mon_agent][:plugin]
|
# Configures the plugin yaml files based on node[:monasca_agent][:plugin]
|
||||||
# attributes
|
# attributes
|
||||||
node[:mon_agent][:plugin].each_key do |plugin|
|
node[:monasca_agent][:plugin].each_key do |plugin|
|
||||||
unless node[:mon_agent][:plugin][plugin].key?(:init_config)
|
unless node[:monasca_agent][:plugin][plugin].key?(:init_config)
|
||||||
node.normal[:mon_agent][:plugin][plugin][:init_config] = {}
|
node.normal[:monasca_agent][:plugin][plugin][:init_config] = {}
|
||||||
end
|
end
|
||||||
template "/etc/mon-agent/conf.d/#{plugin}.yaml" do
|
template "/etc/monasca-agent/conf.d/#{plugin}.yaml" do
|
||||||
source 'plugin_yaml.erb'
|
source 'plugin_yaml.erb'
|
||||||
action :create
|
action :create
|
||||||
owner node[:mon_agent][:owner]
|
owner node[:monasca_agent][:owner]
|
||||||
group node[:mon_agent][:group]
|
group node[:monasca_agent][:group]
|
||||||
mode 0644
|
mode 0644
|
||||||
variables(
|
variables(
|
||||||
init_config: node[:mon_agent][:plugin][plugin][:init_config],
|
init_config: node[:monasca_agent][:plugin][plugin][:init_config],
|
||||||
instances: node[:mon_agent][:plugin][plugin][:instances]
|
instances: node[:monasca_agent][:plugin][plugin][:instances]
|
||||||
)
|
)
|
||||||
notifies :run, 'execute[mon-setup]'
|
notifies :run, 'execute[monasca-setup]'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Encoding: utf-8
|
||||||
|
require_relative 'spec_helper'
|
||||||
|
|
||||||
|
def nothing_execute(resource_name)
|
||||||
|
ChefSpec::Matchers::ResourceMatcher.new(:execute, :nothing, resource_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'monasca_agent::default' do
|
||||||
|
describe 'ubuntu' do
|
||||||
|
include_context 'monasca_stubs'
|
||||||
|
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||||
|
let(:node) { runner.node }
|
||||||
|
let(:chef_run) do
|
||||||
|
node.set['monasca']['data_bag'] = 'monasca_agent'
|
||||||
|
runner.converge(described_recipe)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes the other recipes' do
|
||||||
|
expect(chef_run).to include_recipe('python')
|
||||||
|
expect(chef_run).to include_recipe('monasca_agent::plugin_cfg')
|
||||||
|
end
|
||||||
|
|
||||||
|
%w(python-pymongo python-yaml supervisor sysstat).each do |pkg|
|
||||||
|
it "installs package #{pkg}" do
|
||||||
|
expect(chef_run).to install_package pkg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'python_pip installs monasca-agent' do
|
||||||
|
expect(chef_run).to install_python_pip 'monasca-agent'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'executes the monasca-setup program' do
|
||||||
|
execute = chef_run.execute('monasca-setup')
|
||||||
|
expect(execute).to do_nothing
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,2 +0,0 @@
|
||||||
# encoding: UTF-8
|
|
||||||
# No unit tests at this time.
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Encoding: utf-8
|
||||||
|
require_relative 'spec_helper'
|
||||||
|
|
||||||
|
describe 'monasca_agent::plugin_cfg' do
|
||||||
|
describe 'ubuntu' do
|
||||||
|
include_context 'monasca_stubs'
|
||||||
|
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||||
|
let(:node) { runner.node }
|
||||||
|
let(:chef_run) do
|
||||||
|
node.set['monasca_agent']['plugin'] = 'monasca_agent'
|
||||||
|
runner.converge(described_recipe)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,36 @@
|
||||||
|
# encoding: UTF-8
|
||||||
|
require 'chefspec'
|
||||||
|
require 'chefspec/berkshelf'
|
||||||
|
|
||||||
|
ChefSpec::Coverage.start! { add_filter 'monasca_agent' }
|
||||||
|
|
||||||
|
require 'chef/application'
|
||||||
|
|
||||||
|
LOG_LEVEL = :fatal
|
||||||
|
SUSE_OPTS = {
|
||||||
|
platform: 'suse',
|
||||||
|
version: '11.3',
|
||||||
|
log_level: ::LOG_LEVEL
|
||||||
|
}
|
||||||
|
REDHAT_OPTS = {
|
||||||
|
platform: 'redhat',
|
||||||
|
version: '6.5',
|
||||||
|
log_level: ::LOG_LEVEL
|
||||||
|
}
|
||||||
|
UBUNTU_OPTS = {
|
||||||
|
platform: 'ubuntu',
|
||||||
|
version: '12.04',
|
||||||
|
log_level: ::LOG_LEVEL
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_context 'monasca_stubs' do
|
||||||
|
before do
|
||||||
|
stub_data_bag_item('monasca_agent', 'monasca_agent').and_return(
|
||||||
|
'keystone_url' => 'http://192.168.10.5:35357/v3',
|
||||||
|
'username' => 'mini-mon',
|
||||||
|
'password' => 'password',
|
||||||
|
'project_name' => 'mini-mon',
|
||||||
|
'monasca_api_url' => 'http://192.168.10.4:8080/v2.0',
|
||||||
|
'service' => 'mini-mon')
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue