Skip to content

Commit

Permalink
Merge branch 'master' into raxmus/COOK-214
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed Feb 25, 2010
2 parents fbfdbc7 + 3da3252 commit 77175c9
Show file tree
Hide file tree
Showing 72 changed files with 3,246 additions and 80 deletions.
29 changes: 29 additions & 0 deletions java/README.rdoc
@@ -0,0 +1,29 @@
= DESCRIPTION:

Installs Java and Ant.

= REQUIREMENTS:

Platform: Ubuntu, Debian, Red Hat, CentOS, Fedora.

Enable the 'multiverse' repository on Ubuntu, 'non-free' on Debian or EPEL on RH/Cent/Fedora to get the Java package, or edit the default recipe to point at the Java package for your platform.

= USAGE:

Simply include the recipe where you want Java installed. Note the respository requirement above to get the right package. On Debian and Ubuntu systems, the recipe will preseed the package and update java alternaties.

= LICENSE and AUTHOR:

Copyright 2008-2010, Opscode, 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.
3 changes: 2 additions & 1 deletion java/metadata.rb
Expand Up @@ -2,7 +2,8 @@
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs java"
version "0.8"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.9"

%w{ debian ubuntu }.each do |os|
supports os
Expand Down
12 changes: 7 additions & 5 deletions java/recipes/default.rb
Expand Up @@ -18,11 +18,11 @@
#

