Skip to content
This repository was archived by the owner on Dec 31, 2021. It is now read-only.

More config options + missing rrdtool for web interface #6

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ The [collectd_plugins](#) cookbook is not required, but provides many common plu
* 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.server_role - Name of the Chef Role to look for to identity a server. Defaults to collectd_server
* collectd.server_ip - IP address of collectd server to use

* 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.
* collectd.collectd_web.http_port - Port the virtualhost Apache listens on
* collectd.enable_rrdtool_plugin - Should this recipe enable a default rrdtool plugin? Defaults to true

# USAGE #

Expand All @@ -32,6 +36,8 @@ The client recipe will use the search index to automatically locate the server h

## Defines ##

This recipe does not install any plugins, if you want you had to include this recipe from your own recipe and add them there.

Several defines are provided to simplfy configuring plugins

### collectd_plugin ###
Expand All @@ -57,6 +63,18 @@ collectd_python_plugin "redis" do
end
```

Some plugins require you to maintain the Case Sensitivity . This cookbook follows the ruby convention to do this. Note (carbon_writer does not get install, it's just an example)

```ruby
collectd_python_plugin "carbon_writer" do
options :line_receiver_host => "127.0.0.1",
:line_receiver_port => 2003,
:differentiate_counters_over_time => true,
:lowercase_metric_names => true,
:types_db => "/usr/share/collectd/types.db"
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:

Expand All @@ -70,7 +88,7 @@ end

## Web frontend ##

The `collectd::collectd_web` recipe will automatically deploy the [collectd_web](https://github.com/httpdss/collectd-web) frontend using Apache. The
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.

Expand Down
7 changes: 7 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
default[:collectd][:types_db] = ["/usr/share/collectd/types.db"]
default[:collectd][:interval] = 10
default[:collectd][:read_threads] = 5
default[:collectd][:server_role] = "collectd_server"
default[:collectd][:server_ip] = "127.0.0.1"

# To make the collectd web out of the box we need to
# activate the rrdtool plugin on the server
default[:collectd][:enable_rrdtool_plugin] = true

default[:collectd][:collectd_web][:path] = "/srv/collectd_web"
default[:collectd][:collectd_web][:hostname] = "collectd"
default[:collectd][:collectd_web][:http_port] = 80
17 changes: 15 additions & 2 deletions recipes/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@
include_recipe "collectd"

servers = []
search(:node, 'recipes:"collectd::server"') do |n|
servers << n['fqdn']

# First look for a server role
if Chef::Config[:solo]
servers << node['collectd']['server_ip']
else
search(:node, "role:'#{node[:collectd][:server_role]}'") do |n|
servers << n['fqdn']
end

# Then check for servers that have the collectd::server recipe
if servers.empty?
search(:node, 'recipes:"collectd::server"') do |n|
servers << n['fqdn']
end
end
end

if servers.empty?
Expand Down
6 changes: 6 additions & 0 deletions recipes/collectd_web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
end

apache_site "collectd_web.conf"

if node[:collectd][:enable_rrdtool_plugin]
collectd_plugin "rrdtool" do
options :DataDir => node[:collectd][:base_dir], :CacheFlush => 120
end
end
2 changes: 1 addition & 1 deletion templates/default/collectd_web.conf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<VirtualHost *:80>
<VirtualHost *:<%= @node[:collectd][:collectd_web][:http_port] %>>
ServerName <%= @node[:collectd][:collectd_web][:hostname] %>

DocumentRoot <%= @node[:collectd][:collectd_web][:path] %>
Expand Down
4 changes: 2 additions & 2 deletions templates/default/collection.conf.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
datadir: "/var/lib/collectd/rrd/"
libdir: "/usr/lib/collectd/"
datadir: "<%= node[:collectd][:base_dir] %>"
libdir: "<%= node[:collectd][:plugin_dir] %>"