Skip to content
Open
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
72 changes: 54 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,86 @@
Description
===========
## Description

Installs and configures statsite, statsd implementation. https://github.com/armon/statsite

Requirements
============
## Requirements

### Platforms

* Ubuntu 10.04 / Ubuntu 12.04
* Centos 7

### Cookbooks

* python
* git
* runit

Attributes
==========
## Usage

* `node[:statsite][:path]` - Default setting: "/opt/statsite"
* `node[:statsite][:repo]` - Default setting: "git://github.com/armon/statsite.git"
`recipe[statsite]` install, build and start statsite

## Attributes

### Installation/System Attributes

#### Systemd, Upstart, Init (Debian based) init systems

These attributes are used by Systemd, Upstart, Init (Debian based) init systems.

* `default[:statsite][:service_type]` - Can be "upstart", "systemd", "init" or
"runit". Default: "runit"
* `node[:statsite][:conf]` - Default setting: "/etc/statsite.conf"
* `node[:statsite][:path]` - Default setting: "/opt/statsite"
* `node[:statsite][:owner]` - Default setting: "statsite"

#### Upstart and Init (Debian based) specific

In addition to attributes listed above, these attributes are also used by Upstart and Init.

* `node[:statsite][:group]` - Default setting: "statsite"

#### Init (Debian based) specific

In addition to attributes listed above, this attribute is also used by Init.

* `default[:statsite][:pid_file]` - Default setting: "/var/run/statsite/statsite.pid"

### Build Attributes

* `node[:statsite][:repo]` - Default setting: "git://github.com/armon/statsite.git"
* `node[:statsite][:ref]` - Default setting: "HEAD"

### Daemon Attributes

* `node[:statsite][:bind_address]` - Default setting: ::1
* `node[:statsite][:port]` - Default setting: 8125
* `node[:statsite][:tcp_port]` - Default setting: 8125
* `node[:statsite][:udp_port]` - Default setting: 8125
* `node[:statsite][:loglevel]` - Default setting: "INFO"
* `node[:statsite][:flush_interval]` - Default setting: 10
* `node[:statsite][:timer_eps]` - Default setting: 0.01
* `node[:statsite][:stream_command]` - Optional handler. Default setting: ''
* `default[:statsite][:service_type]` - Can be "runit" or "upstart". Default: "runit"
* `node[:statsite][:binary_stream]` - Optional handler. Default setting: ''
* `node[:statsite][:use_type_prefix]` - Optional handler. Default setting: ''

## Recipes

Usage
=====
* `recipe[statsite]` Installs/Configures statsite

`recipe[statsite]` install, build and start with either runit or upstart
## Roles

### Histogram

Histogram
=========
Additional histograms can be defined in `node[:statsite][:histogram]` attribute.

Role example:

```
{
...
"default_attributes": {
"statsite": {
"bind_address": "::",
"port": 18125,
"udp_port": 18125,
"stream_command": "python /opt/statsite/sinks/graphite.py graphite.recfut.com 2003 statsite",
"service_type": "upstart",
"histogram": {
Expand All @@ -57,6 +93,6 @@ Role example:
}
}
}
...
...
}
```
5 changes: 4 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
default[:statsite][:owner] = "statsite"
default[:statsite][:group] = "statsite"
default[:statsite][:bind_address] = "::1"
default[:statsite][:port] = 8125
default[:statsite][:tcp_port] = 8125
default[:statsite][:udp_port] = 8125
default[:statsite][:loglevel] = "INFO"
default[:statsite][:flush_interval] = 10
default[:statsite][:timer_eps] = 0.01
default[:statsite][:stream_command] = ""
default[:statsite][:binary_stream] = ""
default[:statsite][:use_type_prefix] = ""

default[:statsite][:service_type] = "runit"
default[:statsite][:pid_file] = "/var/run/statsite/statsite.pid"
18 changes: 18 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@
action [:enable, :start]
end

when 'systemd'
service_resource = 'service[statsite]'

template "/lib/systemd/system/statsite.service" do
source "systemd.statsite.erb"
mode "0755"
variables(
:conf => node[:statsite][:conf],
:path => node[:statsite][:path],
:user => node[:statsite][:owner]
)
end

service "statsite" do
supports :restart => true
action [:enable, :start]
end

when 'init'
service_resource = 'service[statsite]'

Expand Down
10 changes: 8 additions & 2 deletions templates/default/statsite.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ bind_address = <%= node[:statsite][:bind_address] %>
daemonize = 1
pid_file = <%= node[:statsite][:pid_file] %>
<% end -%>
port = <%= node[:statsite][:port] %>
udp_port = <%= node[:statsite][:port] %>
tcp_port = <%= node[:statsite][:tcp_port] %>
udp_port = <%= node[:statsite][:udp_port] %>
log_level = <%= node[:statsite][:loglevel] %>
flush_interval = <%= node[:statsite][:flush_interval] %>
timer_eps = <%= node[:statsite][:timer_eps] %>
<% if node[:statsite][:stream_command] -%>
stream_cmd = <%= node[:statsite][:stream_command] %>
<% end -%>
<% if node[:statsite][:binary_stream] -%>
binary_stream = <%= node[:statsite][:binary_stream] %>
<% end -%>
<% if node[:statsite][:use_type_prefix] -%>
use_type_prefix = <%= node[:statsite][:use_type_prefix] %>
<% end -%>

<% if node[:statsite][:histogram] -%>
<% node[:statsite][:histogram].each do |section,opts| -%>
Expand Down
15 changes: 15 additions & 0 deletions templates/default/systemd.statsite.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Statsite Collector
Wants=basic.target
After=basic.target network.target

[Service]
User=<%= @user %>
ExecStart=<%= @path %>/statsite -f <%= @conf %>
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target