Skip to content

Commit

Permalink
Rewrites the collectd cookbook to utilize Poise.
Browse files Browse the repository at this point in the history
This is a complete rewrite of the collectd cookbook. It utilizes the
best practices set forth by the Poise and Poise Service cookbooks.
  • Loading branch information
John Bellone committed Aug 31, 2015
1 parent f0f1d68 commit 5db2a92
Show file tree
Hide file tree
Showing 42 changed files with 912 additions and 471 deletions.
54 changes: 53 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
metadata.json
# Ignore docs files
_gh_pages
_site
.ruby-version
.node-version
Gemfile.lock

# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.vi
*~

# OS or Editor folders
.DS_Store
._*
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.sublime-project
*.sublime-workspace
.idea

# Komodo
*.komodoproject
.komodotools

# grunt-html-validation
validation-status.json
validation-report.json

# Folders to ignore
bin
node_modules
tmp
vendor
.bundle

# Chef specifics to ignore
.chef
.chefdk
.kitchen
.vagrant
Berksfile.lock
28 changes: 28 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
driver:
name: vagrant

provisioner:
name: chef_zero

platforms:
- name: ubuntu-14.04
- name: ubuntu-12.04
- name: ubuntu-10.04
- name: centos-7.1
- name: centos-6.6
- name: centos-5.11

suites:
- name: default
run_list:
- recipe[collectd::default]
- name: server
run_list:
- recipe[collectd::server]
- name: client
run_list:
- recipe[collectd::client]
- name: web
run_list:
- recipe[collectd::web]
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--default-path test/spec
--color
43 changes: 43 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
AlignParameters:
Enabled: false

Encoding:
Enabled: false

ClassLength:
Enabled: false

MethodLength:
Enabled: false

LineLength:
Enabled: false

Documentation:
Enabled: false

PerceivedComplexity:
Enabled: false

CyclomaticComplexity:
Enabled: false

Style/FileName:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Metrics/AbcSize:
Enabled: false

AllCops:
Exclude:
- 'Guardfile'
- 'test/**/*_test.rb'
- 'test/**/*_spec.rb'
- 'bin/**'

Style/GuardClause:
Enabled: false
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
language: ruby
notifications:
slack: bloomberg-rnd:eHp3Czg42iGzaTgG8sAFeD9v
install:
- bundle install --retry 3 --without kitchen_vagrant kitchen_cloud
- bundle exec berks install
script: bundle exec rake travis
rvm:
- 2.1
- 2.2
cache:
directories:
- vendor/bundle
branches:
only:
- master
builder_args: --jobs 7
matrix:
fast_finish: true
5 changes: 5 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--plugin classmethods
--embed-mixin ClassMethods
--hide-api private
--markup markdown
--hide-void-return
2 changes: 2 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source 'https://supermarket.chef.io'
metadata
44 changes: 44 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
source 'https://rubygems.org'
gem 'poise', '~> 2.2'
gem 'poise-service', '~> 1.0'
gem 'poise-boiler'

group :lint do
gem 'rubocop'
gem 'foodcritic'
end

group :kitchen_common do
gem 'test-kitchen', '~> 1.4'
end

group :kitchen_vagrant do
gem 'kitchen-vagrant', '~> 0.17'
end

group :kitchen_cloud do
gem 'kitchen-openstack', '~> 1.8'
end

group :unit do
gem 'berkshelf'
gem 'chefspec'
end

group :integration do
gem 'serverspec'
end

group :development do
gem 'awesome_print'
gem 'guard'
gem 'guard-kitchen'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'rake'
gem 'stove'
end

group :doc do
gem 'yard'
end
21 changes: 21 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
guard 'foodcritic', cookbook_paths: '.', cli: '-t ~FC023 -t ~FC005', all_on_start: false do
watch(%r{^(?:recipes|libraries|providers|resources)/.+\.rb$})
watch('metadata.rb')
end

# More info at https://github.com/guard/guard#readme
guard 'rubocop' do
watch(%r{^attributes/.+\.rb$})
watch(%r{^providers/.+\.rb$})
watch(%r{^recipes/.+\.rb$})
watch(%r{^resources/.+\.rb$})
watch(%r{^libraries/.+\.rb$})
watch('metadata.rb')
end

guard :rspec, cmd: 'bin/rspec', all_on_start: false, notification: false do
watch(%r{^(recipes|libraries|providers|resources)/(.+)\.rb$}) do |m|
"test/spec/#{m[0]}/#{m[1]}_spec.rb"
end
watch('test/spec/spec_helper.rb') { 'test/spec' }
end
14 changes: 14 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright 2010, Atari, Inc
Copyright 2015, Bloomberg Finance L.P.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
135 changes: 47 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,51 @@
# DESCRIPTION #

