Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Repository files navigation

Description

This cookbook provides providers and resources to configure and manage Diamond Diamond is a python daemon that collects system metrics and publishes them to Graphite. It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.

Requirements

Chef Version

Requires Chef 11 or higher.

Cookbooks

Opscode Cookbooks:

  • build-essential
  • python
  • git

Default Collectors

Diamond has the following Collectors enabled by default:
Cpu, DiskSpace, DiskUsage, LoadAvg, Memory, SockStat, Vmstat.

Resources and Providers

This cookbook provides three resources and corresponding providers.

install.rb

Install Diamond with this resource.

Actions:

  • git - Clones the source from Github and installs using python setup.py install
  • tarball - Fetches a tarball containing using HTTP and installs using python setup.py install

Attribute Parameters:

diamond::install

AttributeTypeDescriptionDefault
prefixStringPrefix of where to install diamond to/opt/diamond
git_repository_uriStringLocation of where the cookbook fetches Diamond from to installhttps://github.com/python-diamond/Diamond.git
git_referenceStringWhich git reference to install Diamond frommaster
required_python_packagesHashList of python packages to install for Diamond{ "configobj" => "4.7.2","psutil" => "1.2.1"}>
cookbookStringName of the cookbook that holds the erb templatesdiamond
tarball_pathStringUrl of the Tarball to install Diamond withhttps://github.com/python-diamond/Diamond/archive/master.tar.gz
tarball_extract_fldrStringName of the directory that holds Diamond in the tarballDiamond-master

configure.rb

Configure Diamond with this resource.

Actions:

  • config - Creates #{new_resource.prefix}/etc/diamond/diamond.conf

Attribute Parameters:

diamond::configure

AttributeTypeDescriptionDefault
cookbookStringName of the cookbook that holds the erb templatesdiamond
runit_nameStringName of the runit service to restart when modifying this configurationdiamond
diamond_configuration_source>StringName of the ERB Template used to generate diamond.confdiamond.conf.erb
diamond_handlersArrayArray of the Handlers to configure Diamond with["diamond.handler.graphitepickle.GraphitePickleHandler"]
diamond_userStringName of the user for diamond to run as
diamond_groupStringName of the group the diamond user will run as
collectors_config_pathStringPath where Diamond will store and retrieve configuration files for the Collectors/opt/diamond/etc/diamond/collectors
diamond_collectors_pathStringDirectory where the collectors are installed/opt/diamond/share/diamond/collectors
archive_handlerHashConfiguration parameters for the archive handler{ "log_file" => "/var/log/diamond/diamond.log", "days" => 7 }
graphite_handlerHashConfiguration parameters for the graphite handler{ "host" => "localhost", "port" => 2003, "batch" => 256, "timeout" => 15 }
graphite_picklehandlerHashConfiguration parameters for the graphite pickle handler{ "host" => "localhost", "port" => 2004, "batch" => 256, "timeout" => 15 }
statsdhandlerHashConfiguration parameters for the statsd handler{ "host" => "127.0.0.1", "port" => 8125 }
tsdbhandlerHashConfiguration parameters for the tsdb handler{ "host" => "127.0.0.1", "port" => 4242, "timeout" => 15 }
mysqlhandlerHashConfiguration parameters for the mysql handler{ "host" => "127.0.0.1", "port" => 3306, "username" => String.new, "password" => String.new, "database" => "diamond", "table" => "metrics", "col_time" => "timestamp", "col_metric" => "metric", "col_value" => "value" }
collectorsHashConfiguration for the collectors allowing you to configure suffix, prefix, how to determine hostname and/or set the hostname manually{ "hostname_method" => "fqdn_short", "hostname" => String.new, "path_prefix" => String.new, "path_suffix" => String.new, "interval" => 300 }

plugin.rb

Enable / Disable plugins with this resource.

Actions:

  • enable - Creates a configuration file for the collector specified and restarts Diamond
  • disable - Deletes the configuration file for the collector specified and restarts Diamond

diamond::plugin

AttributeTypeDescriptionDefault
sourceStringName of the ERB Template to be used generating the Collector configuration filesgeneric_collector_config.conf.erb
cookbookStringName of the cookbook holding the ERB template for the source attribute/opt/diamond/etc/diamond/collectors
runit_nameStringName of the runit service to restart when modifying this plugindiamond
optionsHashAllows you to specify options outside of enabling a collector

Generic Usage

The following example will just configure Diamond with the GraphiteHandler and with the default collectors enabled only.

diamond_install"#{node['hostname']}"doaction:gitenddiamond_configure"#{node['hostname']}"doaction:configdiamond_handlers["diamond.handler.graphite.GraphiteHandler"]graphite_handler({"host"=>"127.0.0.1","port"=>2003,"timeout"=>15})end

Basic Usage with Plugins

The following example will configure Diamond with the archive.ArchiveHandler and graphite.GraphiteHandler with the PingCollector and CPUCollector enabled.

diamond_install"#{node['hostname']}"doaction:gitenddiamond_configure"#{node['hostname']}"doaction:configdiamond_handlers["diamond.handler.archive.ArchiveHandler","diamond.handler.graphite.GraphiteHandler"]graphite_handler({"host"=>"127.0.0.1","port"=>2003,"timeout"=>15})enddiamond_plugin"CPUCollector"doaction:enableoptions({})enddiamond_plugin"PingCollector"doaction:enableoptions({"enabled"=>"True","bin"=>"/bin/ping","use_sudo"=>"False","sudo_cmd"=>"/usr/bin/sudo","target_1"=>"google.com","target_2"=>"aol.com"})end

Advanced Usage with Custom Collectors Installed

diamond_install"#{node['hostname']}"doaction:gitenddiamond_configure"#{node['hostname']}"doaction:configdiamond_handlers["diamond.handler.archive.ArchiveHandler","diamond.handler.graphite.GraphiteHandler"]graphite_handler({"host"=>"127.0.0.1","port"=>2003,"timeout"=>15})enddirectory"/usr/local/share/diamond/collectors/latency_http"doaction:createendcookbook_file"/usr/local/share/diamond/collectors/latency_http/latency_http.py"dosource"latency_http.py"cookbook"our_custom"enddiamond_plugin"LatencyHTTTPCollector"doaction:enableoptions({"enabled"=>"True","target_1"=>"host1.com","target_2"=>"host2.com"})end

Author:: Scott M. Likens (scott@likens.us)

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.

About

Chef Cookbook for deploying Diamond

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages