Provides Chef recipes for installing Monit and its configurations
Ruby HTML
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
attributes
providers
recipes
resources
templates
.gitignore
README.md
metadata.rb

README.md

cookbook-monit

Provides a set of primitives for managing monit and monit configurations.

Requirements

Chef

Tested on

  • 0.10.x
  • 0.11.x
  • 0.12.x

Platform

Tested on

  • Ubuntu 11.04
  • Ubuntu 12.04
  • Ubuntu 14.04

but older and newer platforms should work just fine.

Installation

Berkshelf is recommended to install this cookbook. In fact, it's recommended to install all your cookbooks! Within your Berksfile

cookbook 'monit', git: 'https://github.com/axsuul/cookbook-monit'

Recipes

Some monit configuration recipes have also been provided for some popular services.

default

Installs monit as a service using the package manager and drops off a monitrc configuration file. Make sure to check out the default attributes file!

Usage

A monit resource is provided to easily manage monit configurations. Here's a simple example

monit "postgresql" do
  pidfile "/var/run/postgresql/9.1-main.pid"
  start "/etc/init.d/postgresql start"
  stop "/etc/init.d/postgresql stop"
end

Default action is :enable. You can disable by doing

monit "postgresql" do
    # ...
    action :disable
end

What happens if you want to run the process as a user? The monit resource provides a helper attribute as and will load that user's environment while running the start and stop commands.

monit "sidekiq" do
  pidfile "/app/pids/sidekiq.pid"
  start "/app/bin/sidekiq --pidfile /app/pids/sidekiq.pid"
  as "deployer"
  conditions [
    "if mem > 256 MB for 1 cycles then restart",
    "if cpu > 90% for 5 cycles then restart",
    "if 5 restarts within 5 cycles then timeout"
  ]
end

You still have the option to run the commands directly as the user (without environment) with uid and gid, although most likely you will want to use as.

monit "sidekiq" do
  pidfile "/app/pids/sidekiq.pid"
  uid "deployer"
  gid "admin"
  # ...
end

Notice that in the above example, stop is not set. If stop is not set, the provider will use a SIGTERM to kill the pid in the pidfile.

No pidfile?. No worries bro!

monit "varnish" do
  matching "varnishd"
  # ...
end

Contributing

I love pull requests!

License

Author:: James Hu (hello@james.hu)

Copyright:: Copyright (c) 2016, James Hu

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.