Configure and install the [collectd](http://collectd.org/) monitoring daemon.

# REQUIREMENTS #

This cookbook has only been tested on Ubuntu 10.04.

To use the `collectd::collectd_web` recipe you need the [apache2](https://github.com/opscode/cookbooks/tree/master/apache2) cookbook.

The [collectd_plugins](https://github.com/coderanger/chef-collectd_plugins) cookbook is not required, but provides many common plugin definitions for easy reuse.

# ATTRIBUTES #

* collectd.basedir - Base folder for collectd output data.
* collectd.plugin_dir - Base folder to find plugins.
* collectd.types_db - Array of files to read graph type information from.
* collectd.interval - Time period in seconds to wait between data reads.

* collectd.collectd_web.path - Location to install collectd_web to. Defaults to /srv/collectd_web.
* collectd.collectd_web.hostname - Server name to use for collectd_web Apache site.

# USAGE #

Three main recipes are provided:

* collectd - Install a standalone daemon.
* collectd::client - Install collectd and configure it to send data to a server.
* collectd::server - Install collectd and configure it to recieve data from clients.

The client recipe will use the search index to automatically locate the server hosts, so no manual configuration is required.

## Defines ##

Several defines are provided to simplfy configuring plugins

### collectd_plugin ###

The `collectd_plugin` define configures and enables standard collect plugins. Example:

# collectd-cookbook
[![Build Status](https://img.shields.io/travis/coderanger/chef-collectd.svg)](https://travis-ci.org/coderanger/chef-collectd)
[![Gem Version](https://img.shields.io/gem/v/poise.svg)](https://rubygems.org/gems/poise)
[![Cookbook Version](https://img.shields.io/cookbook/v/poise.svg)](https://supermarket.chef.io/cookbooks/poise)
[![Coverage](https://img.shields.io/codecov/c/github/coderanger/chef-collectd.svg)](https://codecov.io/github/coderanger/chef-collectd)
[![Gemnasium](https://img.shields.io/gemnasium/coderanger/chef-collectd.svg)](https://gemnasium.com/coderanger/chef-collectd)
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

[Application cookbook][0] which installs and configures the
[collectd monitoring daemon][1].

This cookbook provides a dead-simple installation and configuration of
the collectd monitoring daemon. It provides two resources: the first
is for managing the collectd system service, and the second is for
configuring the daemon's plugins. Additionally, the
[collectd_plugins cookbook][4] may be used to configure many of the
common plugins that ship with the daemon.

It is very important to note that distributions may ship different
major versions of the package, but the following platforms are tested
using the integration tests via [Test Kitchen][2].
- Ubuntu ~> 10.04, 12.04, 14.04
- CentOS ~> 5.8, 6.4, 7.1
- RHEL ~> 5.8, 6.4, 7.1

## Basic Usage
The [default recipe](recipes/default.rb) in this cookbook simply
configures the monitoring daemon to run as a system service. The
configuration for this service can be tuned using the
[node attributes](attributes/default.rb). Additionally, a resource is
provided to configure plugins for the daemon. After a plugin has been
configured the daemon should be restarted.

### Enabling Syslog
One of the simplest plugins to enable is the [collectd Syslog plugin][3]
which receives log messages from the daemon and dispatches them to the
to syslog. This allows the daemon's logs to easily integrate with
existing UNIX utilities.
```ruby
collectd_plugin "interface" do
options :interface=>"lo", :ignore_selected=>true
collectd_plugin 'syslog' do
options do
log_level 'info'
notify_level 'OKAY'
end
end
```

The options hash is converted to collectd-style settings automatically. Any symbol key will be converted to camel-case. In the above example :ignore_selected will be output as the
key "IgnoreSelected". If the key is already a string, this conversion is skipped. If the value is an array, it will be output as a separate line for each element.

### collectd_python_plugin ###

The `collectd_python_plugin` define configures and enables Python plugins using the collectd-python plugin. Example:

```ruby
collectd_python_plugin "redis" do
options :host=>servers, :verbose=>true
end
```

Options are interpreted in the same way as with `collectd_plugin`. This define will not deploy the plugin script as well, so be sure to setup a cookbook_file resource
or other mechanism to handle distribution. Example:

```ruby
cookbook_file File.join(node[:collectd][:plugin_dir], "redis.py") do
owner "root"
group "root"
mode "644"
end
```

## Web frontend ##

The `collectd::collectd_web` recipe will automatically deploy the [collectd_web](https://github.com/httpdss/collectd-web) frontend using Apache. The
[apache2](https://github.com/opscode/cookbooks/tree/master/apache2) cookbook is required for this and is *not* included automatically as this is an optional
component, so be sure to configure the node with the correct recipes.

# LICENSE & AUTHOR #

Author:: Noah Kantrowitz (<[email protected]>)
Copyright:: 2010, Atari, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
[0]: http://blog.vialstudios.com/the-environment-cookbook-pattern#theapplicationcookbook
[1]: https://collectd.org
[2]: https://github.com/test-kitchen/test-kitchen
[3]: https://collectd.org/wiki/index.php/Plugin:SysLog
Loading

0 comments on commit 5db2a92

Please sign in to comment.