java_pkg = value_for_platform(
"ubuntu" => {
[ "ubuntu", "debian" ] => {
"default" => "sun-java6-jdk"
},
"debian" => {
"default" => "sun-java6-jdk"
[ "redhat", "centos", "fedora" ] => {
"default" => "java-1.6.0-openjdk"
},
"default" => "sun-java6-jdk"
)
Expand All @@ -35,9 +35,11 @@
end

package java_pkg do
response_file "java.seed"
action :install
notifies :run, resources(:execute => "update-java-alternatives"), :immediately
if platform?("ubuntu", "debian")
response_file "java.seed"
notifies :run, resources(:execute => "update-java-alternatives"), :immediately
end
end

package "ant"
95 changes: 95 additions & 0 deletions munin/README.rdoc
@@ -0,0 +1,95 @@
= DESCRIPTION:

Installs and configures Nagios for a server and for clients using Chef 0.8 search capabilities.

= REQUIREMENTS:

Requires Chef 0.8+ for search capability of roles and data bags.

The monitoring server that uses this recipe should have a role named 'monitoring'. A role named after the environment (e.g., "production") and a node attribute app_environment with a value of the same should be created for all nodes. The server uses this to search for only nodes that belong to its same environment.

Because of the heavy use of search, this recipe will not work with Chef Solo, as it cannot do any searches without a server.

== Platform:

Tested on Ubuntu 9.04, Ubuntu 9.10 and Debian 5.

== Cookbooks:

Opscode cookbooks:

* apache2

To install perl cpan modules for munin plugins:

* perl

= USAGE:

This document describes how to add custom munin plugins.

The munin cookbook now has a definition that can be used to enable a new plugin for data gathering on a client. If an existing munin plugin is desired, call the definition:

munin_plugin "nfs_client"

By default the plugin file name is the name parameter here. Specify the plugin parameter to use something else.

munin_plugin "nfs_client"
plugin "nfs_client_"
end

This creates a symlink from the plugins distribution directory, `/usr/share/munin/plugins` to the enabled plugins directory, `/etc/munin/plu
gins`, and once the server poller picks it up will have new graph data for that plugin. See the plugins distribution directory for available
plugins or add your own.

If a custom plugin is required, add the plugin file to the munin cookbook in `site-cookbooks/munin/files/default/plugins`. Call the definition specifying that the plugin file should be downloaded from the cookbook.

munin_plugin "nfs_client_custom"
create_file true
end

By default in both cases, the plugin is enabled. If a plugin should be disabled, use the `enable` parameter:

munin_plugin "nfs_client_custom"
enable false
end

Some plugins may require other configuration. For example, to use the memcache plugins, you'll need the Cache::Memcache cpan module installed, and use the munin_plugin definition. The perl cookbook from opscode includes a definition to handle this easily.

cpan_module "Cache::Memcached"

Then for example in your memcache recipe:

%w(
memcached_bytes_
memcached_connections_
memcached_hits_
memcached_items_
memcached_requests_
memcached_responsetime_
memcached_traffic_
).each do |plugin_name|
munin_plugin plugin_name do
plugin "#{plugin_name}#{node[:ipaddress].gsub('.','_')}_#{node[:memcached][:port]}"
create_file true
end
end

= LICENSE and AUTHOR:

Author:: Nathan Haneysmith <nathan@opscode.com>
Author:: Joshua Timberman <joshua@opscode.com>

Copyright 2009-2010, Opscode, 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.
47 changes: 47 additions & 0 deletions munin/definitions/munin_plugin.rb
@@ -0,0 +1,47 @@
#
# Cookbook Name:: munin
# Definition:: munin_plugin
#
# Copyright 2010, OpsCode, 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.
#


define :munin_plugin, :plugin_config => "/etc/munin/plugins", :plugin_dir => "/usr/share/munin/plugins", :create_file => false, :enable => true do

include_recipe "munin::client"

plugin = params[:plugin] ? params[:plugin] : params[:name]

if params[:create_file]
remote_file "#{params[:plugin_dir]}/#{params[:name]}" do
cookbook "munin"
source "plugins/#{params[:name]}"
owner "root"
group "root"
mode 0755
end
end

link "#{params[:plugin_config]}/#{plugin}" do
to "#{params[:plugin_dir]}/#{params[:name]}"
if params[:enable]
action :create
else
action :delete
end
notifies :restart, resources(:service => "munin-node")
end

end
3 changes: 3 additions & 0 deletions munin/files/default/htpasswd.users
@@ -0,0 +1,3 @@
# Generated by Chef.
# Included as a placeholder, but not used in the recipes, we use OpenID
# based login instead.
9 changes: 9 additions & 0 deletions munin/files/default/munin-cron
@@ -0,0 +1,9 @@
#
# cron-jobs for munin
#

MAILTO=root

@reboot root if [ ! -d /var/run/munin ]; then /bin/bash -c 'perms=(`/usr/sbin/dpkg-statoverride --list /var/run/munin`); mkdir /var/run/munin; chown ${perms[0]:-munin}:${perms[1]:-root} /var/run/munin; chmod ${perms[2]:-0755} /var/run/munin'; fi
*/5 * * * * munin if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi
14 10 * * * munin if [ -x /usr/share/munin/munin-limits ]; then /usr/share/munin/munin-limits; fi
1 change: 1 addition & 0 deletions munin/files/default/plugins/README
@@ -0,0 +1 @@
Put the custom munin plugin files here.
36 changes: 36 additions & 0 deletions munin/files/default/plugins/memcached_bytes_
@@ -0,0 +1,36 @@
#!/usr/bin/env perl
# ex:ts=4

use strict;
use warnings;

use Cache::Memcached;

$0 =~ /memcached_bytes_(\d+_\d+_\d+_\d+)_(\d+)$/;
my ($ip, $port) = ($1, $2);
$ip =~ s/_/./g;
my $address = "$ip:$port";

my $cmd = shift || '';
if ($cmd eq 'config') {
print "graph_title Memcached bytes used for $address\n";
print "graph_args --base 1024 -l 0\n";
print "graph_vlabel bytes\n";
print "graph_category memcached\n";
print "graph_info This graph monitors the size of the memcached cache.\n";
print "bytes.label bytes used\n";
print "bytes.info Number of bytes currently used\n";
print "bytes.min 0\n";
print "bytes.draw AREA\n";
print "maxbytes.label maximum available\n";
print "maxbytes.info The configured cache size\n";
print "maxbytes.min 0\n";
exit 0;
}

my $memd = new Cache::Memcached { 'servers' => [$address] };
my $memstats = $memd->stats(['misc']);

print "bytes.value " . $memstats->{hosts}->{$address}->{misc}->{bytes} . "\n";
print "maxbytes.value " .
$memstats->{hosts}->{$address}->{misc}->{limit_maxbytes} . "\n";
32 changes: 32 additions & 0 deletions munin/files/default/plugins/memcached_connections_
@@ -0,0 +1,32 @@
#!/usr/bin/env perl
# ex:ts=4

use strict;
use warnings;

use Cache::Memcached;

my $cmd = shift || '';
$0 =~ /memcached_connections_(\d+_\d+_\d+_\d+)_(\d+)$/;
my ($ip, $port) = ($1, $2);
$ip =~ s/_/./g;
my $address = "$ip:$port";

if ($cmd eq 'config') {
print "graph_title Memcached connections for $address\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel connections\n";
print "graph_category memcached\n";
print "graph_info This graph monitors the connections to the memcached server.\n";
print "connections.label connections\n";
print "connections.info Number of connections to memcached\n";
print "connections.min 0\n";
print "connections.draw AREA\n";
exit 0;
}

my $memd = new Cache::Memcached { 'servers' => [$address] };
my $memstats = $memd->stats(['misc']);

print "connections.value " .
$memstats->{hosts}->{$address}->{misc}->{curr_connections} . "\n";
38 changes: 38 additions & 0 deletions munin/files/default/plugins/memcached_hits_
@@ -0,0 +1,38 @@
#!/usr/bin/env perl
# ex:ts=4

use strict;
use warnings;

use Cache::Memcached;

$0 =~ /memcached_hits_(\d+_\d+_\d+_\d+)_(\d+)$/;
my ($ip, $port) = ($1, $2);
$ip =~ s/_/./g;
my $address = "$ip:$port";

my $cmd = shift || '';
if ($cmd eq 'config') {
print "graph_title Memcached cache hits and misses for $address\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel requests\n";
print "graph_category memcached\n";
print "graph_info This graph monitors the number of cache hits and misses.\n";
print "hits.label hits\n";
print "hits.info Number of cache hits\n";
print "hits.min 0\n";
print "hits.type DERIVE\n";
print "misses.label misses\n";
print "misses.info Number of cache misses\n";
print "misses.min 0\n";
print "misses.type DERIVE\n";
print "misses.draw AREA\n";
exit 0;
}

my $memd = new Cache::Memcached { 'servers' => [$address] };
my $memstats = $memd->stats(['misc']);

print "hits.value " . $memstats->{hosts}->{$address}->{misc}->{get_hits} . "\n";
print "misses.value " .
$memstats->{hosts}->{$address}->{misc}->{get_misses} . "\n";
32 changes: 32 additions & 0 deletions munin/files/default/plugins/memcached_items_
@@ -0,0 +1,32 @@
#!/usr/bin/env perl
# ex:ts=4

use strict;
use warnings;

use Cache::Memcached;

my $cmd = shift || '';
$0 =~ /memcached_items_(\d+_\d+_\d+_\d+)_(\d+)$/;
my ($ip, $port) = ($1, $2);
$ip =~ s/_/./g;
my $address = "$ip:$port";

if ($cmd eq 'config') {
print "graph_title Memcached cached items for $address\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel items\n";
print "graph_category memcached\n";
print "graph_info This graph monitors the number of items stored by the memcached server.\n";
print "items.label items\n";
print "items.info Number of cached items\n";
print "items.min 0\n";
print "items.draw AREA\n";
exit 0;
}

my $memd = new Cache::Memcached { 'servers' => [$address] };
my $memstats = $memd->stats(['misc']);

print "items.value " .
$memstats->{hosts}->{$address}->{misc}->{curr_items} . "\n";

0 comments on commit 77175c9

Please sign in to comment.