Git Product home page Git Product logo

chef-monit's Introduction

chef-monit Build Status

Description

Installs the monit package from (http://mmonit.com/monit/).

Requirements

Supported Platforms

The following platforms are supported by this cookbook, meaning that the recipes run on these platforms without error:

  • Ubuntu 12.04, 14.04
  • Debian 7.8, 8.0
  • RedHat
  • CentOS 6.6, 7.1
  • Scientific
  • Fedora 21
  • SUSE
  • Amazon

Recipes

  • monit - The default recipe. Sets up the service definition and default checks.

Resources

monit_monitrc

The following will create a monitrc configuration:

monit_monitrc "ssh" do
  variables({ category: "system" })
end

The name parameter must match a file located in your templates directory. In the example above, this would be ssh.monitrc.erb.

The variables option within the block is optional, and can contain a list of key-value pairs to assign within your template.

Usage

This cookbook installs the monit components if not present, and pulls updates if they are installed on the system.

Attributes

# Delay the start of polling when the service is started
default["monit"]["start_delay"] = 0

# How frequently the monit daemon polls for changes.
default["monit"]["polling_frequency"] = 20

# Where Monit stores the pid file
default["monit"]["pidfile"] = "/var/run/monit.pid"

# Use syslog for logging instead of a logfile.
default["monit"]["use_syslog"] = true

# If not using syslog, the log file that monit will use.
default["monit"]["logfile"] = "/var/log/monit.log"

# Where Monit stores unique Monit instance id
default["monit"]["idfile"] = "/var/.monit.id"

# Where Monit stores Monit state file
default["monit"]["statefile"] = "/var/lib/monit/state"

# Enable emails for internal monit alerts
default["monit"]["mail_alerts"] = true

# Possible events include: action, checksum, connection, content, data, exec, fsflags, gid, icmp, instance, invalid, nonexist, permission, pid, ppid, resource, size, status, timeout, timestamp, uid, uptime.
# Only alert on specific events
default["monit"]["alert_onlyif_events"] = []
# Ignore alerts for specific events
default["monit"]["alert_ignore_events"] = []

# Email address that will be notified of events.
default["monit"]["alert_email"] = "root@localhost"

# Enable the web interface and define credentials.
default["monit"]["web_interface"] = {
  enable:  true,
  port:    2812,
  address: "localhost",
  allow:   ["localhost", "admin:b1gbr0th3r"]
}

# Email settings that will be used for notification of events.
default["monit"]["mail"] = {
  hostname: "localhost",
  port:     25,
  username: nil,
  password: nil,
  encrypted_credentials: nil,
  encrypted_credentials_data_bag: "credentials",
  from:     "monit@$HOST",
  subject:  "$SERVICE $EVENT at $DATE",
  message:  "Monit $ACTION $SERVICE at $DATE on $HOST,\n\n$DESCRIPTION\n\nDutifully,\nMonit",
  security: nil,  # 'SSLV2'|'SSLV3'|'TLSV1'
  timeout:  30,
  using_hostname: nil
}

case node["platform_family"]
when "rhel", "fedora", "suse"
  default["monit"]["main_config_path"] = "/etc/monit.conf"
  default["monit"]["includes_dir"] = "/etc/monit.d"
else
  default["monit"]["main_config_path"] = "/etc/monit/monitrc"
  default["monit"]["includes_dir"] = "/etc/monit/conf.d"
end

# The monit::default recipe will load these monit_monitrc resources automatically
# NOTE setting this attribute at the default level will append values to the array
default["monit"]["default_monitrc_configs"] = %w[load ssh]

# Whether the monit service should be reloaded when a configuration changes
default["monit"]["reload_on_change"] = true

# `MONIT_OPTS` for /etc/default/monit
default["monit"]["init_opts"] = ""

# specify a particular version of the monit package you want installed,
# otherwise it will install the default. this value is ignored when performing a
# source install.
default["monit"]["version"] = nil

# source install specifics
default["monit"]["source_install"] = false
default["monit"]["source_uninstall"] = false

default["monit"]["source"]["version"] = "5.12.2"
default["monit"]["source"]["prefix"] = "/usr/local"
default["monit"]["source"]["url"] = "https://mmonit.com/monit/dist/monit-#{node["monit"]["source"]["version"]}.tar.gz"
default["monit"]["source"]["checksum"] = "8ab0296d1aa2351b1573481592d7b5e06de1edd49dff1b5552839605a450914c"
default["monit"]["source"]["pam_support"] = true
default["monit"]["source"]["ssl_support"] = true
default["monit"]["source"]["large_file_support"] = true
default["monit"]["source"]["compiler_optimized"] = true

# binary install specifics
default["monit"]["binary_install"] = false
default["monit"]["binary_uninstall"] = false

default["monit"]["binary"]["version"] = "5.12.2"
default["monit"]["binary"]["prefix"] = "/usr"
default["monit"]["binary"]["url"] = "http://mmonit.com/monit/dist/binary/#{node["monit"]["binary"]["version"]}/monit-#{node["monit"]["binary"]["version"]}-linux-x64.tar.gz"
default["monit"]["binary"]["checksum"] = "4908143752d0ee5081a50389a9206b7c905f9f8922a062a208fecf6e729a3c77"

Contributors

Many thanks go to the following contributors who have helped to make this cookbook even better:

  • @werdan
    • add support for redhat-flavored systems
  • @auser
    • add missing metadata
  • @arrowcircle
    • update syntax to be Ruby 1.8-compatible
  • @dwradcliffe
    • typo fix for README
    • fix logging logic
    • whyrun support for monitrc provider
    • support for reloading monit without restart
    • don't render 'use address' if no address is provided
    • fix attribute comments
  • @tjwallace
    • load default monitrc configs from an attribute
  • @tomdz
    • Ruby 1.8.x compatibility fix
    • add support for templates in different cookbooks
  • @alexism
    • support other security protocols
  • @fixlr
    • add mail_alerts attribute
  • @darron
    • add descriptions to email notifications
  • @claco
    • add startup delay option to monit daemon config
    • restart on default monitrc configs change
    • restart monit service if the monit config changes
    • fix platform family logic
  • @maciejgalkiewicz
    • fix logging logic
  • @pauloricardomg
    • add alert_ignore_events attribute
    • add reload_on_change attribute
  • @drywheat
    • support encrypted data bag for smtp credentials
    • add support for installation from source vs. package
  • @esigler
    • allow either style of monit startup flag to work
  • @evan2645
    • fix bug in which monit is not started during bootstrap
  • @mvdkleijn
    • add settings for idfile and statefile
  • @mbanton
    • fix statefile attribute in monitrc template
  • @foxycoder
    • add support for binary install
  • @ijin
    • add using_hostname attribute
    • better ssh support for Amazon Linux
  • @rickhull
    • update to use latest monit versions
    • add proper rhel-family support with init script template
  • @dougbarth
    • fix lwrp updated_by_last_action
  • @fulloflilies
    • fix converge error caused by overwriting running binary file

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

chef-monit

chef-monit's People

Contributors

alexism avatar arrowcircle avatar auser avatar bitdeli-chef avatar claco avatar darron avatar dwradcliffe avatar esigler avatar evan2645 avatar fixlr avatar fulloflilies avatar ijin avatar mbanton avatar mgalkiewicz avatar mvdkleijn avatar pauloricardomg avatar phlipper avatar sonnysideup avatar tjwallace avatar tomdz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

chef-monit's Issues

location of idfile and statefile

Hi, there any reason to have this:
default["monit"]["idfile"] = "/var/.monit.id"
default["monit"]["statefile"] = "/var/lib/monit/state"

Instead of:
default["monit"]["idfile"] = "/var/lib/monit/id"
default["monit"]["statefile"] = "/var/lib/monit/state"

Grouping every monit file in its directory ?

Directory name doesn't match name field in metadata.rb

I was encountering a chef compile time error with line 73 of recipes/default.rb because of the mismatch between the directory name and the name field in metadata.rb

I was able to get around a chef compile issue by renaming the git directory. How are you guys approaching this?

kitchen converge throws yum error

I am trying the cookbook using kitchen & am stuck at the issue below:

   ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/yum/resources/globalconfig.rb
   ================================================================================

   ArgumentError
   -------------
   Cannot specify both default and name_property/name_attribute together on property path of resource yum_globalconfig

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/yum/resources/globalconfig.rb:76:in `class_from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/yum/resources/globalconfig.rb:

    69:  attribute :mdpolicy, :kind_of => String, :equal_to => %w(instant group:primary group:small group:main group:all), :default => nil
    70:  attribute :metadata_expire, :kind_of => String, :regex => [/^\d+$/, /^\d+[mhd]$/, /never/], :default => nil
    71:  attribute :mirrorlist_expire, :kind_of => String, :regex => /^\d+$/, :default => nil
    72:  attribute :multilib_policy, :kind_of => String, :equal_to => %w(all best), :default => nil
    73:  attribute :obsoletes, :kind_of => [TrueClass, FalseClass], :default => true
    74:  attribute :overwrite_groups, :kind_of => [TrueClass, FalseClass], :default => nil
    75:  attribute :password, :kind_of => String, :regex => /.*/, :default => nil
    76>> attribute :path, :kind_of => String, :regex => /.*/, :default => nil, :name_attribute => true
    77:  attribute :persistdir, :kind_of => String, :regex => /.*/, :default => nil
    78:  attribute :pluginconfpath, :kind_of => String, :regex => /.*/, :default => nil
    79:  attribute :pluginpath, :kind_of => String, :regex => /.*/, :default => nil
    80:  attribute :plugins, :kind_of => [TrueClass, FalseClass], :default => true
    81:  attribute :protected_multilib, :kind_of => [TrueClass, FalseClass], :default => nil
    82:  attribute :protected_packages, :kind_of => String, :regex => /.*/, :default => nil
    83:  attribute :proxy, :kind_of => String, :regex => /.*/, :default => nil
    84:  attribute :proxy_password, :kind_of => String, :regex => /.*/, :default => nil
    85:  attribute :proxy_username, :kind_of => String, :regex => /.*/, :default => nil

   System Info:
   ------------
   chef_version=13.5.3
   platform=centos
   platform_version=6.6
   ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
   program_name=chef-solo worker: ppid=3023;start=23:26:53;
   executable=/opt/chef/bin/chef-solo

Can you let me know what am I doing wrong.

Add encrypted credentials option for mail provider

We store all of our service credentials (mail, db, lb, etc...) in encrypted data bags. I would like to extend this cookbook to support reading and setting mail credentials using an encrypted data bag. Does that sound valuable?

install-monit-binary gets STDERR: cp: cannot create regular file `/usr/bin/monit': Text file busy

Hello, I got following error while running chef-client which includes install-monit-binary in runlist:
This error appears on chef-client run after "first run" which is successful.
Looks like /usr/bin/monit is not available during command "cd /var/chef/cache && tar zxvf monit-5.10.tar.gz && cd monit-5.10 && cp bin/monit /usr/bin/monit" because monit service is running.
Following is the error:

Recipe: monit::install_binary
   execute[install-monit-binary] action run

Error executing action `run` on resource 'execute[install-monit-binary]'


Mixlib::ShellOut::ShellCommandFailed

Expected process to exit with [0], but received '1'
---- Begin output of cd /var/chef/cache &&   tar zxvf monit-5.10.tar.gz &&   cd monit-5.10 &&   cp bin/monit /usr/bin/monit ----
STDOUT: monit-5.10/
monit-5.10/bin/
monit-5.10/bin/monit
monit-5.10/COPYING
monit-5.10/conf/
monit-5.10/conf/monitrc
monit-5.10/man/
monit-5.10/man/man1/
monit-5.10/man/man1/monit.1
STDERR: cp: cannot create regular file `/usr/bin/monit': Text file busy
---- End output of cd /var/chef/cache &&   tar zxvf monit-5.10.tar.gz &&   cd monit-5.10 &&   cp bin/monit /usr/bin/monit ----
Ran cd /var/chef/cache &&   tar zxvf monit-5.10.tar.gz &&   cd monit-5.10 &&   cp bin/monit /usr/bin/monit returned 1


Resource Declaration:

 In /var/chef/cache/cookbooks/monit/recipes/install_binary.rb

 10: execute "install-monit-binary" do
 11:   command "cd #{Chef::Config[:file_cache_path]} && \
 12:   tar zxvf monit-#{node["monit"]["binary"]["version"]}.tar.gz && \
 13:   cd monit-#{node["monit"]["binary"]["version"]} && \
 14:   cp bin/monit #{node["monit"]["binary"]["prefix"]}/bin/monit"
 15:   action :nothing
 16: end
 17:



Compiled Resource:

 Declared in /var/chef/cache/cookbooks/monit/recipes/install_binary.rb:10:in `from_file'

execute("install-monit-binary") do
  action [:nothing]
  retries 0
  retry_delay 2
  guard_interpreter :default
  command "cd /var/chef/cache &&   tar zxvf monit-5.10.tar.gz &&   cd monit-5.10 &&   cp bin/monit /usr/bin/monit"
  backup 5
  returns 0
  cookbook_name "monit"
  recipe_name "install_binary"
end



Recipe: monit::default
  * service[monit] action reload
    - reload service service[monit]


Running handlers:
[2014-12-11T14:09:31-05:00] ERROR: Running exception handlers
Running handlers complete

[2014-12-11T14:09:31-05:00] ERROR: Exception handlers complete
[2014-12-11T14:09:31-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 136 resources updated in 497.362269175 seconds
[2014-12-11T14:09:31-05:00] ERROR: execute[install-monit-binary] (monit::install_binary line 10) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of cd /var/chef/cache &&   tar zxvf monit-5.10.tar.gz &&   cd monit-5.10 &&   cp bin/monit /usr/bin/monit ----
STDOUT: monit-5.10/
monit-5.10/bin/
monit-5.10/bin/monit
monit-5.10/COPYING
monit-5.10/conf/
monit-5.10/conf/monitrc
monit-5.10/man/
monit-5.10/man/man1/
monit-5.10/man/man1/monit.1
STDERR: cp: cannot create regular file `/usr/bin/monit': Text file busy
---- End output of cd /var/chef/cache &&   tar zxvf monit-5.10.tar.gz &&   cd monit-5.10 &&   cp bin/monit /usr/bin/monit ----
Ran cd /var/chef/cache &&   tar zxvf monit-5.10.tar.gz &&   cd monit-5.10 &&   cp bin/monit /usr/bin/monit returned 1
[2014-12-11T14:09:32-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Attribute to not automatically start monit

Sometimes when you are in a dev environment, or even when you want to create a instance of a database cluster that you won't like the service to be running right away because performance reasons, it's interesting to not start monit after the installation.

It would be interesting to have a attribute that switches the auto start off, like:

default[:monit][:auto_start] = false

Wrong init.d on RHEL

I'm trying to install monit on RHEL (6.4) from binary and I can't figure out how to get it to copy the correct init.d template. I've tried manually and the version in templates/centos works perfectly but for some reason it only copies the version from templates/default. I can't tell if this is a bug or I'm just missing something.

Thanks in advance.

Ruby version file references non-existent version

The .ruby-version file specifies version 2.2 but, according to rbenv, there is no version by that name available.

-> rbenv install 2.2
ruby-build: definition not found: 2.2

The following versions contain `2.2' in the name:
  2.2.0-dev
  2.2.0-preview1
  2.2.0-preview2
  2.2.0-rc1
  2.2.0
  2.2.1
  2.2.2
  rbx-2.2.0
  rbx-2.2.1
  rbx-2.2.2
  rbx-2.2.3
  rbx-2.2.4
  rbx-2.2.5
  rbx-2.2.6
  rbx-2.2.7
  rbx-2.2.9
  rbx-2.2.10

See all available versions with `rbenv install --list'.

Should this not be changed to 2.2.0?

Credentials unencrypted

Setting the login credentials for the web interface using node['monit']['web_interface']['allow'] is resulting in the unencrypted credentials being available from the chef server. Is there a good way to remove them from the Ohai data collected after a chef client run?

Ideally I would like to populate them from an encrypted data bag instead of from an attribute. I'm doing this now in a round about manner by reading them and inserting into the allow array. But then they are captured by Ohai.

Getting invoke-rc.d: initscript monit, action "restart" failed.

Hi, I tried this recipe today and I'm getting an error:

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/sbin/invoke-rc.d monit restart ----
STDOUT: Stopping daemon monitor: monit.
Starting daemon monitor: monit
STDERR: invoke-rc.d: initscript monit, action "restart" failed.
---- End output of /usr/sbin/invoke-rc.d monit restart ----
Ran /usr/sbin/invoke-rc.d monit restart returned 1

On Ubuntu 10.04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.