├── .gitignore ├── .kitchen.yml ├── .rubocop.yml ├── .ruby-version ├── .travis.yml ├── Berksfile ├── Berksfile.lock ├── CHANGELOG.md ├── Gemfile ├── Guardfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── attributes └── default.rb ├── libraries └── matchers.rb ├── metadata.rb ├── providers └── monitrc.rb ├── recipes ├── _service_configuration.rb ├── default.rb ├── install_binary.rb ├── install_package.rb ├── install_source.rb ├── uninstall.rb ├── uninstall_binary.rb └── uninstall_source.rb ├── resources └── monitrc.rb ├── spec ├── default_spec.rb ├── install_binary_spec.rb ├── install_package_spec.rb ├── install_source_spec.rb └── spec_helper.rb ├── templates ├── amazon │ └── ssh.monitrc.erb ├── centos │ ├── monit.init.erb │ └── ssh.monitrc.erb └── default │ ├── load.monitrc.erb │ ├── monit.init.erb │ ├── monitrc.erb │ └── ssh.monitrc.erb └── test ├── .chef └── knife.rb ├── integration ├── binary │ └── serverspec │ │ └── localhost │ │ └── binary_install_spec.rb ├── default │ └── serverspec │ │ └── localhost │ │ └── default_install_spec.rb └── source │ └── serverspec │ └── localhost │ └── source_install_spec.rb └── rubocop ├── disabled.yml └── enabled.yml /.gitignore: -------------------------------------------------------------------------------- 1 | *.tgz 2 | *.tar.gz 3 | vendor/bundle 4 | .bundle 5 | .DS_Store 6 | build/* 7 | tmp/ 8 | Gemfile.lock 9 | test/support/chef-10.gemfile.lock 10 | test/support/chef-11.gemfile.lock 11 | .kitchen/ 12 | .kitchen.local.yml 13 | *.swp 14 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: docker 3 | require_chef_omnibus: <%= ENV.fetch("CHEF_VERSION", "true") %> 4 | 5 | provisioner: 6 | name: chef_zero 7 | 8 | platforms: 9 | - name: debian-7.8 10 | run_list: 11 | - recipe[apt] 12 | - name: debian-8.0 13 | run_list: 14 | - recipe[apt] 15 | - name: ubuntu-12.04 16 | run_list: 17 | - recipe[apt] 18 | - name: ubuntu-14.04 19 | run_list: 20 | - recipe[apt] 21 | - name: centos-6.6 22 | run_list: 23 | - recipe[yum-epel] 24 | - name: centos-7.1 25 | run_list: 26 | - recipe[yum-epel] 27 | - name: fedora-21 28 | 29 | suites: 30 | - name: default 31 | run_list: 32 | - recipe[monit] 33 | - name: source 34 | run_list: 35 | - recipe[monit] 36 | attributes: 37 | monit: 38 | source_install: true 39 | - name: binary 40 | run_list: 41 | - recipe[monit] 42 | attributes: 43 | monit: 44 | binary_install: true 45 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | LineLength: 2 | Max: 80 3 | Exclude: 4 | - "**/attributes/*.rb" 5 | - "**/metadata.rb" 6 | 7 | Style/StringLiterals: 8 | EnforcedStyle: double_quotes 9 | 10 | Style/StringLiteralsInInterpolation: 11 | EnforcedStyle: double_quotes 12 | 13 | PercentLiteralDelimiters: 14 | PreferredDelimiters: 15 | "%w": "[]" # Arrays use brackets 16 | 17 | SingleSpaceBeforeFirstArg: 18 | Enabled: false # too strict about metadata and certain formatting 19 | 20 | inherit_from: test/rubocop/enabled.yml 21 | inherit_from: test/rubocop/disabled.yml 22 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | bundler_args: --jobs 4 --retry 3 --without integration 3 | rvm: 4 | - 2.0 5 | - 2.1 6 | - 2.2 7 | script: 8 | - bundle exec rake rubocop 9 | - bundle exec rake foodcritic 10 | - bundle exec rake chefspec 11 | - bundle exec rake kitchen:all 12 | env: 13 | matrix: 14 | - CHEF_VERSION: "11.18.6" 15 | - CHEF_VERSION: "12.0.0" 16 | - CHEF_VERSION: "12.1.0" 17 | - CHEF_VERSION: "12.2.0" 18 | - CHEF_VERSION: "12.3.0" 19 | sudo: false 20 | cache: bundler 21 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source "https://supermarket.chef.io" 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook "apt" 7 | cookbook "yum-epel" 8 | end 9 | -------------------------------------------------------------------------------- /Berksfile.lock: -------------------------------------------------------------------------------- 1 | DEPENDENCIES 2 | apt 3 | monit 4 | path: . 5 | metadata: true 6 | yum-epel 7 | 8 | GRAPH 9 | apt (2.4.0) 10 | build-essential (2.0.4) 11 | monit (1.5.4) 12 | build-essential (>= 0.0.0) 13 | yum (3.2.2) 14 | yum-epel (0.3.6) 15 | yum (~> 3.0) 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # chef-monit 2 | 3 | ## [Unreleased](https://github.com/phlipper/chef-monit/tree/HEAD) 4 | 5 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.5.4...HEAD) 6 | 7 | **Closed issues:** 8 | 9 | - Binary install no longer works as Monit 5.8.1 no longer exists [\#63](https://github.com/phlipper/chef-monit/issues/63) 10 | 11 | - install-monit-binary gets `STDERR: cp: cannot create regular file '/usr/bin/monit': Text file busy` [\#60](https://github.com/phlipper/chef-monit/issues/60) 12 | 13 | - Directory name doesn't match name field in `metadata.rb` [\#49](https://github.com/phlipper/chef-monit/issues/49) 14 | 15 | **Merged pull requests:** 16 | 17 | - Fix binary install [\#71](https://github.com/phlipper/chef-monit/pull/71) ([phlipper](https://github.com/phlipper)) 18 | 19 | - Fix converge error caused by overwriting runnig bin file [\#70](https://github.com/phlipper/chef-monit/pull/70) ([fulloflilies](https://github.com/fulloflilies)) 20 | 21 | - Fix LWRP notifications [\#69](https://github.com/phlipper/chef-monit/pull/69) ([phlipper](https://github.com/phlipper)) 22 | 23 | - Glassdoor updates [\#68](https://github.com/phlipper/chef-monit/pull/68) ([phlipper](https://github.com/phlipper)) 24 | 25 | - Project updates and cleanup [\#67](https://github.com/phlipper/chef-monit/pull/67) ([phlipper](https://github.com/phlipper)) 26 | 27 | - Much needed updates [\#66](https://github.com/phlipper/chef-monit/pull/66) ([rickhull](https://github.com/rickhull)) 28 | 29 | - Much needed update [\#65](https://github.com/phlipper/chef-monit/pull/65) ([rickhull](https://github.com/rickhull)) 30 | 31 | - Fixing LWRP's `updated_by_last_action` setting [\#62](https://github.com/phlipper/chef-monit/pull/62) ([dougbarth](https://github.com/dougbarth)) 32 | 33 | - Fixes broken binary download url [\#61](https://github.com/phlipper/chef-monit/pull/61) ([fromonesrc](https://github.com/fromonesrc)) 34 | 35 | - Updating `install_binary.rb` to add support for rhel platform, and changin... [\#58](https://github.com/phlipper/chef-monit/pull/58) ([smford22](https://github.com/smford22)) 36 | 37 | - add `use_inline_resources` to `monit_monitrc` provider [\#57](https://github.com/phlipper/chef-monit/pull/57) ([MrMMorris](https://github.com/MrMMorris)) 38 | 39 | - Make pid file path customisable [\#56](https://github.com/phlipper/chef-monit/pull/56) ([heryandi](https://github.com/heryandi)) 40 | 41 | ## [1.5.4](https://github.com/phlipper/chef-monit/tree/1.5.4) (2014-06-29) 42 | 43 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.5.3...1.5.4) 44 | 45 | **Merged pull requests:** 46 | 47 | - Support Amazon Linux for ssh \(\#51\) [\#55](https://github.com/phlipper/chef-monit/pull/55) ([phlipper](https://github.com/phlipper)) 48 | 49 | - Support 'using HOSTNAME' syntax \(\#52\) [\#54](https://github.com/phlipper/chef-monit/pull/54) ([phlipper](https://github.com/phlipper)) 50 | 51 | - Binary install \(\#48\) [\#53](https://github.com/phlipper/chef-monit/pull/53) ([phlipper](https://github.com/phlipper)) 52 | 53 | - project updates [\#50](https://github.com/phlipper/chef-monit/pull/50) ([phlipper](https://github.com/phlipper)) 54 | 55 | - Support 'using HOSTNAME' syntax [\#52](https://github.com/phlipper/chef-monit/pull/52) ([ijin](https://github.com/ijin)) 56 | 57 | - Support Amazon Linux for ssh [\#51](https://github.com/phlipper/chef-monit/pull/51) ([ijin](https://github.com/ijin)) 58 | 59 | - Binary install [\#48](https://github.com/phlipper/chef-monit/pull/48) ([foxycoder](https://github.com/foxycoder)) 60 | 61 | ## [1.5.3](https://github.com/phlipper/chef-monit/tree/v1.5.3) (2014-05-24) 62 | 63 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.5.2...1.5.3) 64 | 65 | **Closed issues:** 66 | 67 | - Upload this cookbook to opscode community site [\#44](https://github.com/phlipper/chef-monit/issues/44) 68 | 69 | - Optionally install monit from source [\#39](https://github.com/phlipper/chef-monit/issues/39) 70 | 71 | - Add encrypted credentials option for mail provider [\#34](https://github.com/phlipper/chef-monit/issues/34) 72 | 73 | - Add a variable to remove mail configurations [\#33](https://github.com/phlipper/chef-monit/issues/33) 74 | 75 | **Merged pull requests:** 76 | 77 | - Fix attribute comments [\#47](https://github.com/phlipper/chef-monit/pull/47) ([dwradcliffe](https://github.com/dwradcliffe)) 78 | 79 | - Fix statefile config parameter in template monitrc.erb [\#46](https://github.com/phlipper/chef-monit/pull/46) ([mbanton](https://github.com/mbanton)) 80 | 81 | - Add source installation option [\#45](https://github.com/phlipper/chef-monit/pull/45) ([phlipper](https://github.com/phlipper)) 82 | 83 | - Add settings for `idfile` and `statefile` - \#41 [\#43](https://github.com/phlipper/chef-monit/pull/43) ([phlipper](https://github.com/phlipper)) 84 | 85 | - add `rubocop` to test suite [\#42](https://github.com/phlipper/chef-monit/pull/42) ([phlipper](https://github.com/phlipper)) 86 | 87 | - Fix bug in which Monit is not started during bootstrap [\#38](https://github.com/phlipper/chef-monit/pull/38) ([evan2645](https://github.com/evan2645)) 88 | 89 | - Allow either style of monit startup flag to work [\#36](https://github.com/phlipper/chef-monit/pull/36) ([esigler](https://github.com/esigler)) 90 | 91 | - configures encrypted smtp provider [\#35](https://github.com/phlipper/chef-monit/pull/35) ([drywheat](https://github.com/drywheat)) 92 | 93 | - Add settings for idfile and statefile options to Monit config [\#41](https://github.com/phlipper/chef-monit/pull/41) ([mvdkleijn](https://github.com/mvdkleijn)) 94 | 95 | - Allow user to install different versions of monit [\#40](https://github.com/phlipper/chef-monit/pull/40) ([drywheat](https://github.com/drywheat)) 96 | 97 | ## [1.5.2](https://github.com/phlipper/chef-monit/tree/1.5.2) (2014-01-17) 98 | 99 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.5.1...1.5.2) 100 | 101 | **Merged pull requests:** 102 | 103 | - Cleanup [\#32](https://github.com/phlipper/chef-monit/pull/32) ([phlipper](https://github.com/phlipper)) 104 | 105 | - Add `reload_on_change` property [\#31](https://github.com/phlipper/chef-monit/pull/31) ([phlipper](https://github.com/phlipper)) 106 | 107 | - Added `reload_on_change` property that defines if monit should be reloaded when configuration changes \(default: true\) [\#30](https://github.com/phlipper/chef-monit/pull/30) ([pauloricardomg](https://github.com/pauloricardomg)) 108 | 109 | ## [1.5.1](https://github.com/phlipper/chef-monit/tree/1.5.1) (2014-01-10) 110 | 111 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.5.0...1.5.1) 112 | 113 | **Merged pull requests:** 114 | 115 | - added option `alert_ignore_events` to avoid certain types of event alerts [\#29](https://github.com/phlipper/chef-monit/pull/29) ([pauloricardomg](https://github.com/pauloricardomg)) 116 | 117 | - Update the recipe to use a version [\#16](https://github.com/phlipper/chef-monit/pull/16) ([mahmoudimus](https://github.com/mahmoudimus)) 118 | 119 | ## [1.5.0](https://github.com/phlipper/chef-monit/tree/1.5.0) (2013-12-21) 120 | 121 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.4.0...1.5.0) 122 | 123 | **Merged pull requests:** 124 | 125 | - Web address [\#28](https://github.com/phlipper/chef-monit/pull/28) ([phlipper](https://github.com/phlipper)) 126 | 127 | - Reload monit [\#27](https://github.com/phlipper/chef-monit/pull/27) ([phlipper](https://github.com/phlipper)) 128 | 129 | - whyrun support for monitrc provider [\#26](https://github.com/phlipper/chef-monit/pull/26) ([phlipper](https://github.com/phlipper)) 130 | 131 | - Fix logging [\#25](https://github.com/phlipper/chef-monit/pull/25) ([phlipper](https://github.com/phlipper)) 132 | 133 | - drop 1.8.7 and 1.9.2, add 2.0.0 for TravisCI [\#24](https://github.com/phlipper/chef-monit/pull/24) ([phlipper](https://github.com/phlipper)) 134 | 135 | - Add a Bitdeli Badge to README [\#18](https://github.com/phlipper/chef-monit/pull/18) ([bitdeli-chef](https://github.com/bitdeli-chef)) 136 | 137 | - minor tweak to skip binding to an address by not providing :address =\> ... [\#23](https://github.com/phlipper/chef-monit/pull/23) ([schettj](https://github.com/schettj)) 138 | 139 | - don't render 'use address' if no address is provided [\#22](https://github.com/phlipper/chef-monit/pull/22) ([dwradcliffe](https://github.com/dwradcliffe)) 140 | 141 | - support for reloading monit without restart [\#21](https://github.com/phlipper/chef-monit/pull/21) ([dwradcliffe](https://github.com/dwradcliffe)) 142 | 143 | - whyrun support for monitrc provider [\#20](https://github.com/phlipper/chef-monit/pull/20) ([dwradcliffe](https://github.com/dwradcliffe)) 144 | 145 | - fix logging logic in template [\#19](https://github.com/phlipper/chef-monit/pull/19) ([dwradcliffe](https://github.com/dwradcliffe)) 146 | 147 | - Fixed using monit with syslog. [\#17](https://github.com/phlipper/chef-monit/pull/17) ([mgalkiewicz](https://github.com/mgalkiewicz)) 148 | 149 | ## [1.4.0](https://github.com/phlipper/chef-monit/tree/1.4.0) (2013-09-11) 150 | 151 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.3.3...1.4.0) 152 | 153 | ## [1.3.3](https://github.com/phlipper/chef-monit/tree/1.3.3) (2013-06-19) 154 | 155 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.3.2...1.3.3) 156 | 157 | **Merged pull requests:** 158 | 159 | - Add startup delay option to monit daemon in config [\#15](https://github.com/phlipper/chef-monit/pull/15) ([claco](https://github.com/claco)) 160 | 161 | - Check template updated / Restart on default monitrc configs change [\#14](https://github.com/phlipper/chef-monit/pull/14) ([claco](https://github.com/claco)) 162 | 163 | - Restart monit service if the monit config changes [\#13](https://github.com/phlipper/chef-monit/pull/13) ([claco](https://github.com/claco)) 164 | 165 | - Fix platform family logic [\#12](https://github.com/phlipper/chef-monit/pull/12) ([claco](https://github.com/claco)) 166 | 167 | ## [1.3.2](https://github.com/phlipper/chef-monit/tree/1.3.2) (2013-05-01) 168 | 169 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.3.1...1.3.2) 170 | 171 | **Merged pull requests:** 172 | 173 | - Makes the email notifications much more useful. [\#11](https://github.com/phlipper/chef-monit/pull/11) ([darron](https://github.com/darron)) 174 | 175 | ## [1.3.1](https://github.com/phlipper/chef-monit/tree/1.3.1) (2013-04-09) 176 | 177 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.3.0...1.3.1) 178 | 179 | **Merged pull requests:** 180 | 181 | - Add `mail_alerts` attribute [\#10](https://github.com/phlipper/chef-monit/pull/10) ([fixlr](https://github.com/fixlr)) 182 | 183 | ## [1.3.0](https://github.com/phlipper/chef-monit/tree/1.3.0) (2013-03-29) 184 | 185 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.2.0...1.3.0) 186 | 187 | **Merged pull requests:** 188 | 189 | - support other security protocols [\#9](https://github.com/phlipper/chef-monit/pull/9) ([alexism](https://github.com/alexism)) 190 | 191 | ## [1.2.0](https://github.com/phlipper/chef-monit/tree/1.2.0) (2013-03-14) 192 | 193 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.1.1...1.2.0) 194 | 195 | **Merged pull requests:** 196 | 197 | - Ruby 1.8.x compatibility fix and support for templates in different cookbooks [\#8](https://github.com/phlipper/chef-monit/pull/8) ([tomdz](https://github.com/tomdz)) 198 | 199 | ## [1.1.1](https://github.com/phlipper/chef-monit/tree/1.1.1) (2013-03-07) 200 | 201 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.1.0...1.1.1) 202 | 203 | **Merged pull requests:** 204 | 205 | - Only load default monitrc configs from an attribute [\#7](https://github.com/phlipper/chef-monit/pull/7) ([tjwallace](https://github.com/tjwallace)) 206 | 207 | - Remove executable permission from files [\#6](https://github.com/phlipper/chef-monit/pull/6) ([tjwallace](https://github.com/tjwallace)) 208 | 209 | - Fix typo in readme [\#5](https://github.com/phlipper/chef-monit/pull/5) ([dwradcliffe](https://github.com/dwradcliffe)) 210 | 211 | ## [1.1.0](https://github.com/phlipper/chef-monit/tree/1.1.0) (2013-01-06) 212 | 213 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.0.1...1.1.0) 214 | 215 | **Closed issues:** 216 | 217 | - Getting invoke-rc.d: initscript monit, action "restart" failed. [\#2](https://github.com/phlipper/chef-monit/issues/2) 218 | 219 | **Merged pull requests:** 220 | 221 | - Fixed hash syntax for ruby 1.8 [\#4](https://github.com/phlipper/chef-monit/pull/4) ([arrowcircle](https://github.com/arrowcircle)) 222 | 223 | ## [1.0.1](https://github.com/phlipper/chef-monit/tree/1.0.1) (2012-12-27) 224 | 225 | [Full Changelog](https://github.com/phlipper/chef-monit/compare/1.0.0...1.0.1) 226 | 227 | ## [1.0.0](https://github.com/phlipper/chef-monit/tree/1.0.0) (2012-12-27) 228 | 229 | **Merged pull requests:** 230 | 231 | - Added name to metadata.rb [\#3](https://github.com/phlipper/chef-monit/pull/3) ([auser](https://github.com/auser)) 232 | 233 | - Support for multiple node platforms [\#1](https://github.com/phlipper/chef-monit/pull/1) ([werdan](https://github.com/werdan)) 234 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | chef_version = ENV.fetch("CHEF_VERSION", "11.18.6") 4 | 5 | gem "chef", "~> #{chef_version}" 6 | gem "chefspec", "~> 4.2.0" 7 | 8 | gem "berkshelf", "~> 3.2.3" 9 | gem "foodcritic", "~> 4.0.0" 10 | gem "rake", "~> 10.4.0" 11 | gem "rubocop", "~> 0.30.1" 12 | gem "serverspec", "~> 2.14.1" 13 | 14 | group :integration do 15 | gem "busser-serverspec", "~> 0.5.5" 16 | gem "kitchen-docker", "~> 2.1.0" 17 | gem "kitchen-sync", "~> 1.0.1" 18 | gem "test-kitchen", "~> 1.4.0" 19 | end 20 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | guard :rspec, cmd: "rspec --color", all_on_start: false do 2 | watch(%r{^spec\/(.+)_spec\.rb}) 3 | watch(%r{^recipes\/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" } 4 | watch("spec/spec_helper.rb") { "spec" } 5 | end 6 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2011-2013 Phil Cohen 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chef-monit [![Build Status](http://img.shields.io/travis-ci/phlipper/chef-monit.png)](http://travis-ci.org/phlipper/chef-monit) 2 | 3 | ## Description 4 | 5 | Installs the `monit` package from (http://mmonit.com/monit/). 6 | 7 | 8 | ## Requirements 9 | 10 | ### Supported Platforms 11 | 12 | The following platforms are supported by this cookbook, meaning that the recipes run on these platforms without error: 13 | 14 | * Ubuntu 12.04, 14.04 15 | * Debian 7.8, 8.0 16 | * RedHat 17 | * CentOS 6.6, 7.1 18 | * Scientific 19 | * Fedora 21 20 | * SUSE 21 | * Amazon 22 | 23 | 24 | ## Recipes 25 | 26 | * `monit` - The default recipe. Sets up the service definition and default checks. 27 | 28 | 29 | ## Resources 30 | 31 | ### `monit_monitrc` 32 | 33 | The following will create a monitrc configuration: 34 | 35 | ```ruby 36 | monit_monitrc "ssh" do 37 | variables({ category: "system" }) 38 | end 39 | ``` 40 | 41 | The `name` parameter must match a file located in your templates directory. In the example above, this would be `ssh.monitrc.erb`. 42 | 43 | The `variables` option within the block is optional, and can contain a list of key-value pairs to assign within your template. 44 | 45 | 46 | ## Usage 47 | 48 | This cookbook installs the monit components if not present, and pulls updates if they are installed on the system. 49 | 50 | 51 | ## Attributes 52 | 53 | ```ruby 54 | # Delay the start of polling when the service is started 55 | default["monit"]["start_delay"] = 0 56 | 57 | # How frequently the monit daemon polls for changes. 58 | default["monit"]["polling_frequency"] = 20 59 | 60 | # Where Monit stores the pid file 61 | default["monit"]["pidfile"] = "/var/run/monit.pid" 62 | 63 | # Use syslog for logging instead of a logfile. 64 | default["monit"]["use_syslog"] = true 65 | 66 | # If not using syslog, the log file that monit will use. 67 | default["monit"]["logfile"] = "/var/log/monit.log" 68 | 69 | # Where Monit stores unique Monit instance id 70 | default["monit"]["idfile"] = "/var/.monit.id" 71 | 72 | # Where Monit stores Monit state file 73 | default["monit"]["statefile"] = "/var/lib/monit/state" 74 | 75 | # Enable emails for internal monit alerts 76 | default["monit"]["mail_alerts"] = true 77 | 78 | # 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. 79 | # Only alert on specific events 80 | default["monit"]["alert_onlyif_events"] = [] 81 | # Ignore alerts for specific events 82 | default["monit"]["alert_ignore_events"] = [] 83 | 84 | # Email address that will be notified of events. 85 | default["monit"]["alert_email"] = "root@localhost" 86 | 87 | # Enable the web interface and define credentials. 88 | default["monit"]["web_interface"] = { 89 | enable: true, 90 | port: 2812, 91 | address: "localhost", 92 | allow: ["localhost", "admin:b1gbr0th3r"] 93 | } 94 | 95 | # Email settings that will be used for notification of events. 96 | default["monit"]["mail"] = { 97 | hostname: "localhost", 98 | port: 25, 99 | username: nil, 100 | password: nil, 101 | encrypted_credentials: nil, 102 | encrypted_credentials_data_bag: "credentials", 103 | from: "monit@$HOST", 104 | subject: "$SERVICE $EVENT at $DATE", 105 | message: "Monit $ACTION $SERVICE at $DATE on $HOST,\n\n$DESCRIPTION\n\nDutifully,\nMonit", 106 | security: nil, # 'SSLV2'|'SSLV3'|'TLSV1' 107 | timeout: 30, 108 | using_hostname: nil 109 | } 110 | 111 | case node["platform_family"] 112 | when "rhel", "fedora", "suse" 113 | default["monit"]["main_config_path"] = "/etc/monit.conf" 114 | default["monit"]["includes_dir"] = "/etc/monit.d" 115 | else 116 | default["monit"]["main_config_path"] = "/etc/monit/monitrc" 117 | default["monit"]["includes_dir"] = "/etc/monit/conf.d" 118 | end 119 | 120 | # The monit::default recipe will load these monit_monitrc resources automatically 121 | # NOTE setting this attribute at the default level will append values to the array 122 | default["monit"]["default_monitrc_configs"] = %w[load ssh] 123 | 124 | # Whether the monit service should be reloaded when a configuration changes 125 | default["monit"]["reload_on_change"] = true 126 | 127 | # `MONIT_OPTS` for /etc/default/monit 128 | default["monit"]["init_opts"] = "" 129 | 130 | # specify a particular version of the monit package you want installed, 131 | # otherwise it will install the default. this value is ignored when performing a 132 | # source install. 133 | default["monit"]["version"] = nil 134 | 135 | # source install specifics 136 | default["monit"]["source_install"] = false 137 | default["monit"]["source_uninstall"] = false 138 | 139 | default["monit"]["source"]["version"] = "5.12.2" 140 | default["monit"]["source"]["prefix"] = "/usr/local" 141 | default["monit"]["source"]["url"] = "https://mmonit.com/monit/dist/monit-#{node["monit"]["source"]["version"]}.tar.gz" 142 | default["monit"]["source"]["checksum"] = "8ab0296d1aa2351b1573481592d7b5e06de1edd49dff1b5552839605a450914c" 143 | default["monit"]["source"]["pam_support"] = true 144 | default["monit"]["source"]["ssl_support"] = true 145 | default["monit"]["source"]["large_file_support"] = true 146 | default["monit"]["source"]["compiler_optimized"] = true 147 | 148 | # binary install specifics 149 | default["monit"]["binary_install"] = false 150 | default["monit"]["binary_uninstall"] = false 151 | 152 | default["monit"]["binary"]["version"] = "5.12.2" 153 | default["monit"]["binary"]["prefix"] = "/usr" 154 | default["monit"]["binary"]["url"] = "http://mmonit.com/monit/dist/binary/#{node["monit"]["binary"]["version"]}/monit-#{node["monit"]["binary"]["version"]}-linux-x64.tar.gz" 155 | default["monit"]["binary"]["checksum"] = "4908143752d0ee5081a50389a9206b7c905f9f8922a062a208fecf6e729a3c77" 156 | ``` 157 | 158 | ## Contributors 159 | 160 | Many thanks go to the following [contributors](https://github.com/phlipper/chef-monit/graphs/contributors) who have helped to make this cookbook even better: 161 | 162 | * **[@werdan](https://github.com/werdan)** 163 | * add support for redhat-flavored systems 164 | * **[@auser](https://github.com/auser)** 165 | * add missing metadata 166 | * **[@arrowcircle](https://github.com/arrowcircle)** 167 | * update syntax to be Ruby 1.8-compatible 168 | * **[@dwradcliffe](https://github.com/dwradcliffe)** 169 | * typo fix for README 170 | * fix logging logic 171 | * whyrun support for monitrc provider 172 | * support for reloading monit without restart 173 | * don't render 'use address' if no address is provided 174 | * fix attribute comments 175 | * **[@tjwallace](https://github.com/tjwallace)** 176 | * load default monitrc configs from an attribute 177 | * **[@tomdz](https://github.com/tomdz)** 178 | * Ruby 1.8.x compatibility fix 179 | * add support for templates in different cookbooks 180 | * **[@alexism](https://github.com/alexism)** 181 | * support other security protocols 182 | * **[@fixlr](https://github.com/fixlr)** 183 | * add `mail_alerts` attribute 184 | * **[@darron](https://github.com/darron)** 185 | * add descriptions to email notifications 186 | * **[@claco](https://github.com/claco)** 187 | * add startup delay option to monit daemon config 188 | * restart on default monitrc configs change 189 | * restart monit service if the monit config changes 190 | * fix platform family logic 191 | * **[@maciejgalkiewicz](https://github.com/maciejgalkiewicz)** 192 | * fix logging logic 193 | * **[@pauloricardomg](https://github.com/pauloricardomg)** 194 | * add `alert_ignore_events` attribute 195 | * add `reload_on_change` attribute 196 | * **[@drywheat](https://github.com/drywheat)** 197 | * support encrypted data bag for smtp credentials 198 | * add support for installation from source vs. package 199 | * **[@esigler](https://github.com/esigler)** 200 | * allow either style of monit startup flag to work 201 | * **[@evan2645](https://github.com/evan2645)** 202 | * fix bug in which monit is not started during bootstrap 203 | * **[@mvdkleijn](https://github.com/mvdkleijn)** 204 | * add settings for idfile and statefile 205 | * **[@mbanton](https://github.com/mbanton)** 206 | * fix `statefile` attribute in `monitrc` template 207 | * **[@foxycoder](https://github.com/foxycoder)** 208 | * add support for binary install 209 | * **[@ijin](https://github.com/ijin)** 210 | * add `using_hostname` attribute 211 | * better ssh support for Amazon Linux 212 | * **[@rickhull](https://github.com/rickhull)** 213 | * update to use latest monit versions 214 | * add proper rhel-family support with init script template 215 | * **[@dougbarth](https://github.com/dougbarth)** 216 | * fix lwrp `updated_by_last_action` 217 | * **[@fulloflilies](https://github.com/fulloflilies)** 218 | * fix converge error caused by overwriting running binary file 219 | 220 | 221 | ## Contributing 222 | 223 | 1. Fork it 224 | 2. Create your feature branch (`git checkout -b my-new-feature`) 225 | 3. Commit your changes (`git commit -am 'Added some feature'`) 226 | 4. Push to the branch (`git push origin my-new-feature`) 227 | 5. Create new Pull Request 228 | 229 | 230 | ## License 231 | 232 | **chef-monit** 233 | 234 | * Freely distributable and licensed under the [MIT license](http://phlipper.mit-license.org/2011-2015/license.html). 235 | * Copyright (c) 2011-2015 Phil Cohen (github@phlippers.net) [![endorse](http://api.coderwall.com/phlipper/endorsecount.png)](http://coderwall.com/phlipper) [![Gittip](http://img.shields.io/gittip/phlipper.png)](https://www.gittip.com/phlipper/) 236 | * http://phlippers.net/ 237 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | task default: "test" 2 | 3 | desc "Run all tests except `kitchen`" 4 | task test: [:rubocop, :foodcritic, :chefspec] 5 | 6 | desc "Run all tests" 7 | task all_tests: [:rubocop, :foodcritic, :chefspec, "kitchen:all"] 8 | 9 | # rubocop style checker 10 | require "rubocop/rake_task" 11 | RuboCop::RakeTask.new 12 | 13 | # foodcritic chef lint 14 | require "foodcritic" 15 | FoodCritic::Rake::LintTask.new do |t| 16 | t.options = { fail_tags: ["any"] } 17 | end 18 | 19 | # chefspec unit tests 20 | require "rspec/core/rake_task" 21 | RSpec::Core::RakeTask.new(:chefspec) do |t| 22 | t.rspec_opts = "--color --format progress" 23 | end 24 | 25 | # test-kitchen integration tests 26 | begin 27 | require "kitchen/rake_tasks" 28 | Kitchen::RakeTasks.new 29 | rescue LoadError 30 | task("kitchen:all") { puts "Unable to run `test-kitchen`" } 31 | end 32 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: monit 3 | # Attributes:: default 4 | # 5 | # Author:: Phil Cohen 6 | # 7 | 8 | # Delay the start of polling when the service is started 9 | default["monit"]["start_delay"] = 0 10 | 11 | # How frequently the monit daemon polls for changes. 12 | default["monit"]["polling_frequency"] = 20 13 | 14 | # Where Monit stores the pid file 15 | default["monit"]["pidfile"] = "/var/run/monit.pid" 16 | 17 | # Use syslog for logging instead of a logfile. 18 | default["monit"]["use_syslog"] = true 19 | 20 | # If not using syslog, the log file that monit will use. 21 | default["monit"]["logfile"] = "/var/log/monit.log" 22 | 23 | # Where Monit stores unique Monit instance id 24 | default["monit"]["idfile"] = "/var/.monit.id" 25 | 26 | # Where Monit stores Monit state file 27 | default["monit"]["statefile"] = "/var/lib/monit/state" 28 | 29 | # Enable emails for internal monit alerts 30 | default["monit"]["mail_alerts"] = true 31 | 32 | # 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. 33 | # Only alert on specific events 34 | default["monit"]["alert_onlyif_events"] = [] 35 | # Ignore alerts for specific events 36 | default["monit"]["alert_ignore_events"] = [] 37 | 38 | # Email address that will be notified of events. 39 | default["monit"]["alert_email"] = "root@localhost" 40 | 41 | # Enable the web interface and define credentials. 42 | default["monit"]["web_interface"] = { 43 | enable: true, 44 | port: 2812, 45 | address: "localhost", 46 | allow: ["localhost", "admin:b1gbr0th3r"] 47 | } 48 | 49 | # Email settings that will be used for notification of events. 50 | default["monit"]["mail"] = { 51 | hostname: "localhost", 52 | port: 25, 53 | username: nil, 54 | password: nil, 55 | encrypted_credentials: nil, 56 | encrypted_credentials_data_bag: "credentials", 57 | from: "monit@$HOST", 58 | subject: "$SERVICE $EVENT at $DATE", 59 | message: "Monit $ACTION $SERVICE at $DATE on $HOST,\n\n$DESCRIPTION\n\nDutifully,\nMonit", 60 | security: nil, # 'SSLV2'|'SSLV3'|'TLSV1' 61 | timeout: 30, 62 | using_hostname: nil 63 | } 64 | 65 | case node["platform_family"] 66 | when "rhel", "fedora", "suse" 67 | default["monit"]["main_config_path"] = "/etc/monit.conf" 68 | default["monit"]["includes_dir"] = "/etc/monit.d" 69 | else 70 | default["monit"]["main_config_path"] = "/etc/monit/monitrc" 71 | default["monit"]["includes_dir"] = "/etc/monit/conf.d" 72 | end 73 | 74 | # The monit::default recipe will load these monit_monitrc resources automatically 75 | # NOTE setting this attribute at the default level will append values to the array 76 | default["monit"]["default_monitrc_configs"] = %w[load ssh] 77 | 78 | # Whether the monit service should be reloaded when a configuration changes 79 | default["monit"]["reload_on_change"] = true 80 | 81 | # `MONIT_OPTS` for /etc/default/monit 82 | default["monit"]["init_opts"] = "" 83 | 84 | # specify a particular version of the monit package you want installed, 85 | # otherwise it will install the default. this value is ignored when performing a 86 | # source install. 87 | default["monit"]["version"] = nil 88 | 89 | # source install specifics 90 | default["monit"]["source_install"] = false 91 | default["monit"]["source_uninstall"] = false 92 | 93 | default["monit"]["source"]["version"] = "5.12.2" 94 | default["monit"]["source"]["prefix"] = "/usr/local" 95 | default["monit"]["source"]["url"] = "https://mmonit.com/monit/dist/monit-#{node["monit"]["source"]["version"]}.tar.gz" 96 | default["monit"]["source"]["checksum"] = "8ab0296d1aa2351b1573481592d7b5e06de1edd49dff1b5552839605a450914c" 97 | default["monit"]["source"]["pam_support"] = true 98 | default["monit"]["source"]["ssl_support"] = true 99 | default["monit"]["source"]["large_file_support"] = true 100 | default["monit"]["source"]["compiler_optimized"] = true 101 | 102 | # binary install specifics 103 | default["monit"]["binary_install"] = false 104 | default["monit"]["binary_uninstall"] = false 105 | 106 | default["monit"]["binary"]["version"] = "5.12.2" 107 | default["monit"]["binary"]["prefix"] = "/usr" 108 | default["monit"]["binary"]["url"] = "http://mmonit.com/monit/dist/binary/#{node["monit"]["binary"]["version"]}/monit-#{node["monit"]["binary"]["version"]}-linux-x64.tar.gz" 109 | default["monit"]["binary"]["checksum"] = "4908143752d0ee5081a50389a9206b7c905f9f8922a062a208fecf6e729a3c77" 110 | -------------------------------------------------------------------------------- /libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def create_monit_monitrc(resource) 3 | ChefSpec::Matchers::ResourceMatcher.new(:monit_monitrc, :create, resource) 4 | end 5 | 6 | def delete_monit_monitrc(resource) 7 | ChefSpec::Matchers::ResourceMatcher.new(:monit_monitrc, :delete, resource) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name "monit" 2 | maintainer "Phil Cohen" 3 | maintainer_email "github@phlippers.net" 4 | license "MIT" 5 | description "Configures monit" 6 | long_description "Please refer to README.md" 7 | version "1.5.4" 8 | 9 | recipe "monit", "Sets up the service definition and default checks." 10 | recipe "monit::install_source", "Compiles and installs monit from source." 11 | recipe "monit::install_binary", "Installs monit from a binary package." 12 | 13 | depends "build-essential" 14 | suggests "apt" 15 | suggests "yum-epel" 16 | 17 | supports "ubuntu" 18 | supports "debian" 19 | supports "redhat" 20 | supports "centos" 21 | supports "scientific" 22 | supports "fedora" 23 | supports "suse" 24 | supports "amazon" 25 | -------------------------------------------------------------------------------- /providers/monitrc.rb: -------------------------------------------------------------------------------- 1 | def whyrun_supported? 2 | true 3 | end 4 | 5 | action :create do 6 | name = new_resource.name 7 | 8 | t = template "#{node["monit"]["includes_dir"]}/#{name}.monitrc" do 9 | owner "root" 10 | group "root" 11 | mode "0644" 12 | source new_resource.template_source || "#{name}.monitrc.erb" 13 | cookbook new_resource.template_cookbook 14 | variables new_resource.variables 15 | notifies :reload, "service[monit]" if node["monit"]["reload_on_change"] 16 | action :nothing 17 | end 18 | 19 | # Run the action immediately so `updated_by_last_action?` is correct 20 | t.run_action(:create) 21 | 22 | new_resource.updated_by_last_action(t.updated_by_last_action?) 23 | end 24 | 25 | action :delete do 26 | f = file "#{node["monit"]["includes_dir"]}/#{new_resource.name}.monitrc" do 27 | action :nothing 28 | notifies :reload, "service[monit]" 29 | end 30 | 31 | # Run the action immediately so `updated_by_last_action?` is correct 32 | f.run_action(:delete) 33 | 34 | new_resource.updated_by_last_action(f.updated_by_last_action?) 35 | end 36 | -------------------------------------------------------------------------------- /recipes/_service_configuration.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: monit 3 | # Recipe:: _service_configuration 4 | # 5 | 6 | config_dir = File.dirname(node["monit"]["main_config_path"]) 7 | monit_dirs = [ 8 | config_dir, 9 | node["monit"]["includes_dir"], 10 | "/var/lib/monit" 11 | ] 12 | 13 | monit_dirs.each do |dir| 14 | directory dir do 15 | recursive true 16 | end 17 | end 18 | 19 | template "/etc/init.d/monit" do 20 | source "monit.init.erb" 21 | mode "0755" 22 | variables( 23 | prefix: node["monit"]["binary"]["prefix"], 24 | config: node["monit"]["main_config_path"], 25 | pidfile: node["monit"]["pidfile"] 26 | ) 27 | end 28 | 29 | execute "chkconfig monit on" do 30 | only_if { platform_family?("rhel") } 31 | not_if %(chkconfig --list | grep 'monit ' | grep '2:on') 32 | end 33 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: monit 3 | # Recipe:: default 4 | # 5 | 6 | include_recipe "apt" if platform_family?("debian") # ~FC007 uses `suggests` 7 | 8 | if node["monit"]["source_install"] 9 | include_recipe "monit::install_source" 10 | elsif node["monit"]["binary_install"] 11 | include_recipe "monit::install_binary" 12 | else 13 | include_recipe "monit::install_package" 14 | end 15 | 16 | # optionally use encrypted mail credentials 17 | encrypted_credentials = node["monit"]["mail"]["encrypted_credentials"] 18 | if encrypted_credentials 19 | bag_name = node["monit"]["mail"]["encrypted_credentials_data_bag"] 20 | credentials = Chef::EncryptedDataBagItem.load(bag_name, encrypted_credentials) 21 | 22 | node.default["monit"]["mail"]["username"] = credentials["username"] 23 | node.default["monit"]["mail"]["password"] = credentials["password"] 24 | 25 | Chef::Log.info "Using encrpyted mail credentials: #{encrypted_credentials}" 26 | end 27 | 28 | # configuration file 29 | template node["monit"]["main_config_path"] do 30 | owner "root" 31 | group "root" 32 | mode "0600" 33 | source "monitrc.erb" 34 | notifies :reload, "service[monit]" if node["monit"]["reload_on_change"] 35 | end 36 | 37 | # build default monitrc files 38 | node["monit"]["default_monitrc_configs"].each do |conf| 39 | monit_monitrc conf do 40 | variables(category: "system") 41 | notifies :reload, "service[monit]" 42 | end 43 | end 44 | 45 | directory "/var/monit" do 46 | owner "root" 47 | group "root" 48 | mode "0700" 49 | end 50 | 51 | # enable service startup 52 | file "/etc/default/monit" do 53 | owner "root" 54 | group "root" 55 | mode "0644" 56 | content [ 57 | "START=yes", 58 | "MONIT_OPTS=#{node["monit"]["init_opts"]}" 59 | ].join("\n") 60 | notifies :restart, "service[monit]" 61 | end 62 | 63 | # system service 64 | service "monit" do 65 | supports restart: true, reload: true 66 | action [:enable, :start] 67 | end 68 | -------------------------------------------------------------------------------- /recipes/install_binary.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: monit 3 | # Recipe:: install_binary 4 | # 5 | 6 | tar_file = "monit-#{node["monit"]["binary"]["version"]}.tar.gz" 7 | cache_path = Chef::Config[:file_cache_path] 8 | binary = "#{node["monit"]["binary"]["prefix"]}/bin/monit" 9 | 10 | execute "rm #{binary}" do 11 | only_if { ::File.exist?(binary) } 12 | not_if "monit -V | grep #{node["monit"]["binary"]["version"]}" 13 | notifies :create, "remote_file[#{cache_path}/#{tar_file}]", :immediately 14 | end 15 | 16 | remote_file "#{cache_path}/#{tar_file}" do 17 | source node["monit"]["binary"]["url"] 18 | checksum node["monit"]["binary"]["checksum"] 19 | action :create_if_missing 20 | notifies :run, "execute[install-monit-binary]", :immediately 21 | end 22 | 23 | execute "install-monit-binary" do 24 | cwd cache_path 25 | command [ 26 | "tar zxvf #{tar_file}", 27 | "cd #{File.basename(tar_file, ".tar.gz")}", 28 | "cp bin/monit #{node["monit"]["binary"]["prefix"]}/bin/monit" 29 | ].join(" && ") 30 | action :nothing 31 | end 32 | 33 | include_recipe "monit::_service_configuration" 34 | -------------------------------------------------------------------------------- /recipes/install_package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: monit 3 | # Recipe:: install_package 4 | # 5 | 6 | include_recipe "yum-epel" if platform_family?("rhel") # ~FC007 uses `suggests` 7 | 8 | package "monit" do 9 | version node["monit"]["version"] if node["monit"]["version"] 10 | end 11 | -------------------------------------------------------------------------------- /recipes/install_source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: monit 3 | # Recipe:: install_source 4 | # 5 | # Emulate a package install using src code 6 | # 7 | 8 | include_recipe "build-essential" 9 | 10 | cache_path = Chef::Config[:file_cache_path] 11 | source_opts = node["monit"]["source"] 12 | monit_version = source_opts["version"] 13 | 14 | pam_pkg = value_for_platform_family( 15 | %w[rhel fedora suse] => "pam-devel", 16 | "debian" => "libpam-dev" 17 | ) 18 | 19 | ssl_pkg = value_for_platform_family( 20 | %w[rhel fedora suse] => "openssl-devel", 21 | "debian" => "libssl-dev" 22 | ) 23 | 24 | package pam_pkg do 25 | only_if { source_opts["pam_support"] } 26 | end 27 | 28 | package ssl_pkg do 29 | only_if { source_opts["ssl_support"] } 30 | end 31 | 32 | remote_file "#{cache_path}/monit-#{monit_version}.tgz" do 33 | source source_opts["url"] 34 | checksum source_opts["checksum"] 35 | action :create_if_missing 36 | end 37 | 38 | config_cmd = "./configure --prefix #{source_opts["prefix"]}" 39 | config_cmd << " --sysconfdir=#{File.dirname(node["monit"]["main_config_path"])}" 40 | config_cmd << " --without-pam" unless source_opts["pam_support"] 41 | config_cmd << " --without-ssl" unless source_opts["ssl_support"] 42 | config_cmd << " --disable-largefile" unless source_opts["large_file_support"] 43 | config_cmd << " --enable-optimized" if source_opts["compiler_optimized"] 44 | 45 | bash "install_monit" do 46 | cwd cache_path 47 | code <<-EOH 48 | tar -xzf monit-#{monit_version}.tgz -C /tmp 49 | cd /tmp/monit-#{monit_version} 50 | #{config_cmd} && make && make install 51 | EOH 52 | creates "#{source_opts["prefix"]}/bin/monit" 53 | end 54 | 55 | include_recipe "monit::_service_configuration" 56 | -------------------------------------------------------------------------------- /recipes/uninstall.rb: -------------------------------------------------------------------------------- 1 | if node["monit"]["source_uninstall"] 2 | include_recipe "monit::uninstall_source" 3 | elsif node["monit"]["binary_uninstall"] 4 | include_recipe "monit::uninstall_binary" 5 | else 6 | include_recipe "yum-epel" if platform_family?("rhel") # ~FC007 uses `suggests` 7 | 8 | package "monit" do 9 | version node["monit"]["version"] if node["monit"]["version"] 10 | action :remove 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /recipes/uninstall_binary.rb: -------------------------------------------------------------------------------- 1 | binary = "#{node["monit"]["binary"]["prefix"]}/bin/monit" 2 | 3 | execute "rm #{binary}" do 4 | only_if { File.exist?(binary) } 5 | end 6 | 7 | template "/etc/init.d/monit" do 8 | source "monit.init.erb" 9 | mode "0755" 10 | variables( 11 | prefix: node["monit"]["binary"]["prefix"], 12 | config: node["monit"]["main_config_path"] 13 | ) 14 | action :delete 15 | end 16 | -------------------------------------------------------------------------------- /recipes/uninstall_source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: monit 3 | # Recipe:: install_source 4 | # 5 | # Remove the binary, libs and init script installed 6 | # by install_source. 7 | # 8 | binary = "#{node["monit"]["source"]["prefix"]}/bin/monit" 9 | 10 | execute "rm #{binary}" do 11 | only_if { File.exist?(binary) } 12 | end 13 | 14 | directory "/var/lib/monit" do 15 | action :delete 16 | end 17 | 18 | template "/etc/init.d/monit" do 19 | source "monit.init.erb" 20 | mode "0755" 21 | variables( 22 | prefix: source_opts["prefix"], 23 | config: node["monit"]["main_config_path"] 24 | ) 25 | action :delete 26 | end 27 | -------------------------------------------------------------------------------- /resources/monitrc.rb: -------------------------------------------------------------------------------- 1 | actions :create, :delete 2 | default_action :create 3 | 4 | attribute :name, kind_of: String, name_attribute: true 5 | attribute :variables, kind_of: Hash 6 | 7 | # the template file name, defaults to #{name}.monitrc.erb 8 | attribute :template_source, kind_of: String 9 | 10 | # the cookbook containing the template, defaults to the one invoking this LWRP 11 | attribute :template_cookbook, kind_of: String 12 | -------------------------------------------------------------------------------- /spec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe "monit::default" do 4 | let(:chef_run) do 5 | ChefSpec::SoloRunner.new.converge("apt", described_recipe) 6 | end 7 | 8 | specify do 9 | expect(chef_run).to include_recipe "apt" 10 | expect(chef_run).to include_recipe "monit::install_package" 11 | expect(chef_run).to_not include_recipe "monit::install_source" 12 | end 13 | 14 | # optionally use encrypted mail credentials 15 | # node["monit"]["mail"]["encrypted_credentials"] 16 | 17 | it "creates the main configuration file" do 18 | monitrc = "/etc/monit/monitrc" 19 | 20 | expect(chef_run).to create_template(monitrc).with( 21 | owner: "root", 22 | group: "root", 23 | mode: "0600", 24 | source: "monitrc.erb" 25 | ) 26 | 27 | expect(chef_run.template(monitrc)).to notify("service[monit]").to(:reload) 28 | # if node["monit"]["reload_on_change"] 29 | end 30 | 31 | it "creates the `/var/monit` directory" do 32 | expect(chef_run).to create_directory("/var/monit").with( 33 | owner: "root", 34 | group: "root", 35 | mode: "0700" 36 | ) 37 | end 38 | 39 | it "creates the service startup file" do 40 | startup = "/etc/default/monit" 41 | 42 | expect(chef_run).to create_file(startup).with( 43 | owner: "root", 44 | group: "root", 45 | mode: "0644" 46 | ) 47 | 48 | expect(chef_run).to render_file(startup).with_content("START=yes") 49 | expect(chef_run).to render_file(startup).with_content("MONIT_OPTS=") 50 | 51 | expect(chef_run.file(startup)).to notify("service[monit]").to(:restart) 52 | end 53 | 54 | it "manages the system service" do 55 | expect(chef_run).to enable_service "monit" 56 | expect(chef_run).to start_service "monit" 57 | end 58 | 59 | it "builds default monitrc files" do 60 | expect(chef_run).to create_monit_monitrc "load" 61 | expect(chef_run).to create_monit_monitrc "ssh" 62 | end 63 | 64 | describe "source installation" do 65 | let(:remote_tarball) do 66 | "#{Chef::Config[:file_cache_path]}/monit-1.2.3.tgz" 67 | end 68 | 69 | let(:chef_run) do 70 | ChefSpec::SoloRunner.new do |node| 71 | node.set["monit"]["source_install"] = true 72 | node.set["monit"]["source"]["version"] = "1.2.3" 73 | end.converge("apt", described_recipe) 74 | end 75 | 76 | specify do 77 | expect(chef_run).to_not include_recipe "monit::install_package" 78 | expect(chef_run).to include_recipe "monit::install_source" 79 | 80 | expect(chef_run).to create_remote_file_if_missing(remote_tarball) 81 | end 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /spec/install_binary_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe "monit::install_binary" do 4 | let(:monit_tarball) { "/var/chef/cache/monit-5.12.2.tar.gz" } 5 | 6 | let(:install_binary_command) do 7 | "tar zxvf monit-5.12.2.tar.gz && cd monit-5.12.2 && cp bin/monit /usr/bin/monit" # rubocop:disable Metrics/LineLength 8 | end 9 | 10 | describe "when binary is not found" do 11 | let(:chef_run) do 12 | ChefSpec::SoloRunner.new(file_cache_path: "/var/chef/cache") do |node| 13 | node.set["monit"]["binary"]["version"] = "5.12.2" 14 | node.set["monit"]["binary"]["prefix"] = "/usr" 15 | end.converge(described_recipe) 16 | end 17 | 18 | specify do 19 | allow(::File).to receive(:exist?).and_call_original 20 | allow(::File).to receive(:exist?).with("/usr/bin/monit").and_return(false) 21 | expect(chef_run).to_not run_execute("rm /usr/bin/monit") 22 | 23 | expect(chef_run).to create_remote_file_if_missing(monit_tarball) 24 | download = chef_run.remote_file(monit_tarball) 25 | expect(download).to notify("execute[install-monit-binary]").to(:run) 26 | 27 | expect(chef_run).to_not( 28 | run_execute("install-monit-binary").with( 29 | cwd: "/var/chef/cache", 30 | command: install_binary_command 31 | ) 32 | ) 33 | expect(chef_run).to include_recipe("monit::_service_configuration") 34 | end 35 | end 36 | 37 | describe "when binary is found and installing a different version" do 38 | let(:chef_run) do 39 | ChefSpec::SoloRunner.new(file_cache_path: "/var/chef/cache") do |node| 40 | node.set["monit"]["binary"]["version"] = "5.12.2" 41 | node.set["monit"]["binary"]["prefix"] = "/usr" 42 | end.converge(described_recipe) 43 | end 44 | 45 | specify do 46 | allow(::File).to receive(:exist?).and_call_original 47 | allow(::File).to receive(:exist?).with("/usr/bin/monit").and_return(true) 48 | 49 | # example: 5.12.1 was installed 50 | stub_command("monit -V | grep 5.12.2").and_return(false) 51 | 52 | expect(chef_run).to run_execute("rm /usr/bin/monit") 53 | remove_existing_binary = chef_run.execute("rm /usr/bin/monit") 54 | expect(remove_existing_binary).to( 55 | notify("remote_file[#{monit_tarball}]").to(:create).immediately 56 | ) 57 | 58 | download = chef_run.remote_file(monit_tarball) 59 | expect(download).to( 60 | notify("execute[install-monit-binary]").to(:run).immediately 61 | ) 62 | 63 | expect(chef_run).to( 64 | create_remote_file_if_missing(monit_tarball) 65 | ) 66 | 67 | expect(chef_run).to_not( 68 | run_execute("install-monit-binary").with( 69 | cwd: "/var/chef/cache", 70 | command: install_binary_command 71 | ) 72 | ) 73 | expect(chef_run).to include_recipe("monit::_service_configuration") 74 | end 75 | end 76 | 77 | describe "when binary is found and installing the same version" do 78 | let(:chef_run) do 79 | ChefSpec::SoloRunner.new(file_cache_path: "/var/chef/cache") do |node| 80 | node.set["monit"]["binary"]["version"] = "5.12.2" 81 | node.set["monit"]["binary"]["prefix"] = "/usr" 82 | end.converge(described_recipe) 83 | end 84 | 85 | specify do 86 | allow(::File).to receive(:exist?).and_call_original 87 | allow(::File).to receive(:exist?).with("/usr/bin/monit").and_return(true) 88 | stub_command("monit -V | grep 5.12.2").and_return(true) 89 | 90 | expect(chef_run).not_to run_execute("rm /usr/bin/monit") 91 | 92 | expect(chef_run).to_not( 93 | run_execute("install-monit-binary").with( 94 | cwd: "/var/chef/cache", 95 | command: install_binary_command 96 | ) 97 | ) 98 | expect(chef_run).to include_recipe("monit::_service_configuration") 99 | end 100 | end 101 | end 102 | -------------------------------------------------------------------------------- /spec/install_package_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe "monit::install_package" do 4 | describe "debian platform family" do 5 | let(:chef_run) do 6 | ChefSpec::SoloRunner.new do |node| 7 | node.set["monit"]["version"] = "1.2.3" 8 | end.converge("apt", described_recipe) 9 | end 10 | 11 | specify do 12 | expect(chef_run).to_not include_recipe "yum-epel" 13 | expect(chef_run).to install_package("monit").with(version: "1.2.3") 14 | end 15 | end 16 | 17 | describe "redhat platform family" do 18 | let(:chef_run) do 19 | platform = { platform: "centos", version: "6.5" } 20 | ChefSpec::SoloRunner.new(platform).converge("yum-epel", described_recipe) 21 | end 22 | 23 | specify do 24 | expect(chef_run).to include_recipe "yum-epel" 25 | expect(chef_run).to install_package "monit" 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /spec/install_source_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe "monit::install_source" do 4 | let(:remote_tarball) do 5 | "#{Chef::Config[:file_cache_path]}/monit-1.2.3.tgz" 6 | end 7 | 8 | describe "debian platform family" do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new do |node| 11 | node.set["monit"]["source_install"] = true 12 | node.set["monit"]["source"]["version"] = "1.2.3" 13 | end.converge("apt", described_recipe) 14 | end 15 | 16 | specify do 17 | expect(chef_run).to install_package "libpam-dev" 18 | expect(chef_run).to install_package "libssl-dev" 19 | 20 | expect(chef_run).to create_remote_file_if_missing(remote_tarball) 21 | 22 | expect(chef_run).to create_directory "/etc/monit" 23 | expect(chef_run).to create_directory "/etc/monit/conf.d" 24 | 25 | expect(chef_run).to_not run_execute "chkconfig monit on" 26 | end 27 | end 28 | 29 | describe "redhat platform family" do 30 | let(:chef_run) do 31 | platform = { platform: "centos", version: "6.5" } 32 | ChefSpec::SoloRunner.new(platform) do |node| 33 | node.set["monit"]["source_install"] = true 34 | node.set["monit"]["source"]["version"] = "1.2.3" 35 | end.converge("yum-epel", described_recipe) 36 | end 37 | 38 | before do 39 | stub_command("chkconfig --list | grep 'monit ' | grep '2:on'") 40 | .and_return(false) 41 | end 42 | 43 | specify do 44 | expect(chef_run).to install_package "pam-devel" 45 | expect(chef_run).to install_package "openssl-devel" 46 | 47 | expect(chef_run).to create_remote_file_if_missing(remote_tarball) 48 | 49 | expect(chef_run).to create_directory "/etc" 50 | expect(chef_run).to create_directory "/etc/monit.d" 51 | 52 | expect(chef_run).to run_execute "chkconfig monit on" 53 | end 54 | end 55 | 56 | # shared behavior 57 | let(:chef_run) do 58 | ChefSpec::SoloRunner.new do |node| 59 | node.set["monit"]["source_install"] = true 60 | node.set["monit"]["source"]["version"] = "1.2.3" 61 | end.converge("apt", described_recipe) 62 | end 63 | 64 | specify do 65 | expect(chef_run).to create_remote_file_if_missing(remote_tarball) 66 | expect(chef_run).to run_bash "install_monit" 67 | expect(chef_run).to create_directory "/var/lib/monit" 68 | expect(chef_run).to create_template("/etc/init.d/monit").with( 69 | source: "monit.init.erb", 70 | mode: "0755" 71 | ) 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require "chefspec" 3 | require "chefspec/berkshelf" 4 | rescue LoadError 5 | puts "Unable to run `chefspec`" 6 | exit 7 | end 8 | 9 | RSpec.configure do |config| 10 | config.platform = "ubuntu" 11 | config.version = "12.04" 12 | config.log_level = :error 13 | config.raise_errors_for_deprecations! 14 | end 15 | 16 | def add_apt_repository(resource_name) 17 | ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :add, resource_name) 18 | end 19 | 20 | at_exit { ChefSpec::Coverage.report! } 21 | -------------------------------------------------------------------------------- /templates/amazon/ssh.monitrc.erb: -------------------------------------------------------------------------------- 1 | check process sshd with pidfile /var/run/sshd.pid 2 | start program "/sbin/service sshd start" 3 | stop program "/sbin/service sshd stop" 4 | if failed port 22 protocol ssh then restart 5 | if 5 restarts within 5 cycles then timeout -------------------------------------------------------------------------------- /templates/centos/monit.init.erb: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # monit Monitor Unix systems 4 | # 5 | # Author: Clinton Work, 6 | # 7 | # chkconfig: 2345 98 02 8 | # description: Monit is a utility for managing and monitoring processes, 9 | # files, directories and filesystems on a Unix system. 10 | # processname: monit 11 | # pidfile: /var/run/monit.pid 12 | # config: /etc/monit.conf 13 | 14 | # Source function library. 15 | . /etc/rc.d/init.d/functions 16 | 17 | # Source networking configuration. 18 | . /etc/sysconfig/network 19 | 20 | MONIT=/usr/bin/monit 21 | 22 | # Source monit configuration. 23 | if [ -f /etc/sysconfig/monit ] ; then 24 | . /etc/sysconfig/monit 25 | fi 26 | 27 | CONFIG="<%= @config %>" 28 | MONIT_OPTS="-c $CONFIG $MONIT_OPTS" 29 | 30 | [ -f $MONIT ] || exit 0 31 | 32 | RETVAL=0 33 | 34 | # See how we were called. 35 | case "$1" in 36 | start) 37 | echo -n "Starting monit: " 38 | daemon $NICELEVEL $MONIT $MONIT_OPTS 39 | RETVAL=$? 40 | echo 41 | [ $RETVAL = 0 ] && touch /var/lock/subsys/monit 42 | ;; 43 | stop) 44 | echo -n "Stopping monit: " 45 | killproc monit 46 | RETVAL=$? 47 | echo 48 | [ $RETVAL = 0 ] && rm -f /var/lock/subsys/monit 49 | ;; 50 | restart) 51 | $0 stop 52 | $0 start 53 | RETVAL=$? 54 | ;; 55 | reload) 56 | echo -n "Reloading monit: " 57 | $MONIT $MONIT_OPTS reload 58 | RETVAL=$? 59 | ;; 60 | condrestart) 61 | [ -e /var/lock/subsys/monit ] && $0 restart 62 | ;; 63 | status) 64 | status monit 65 | RETVAL=$? 66 | ;; 67 | *) 68 | echo "Usage: $0 {start|stop|restart|condrestart|status}" 69 | exit 1 70 | esac 71 | 72 | exit $RETVAL 73 | -------------------------------------------------------------------------------- /templates/centos/ssh.monitrc.erb: -------------------------------------------------------------------------------- 1 | check process sshd with pidfile /var/run/sshd.pid 2 | start program "/sbin/service sshd start" 3 | stop program "/sbin/service sshd stop" 4 | if failed port 22 protocol ssh then restart 5 | if 5 restarts within 5 cycles then timeout -------------------------------------------------------------------------------- /templates/default/load.monitrc.erb: -------------------------------------------------------------------------------- 1 | check system <%= node["fqdn"] %> 2 | if loadavg (1min) > 4 for 2 cycles then alert 3 | if loadavg (5min) > 2 for 2 cycles then alert 4 | if memory usage > 75% for 2 cycles then alert 5 | if cpu usage (user) > 70% for 2 cycles then alert 6 | if cpu usage (system) > 30% for 2 cycles then alert 7 | if cpu usage (wait) > 20% for 2 cycles then alert 8 | -------------------------------------------------------------------------------- /templates/default/monit.init.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: monit 5 | # Required-Start: $remote_fs 6 | # Required-Stop: $remote_fs 7 | # Should-Start: $all 8 | # Should-Stop: $all 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: service and resource monitoring daemon 12 | # Description: monit is a utility for managing and monitoring 13 | # processes, programs, files, directories and filesystems 14 | # on a Unix system. Monit conducts automatic maintenance 15 | # and repair and can execute meaningful causal actions 16 | # in error situations. 17 | ### END INIT INFO 18 | 19 | set -e 20 | 21 | [ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions 22 | [ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions 23 | 24 | DAEMON="<%= @prefix %>/bin/monit" 25 | CONFIG="<%= @config %>" 26 | NAME=monit 27 | DESC="daemon monitor" 28 | MONIT_OPTS= 29 | PID="<%= @pidfile %>" 30 | 31 | # Check if DAEMON binary exist 32 | [ -f $DAEMON ] || exit 0 33 | 34 | [ -f "/etc/default/$NAME" ] && . /etc/default/$NAME 35 | 36 | MONIT_OPTS="-c $CONFIG $MONIT_OPTS" 37 | 38 | monit_not_configured () { 39 | if [ "$1" != "stop" ] 40 | then 41 | printf "\tplease configure $NAME and then edit /etc/default/$NAME\n" 42 | printf "\tand set the \"START\" variable to \"yes\" in order to allow\n" 43 | printf "\t$NAME to start\n" 44 | fi 45 | exit 0 46 | } 47 | 48 | monit_checks () { 49 | # Check if START variable is set to "yes", if not we exit. 50 | if [ "$START" != "yes" ] 51 | then 52 | monit_not_configured $1 53 | fi 54 | } 55 | 56 | case "$1" in 57 | start) 58 | mkdir -p $(dirname $PID) 59 | log_daemon_msg "Starting $DESC" "$NAME" 60 | monit_checks $1 61 | if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $MONIT_OPTS 1>/dev/null 62 | then 63 | log_end_msg 0 64 | else 65 | log_end_msg 1 66 | fi 67 | ;; 68 | stop) 69 | log_daemon_msg "Stopping $DESC" "$NAME" 70 | if start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null 71 | then 72 | log_end_msg 0 73 | else 74 | log_end_msg 1 75 | fi 76 | ;; 77 | reload) 78 | log_daemon_msg "Reloading $DESC configuration" "$NAME" 79 | if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID --exec $DAEMON -- $MONIT_OPTS 1>/dev/null 80 | then 81 | log_end_msg 0 82 | else 83 | log_end_msg 1 84 | fi 85 | ;; 86 | restart|force-reload) 87 | log_daemon_msg "Restarting $DESC" "$NAME" 88 | start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null 89 | if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $MONIT_OPTS 1>/dev/null 90 | then 91 | log_end_msg 0 92 | else 93 | log_end_msg 1 94 | fi 95 | ;; 96 | syntax) 97 | $DAEMON $MONIT_OPTS -t 98 | ;; 99 | status) 100 | status_of_proc -p $PID $DAEMON $NAME 101 | ;; 102 | *) 103 | log_action_msg "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|syntax|status}" 104 | ;; 105 | esac 106 | 107 | exit 0 108 | -------------------------------------------------------------------------------- /templates/default/monitrc.erb: -------------------------------------------------------------------------------- 1 | # Polling frequency 2 | set daemon <%= node["monit"]["polling_frequency"] %> 3 | <% if node["monit"]["start_delay"].to_i > 0 %> 4 | with start delay <%= node["monit"]["start_delay"].to_i %> 5 | <% end -%> 6 | 7 | # Logging 8 | <% if node["monit"]["use_syslog"] %> 9 | set logfile syslog facility log_daemon 10 | <% elsif node["monit"]["logfile"] %> 11 | set logfile <%= node["monit"]["logfile"] %> 12 | <% end %> 13 | 14 | # Set location of Monit pid file 15 | <% if node["monit"]["pidfile"] %> 16 | set pidfile <%= node["monit"]["pidfile"] %> 17 | <% end %> 18 | 19 | # Set location of Monit id file 20 | <% if node["monit"]["idfile"] %> 21 | set idfile <%= node["monit"]["idfile"] %> 22 | <% end %> 23 | 24 | # Set location of Monit state file 25 | <% if node["monit"]["statefile"] %> 26 | set statefile <%= node["monit"]["statefile"] %> 27 | <% end %> 28 | 29 | <% if node['monit']['mail_alerts'] %> 30 | # Mail alerts 31 | <% alert_email_map = node['monit']['alert_email'] %> 32 | <% unless alert_email_map.is_a? Hash %> 33 | <% alert_email_map = { alert_email_map => { 'onlyon_events' => node['monit']['alert_onlyon_events'], 'ignore_events' => node['monit']['alert_ignore_events'] } } %> 34 | <% end %> 35 | <% alert_email_map.each do |alert_emails, events_map| %> 36 | <% onlyon = events_map['onlyon_events'].join(', ') rescue '' %> 37 | <% ignore = events_map['ignore_events'].join(', ') rescue '' %> 38 | <% (alert_emails.is_a?(Array) ? alert_emails : alert_emails.split(/[, ]+/)).each do |alert_email| %> 39 | set alert <%= alert_email %> <%= onlyon.empty? ? '' : "on { #{onlyon} }" %> <%= ignore.empty? ? '' : "but not on { #{ignore} }" %> 40 | <% end %> 41 | <% end %> 42 | <% end %> 43 | 44 | set mailserver <%= node["monit"]["mail"]["hostname"] %> port <%= node["monit"]["mail"]["port"] %> 45 | <% if node["monit"]["mail"]["username"] -%> 46 | username "<%= node["monit"]["mail"]["username"] %>" 47 | <% end -%> 48 | <% if node["monit"]["mail"]["password"] -%> 49 | password "<%= node["monit"]["mail"]["password"] %>" 50 | <% end -%> 51 | <% if node["monit"]["mail"]["security"] -%> 52 | using <%= node["monit"]["mail"]["security"] %> 53 | <% end -%> 54 | with timeout <%= node["monit"]["mail"]["timeout"] %> seconds 55 | <% if node["monit"]["mail"]["using_hostname"] -%> 56 | using hostname <%= node["monit"]["mail"]["using_hostname"] %> 57 | <% end -%> 58 | 59 | set mail-format { 60 | from: <%= node["monit"]["mail"]["from"] %> 61 | subject: <%= node["monit"]["mail"]["subject"] %> 62 | message: <%= node["monit"]["mail"]["message"] %> 63 | } 64 | 65 | <% if node["monit"]["web_interface"]["enable"] %> 66 | # Web interface 67 | set httpd port <%= node["monit"]["web_interface"]["port"] %> 68 | <% if node["monit"]["web_interface"]["address"] %>use address <%= node["monit"]["web_interface"]["address"] %><% end %> 69 | <% node["monit"]["web_interface"]["allow"].each do |allow| -%> 70 | allow <%= allow %> 71 | <% end %> 72 | <% end %> 73 | 74 | # Include config files 75 | include <%= node["monit"]["includes_dir"] %>/* 76 | -------------------------------------------------------------------------------- /templates/default/ssh.monitrc.erb: -------------------------------------------------------------------------------- 1 | check process sshd with pidfile /var/run/sshd.pid 2 | start program "/etc/init.d/ssh start" 3 | stop program "/etc/init.d/ssh stop" 4 | if failed port 22 protocol ssh then restart 5 | if 5 restarts within 5 cycles then timeout -------------------------------------------------------------------------------- /test/.chef/knife.rb: -------------------------------------------------------------------------------- 1 | cache_type "BasicFile" 2 | cache_options(path: "#{ENV["HOME"]}/.chef/checksums") 3 | ssl_verify_mode :verify_peer 4 | -------------------------------------------------------------------------------- /test/integration/binary/serverspec/localhost/binary_install_spec.rb: -------------------------------------------------------------------------------- 1 | require "serverspec" 2 | 3 | set :backend, :exec 4 | 5 | def redhat? 6 | os[:family] == "redhat" 7 | end 8 | 9 | def status_command 10 | config_file = redhat? ? "/etc/monit.conf" : "/etc/monit/monitrc" 11 | "monit -c #{config_file} status" 12 | end 13 | 14 | describe "Binary install of monit" do 15 | describe package("monit") do 16 | it { should_not be_installed } 17 | end 18 | 19 | describe command("monit -V") do 20 | its(:stdout) { should match(/version 5\.12\.2/) } 21 | its(:exit_status) { should eq 0 } 22 | end 23 | 24 | describe service("monit") do 25 | it { should be_enabled } 26 | it { should be_running } 27 | end 28 | 29 | describe command(status_command) do 30 | its(:stdout) { should match(/System '[\w\-\.]+'/) } 31 | its(:stdout) { should match(/status\s+(Initializing|Running)/) } 32 | its(:stdout) do 33 | should match(/monitoring status\s+(Initializing|Monitored)/) 34 | end 35 | its(:exit_status) { should eq 0 } 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/localhost/default_install_spec.rb: -------------------------------------------------------------------------------- 1 | require "serverspec" 2 | 3 | set :backend, :exec 4 | 5 | def redhat? 6 | os[:family] == "redhat" 7 | end 8 | 9 | describe "Default install of monit" do 10 | describe package("monit") do 11 | it { should be_installed } 12 | end 13 | 14 | describe command("monit -V") do 15 | its(:stdout) { should match(/monit version \d\.\d/i) } 16 | its(:exit_status) { should eq 0 } 17 | end 18 | 19 | describe service("monit") do 20 | it { should be_enabled } 21 | it { should be_running } 22 | end 23 | 24 | describe command("monit status") do 25 | its(:stdout) { should match(/System '[\w\-\.]+'/) } 26 | its(:stdout) do 27 | should match(/monitoring status\s+(Initializing|Monitored)/i) 28 | end 29 | 30 | if redhat? 31 | its(:stdout) { should match(/The Monit daemon \d\.\d\.\d uptime: \d+m/) } 32 | else 33 | its(:stdout) { should match(/status\s+(Initializing|Running)/) } 34 | end 35 | 36 | its(:exit_status) { should eq 0 } 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /test/integration/source/serverspec/localhost/source_install_spec.rb: -------------------------------------------------------------------------------- 1 | require "serverspec" 2 | 3 | set :backend, :exec 4 | 5 | def redhat? 6 | os[:family] == "redhat" 7 | end 8 | 9 | def status_command 10 | config_file = redhat? ? "/etc/monit.conf" : "/etc/monit/monitrc" 11 | "monit -c #{config_file} status" 12 | end 13 | 14 | describe "Source install of monit" do 15 | describe package("monit") do 16 | it { should_not be_installed } 17 | end 18 | 19 | describe command("monit -V") do 20 | its(:stdout) { should match(/version 5\.12\.2/) } 21 | its(:exit_status) { should eq 0 } 22 | end 23 | 24 | describe service("monit") do 25 | it { should be_enabled } 26 | it { should be_running } 27 | end 28 | 29 | describe command(status_command) do 30 | its(:stdout) { should match(/System '[\w\-\.]+'/) } 31 | its(:stdout) { should match(/status\s+(Initializing|Running)/) } 32 | its(:stdout) do 33 | should match(/monitoring status\s+(Initializing|Monitored)/) 34 | end 35 | its(:exit_status) { should eq 0 } 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /test/rubocop/disabled.yml: -------------------------------------------------------------------------------- 1 | Encoding: 2 | Description: 'Use UTF-8 as the source file encoding.' 3 | Enabled: false 4 | 5 | SymbolArray: 6 | Description: 'Use %i or %I for arrays of symbols.' 7 | Enabled: false 8 | 9 | ##################### Rails ################################## 10 | 11 | DefaultScope: 12 | Description: 'Checks if the argument passed to default_scope is a block.' 13 | Enabled: false 14 | 15 | HasAndBelongsToMany: 16 | Description: 'Prefer has_many :through to has_and_belongs_to_many.' 17 | Enabled: false 18 | 19 | Output: 20 | Description: 'Checks for calls to puts, print, etc.' 21 | Enabled: false 22 | 23 | Validation: 24 | Description: 'Use sexy validations.' 25 | Enabled: false 26 | -------------------------------------------------------------------------------- /test/rubocop/enabled.yml: -------------------------------------------------------------------------------- 1 | # These are all the cops that are enabled in the default configuration. 2 | 3 | AccessModifierIndentation: 4 | Description: Check indentation of private/protected visibility modifiers. 5 | Enabled: true 6 | 7 | AccessorMethodName: 8 | Description: Check the naming of accessor methods for get_/set_. 9 | Enabled: true 10 | 11 | Alias: 12 | Description: 'Use alias_method instead of alias.' 13 | Enabled: true 14 | 15 | AlignArray: 16 | Description: >- 17 | Align the elements of an array literal if they span more than 18 | one line. 19 | Enabled: true 20 | 21 | AlignHash: 22 | Description: >- 23 | Align the elements of a hash literal if they span more than 24 | one line. 25 | Enabled: true 26 | 27 | AlignParameters: 28 | Description: >- 29 | Align the parameters of a method call if they span more 30 | than one line. 31 | Enabled: true 32 | 33 | AndOr: 34 | Description: 'Use &&/|| instead of and/or.' 35 | Enabled: true 36 | 37 | AsciiComments: 38 | Description: 'Use only ascii symbols in comments.' 39 | Enabled: true 40 | 41 | AsciiIdentifiers: 42 | Description: 'Use only ascii symbols in identifiers.' 43 | Enabled: true 44 | 45 | Attr: 46 | Description: 'Checks for uses of Module#attr.' 47 | Enabled: true 48 | 49 | BeginBlock: 50 | Description: 'Avoid the use of BEGIN blocks.' 51 | Enabled: true 52 | 53 | BlockComments: 54 | Description: 'Do not use block comments.' 55 | Enabled: true 56 | 57 | BlockNesting: 58 | Description: 'Avoid excessive block nesting' 59 | Enabled: true 60 | 61 | Blocks: 62 | Description: >- 63 | Avoid using {...} for multi-line blocks (multiline chaining is 64 | always ugly). 65 | Prefer {...} over do...end for single-line blocks. 66 | Enabled: true 67 | 68 | BracesAroundHashParameters: 69 | Description: 'Enforce braces style inside hash parameters.' 70 | Enabled: true 71 | 72 | CaseEquality: 73 | Description: 'Avoid explicit use of the case equality operator(===).' 74 | Enabled: true 75 | 76 | CaseIndentation: 77 | Description: 'Indentation of when in a case/when/[else/]end.' 78 | Enabled: true 79 | 80 | CharacterLiteral: 81 | Description: 'Checks for uses of character literals.' 82 | Enabled: true 83 | 84 | ClassAndModuleCamelCase: 85 | Description: 'Use CamelCase for classes and modules.' 86 | Enabled: true 87 | 88 | ClassLength: 89 | Description: 'Avoid classes longer than 100 lines of code.' 90 | Enabled: true 91 | 92 | ClassMethods: 93 | Description: 'Use self when defining module/class methods.' 94 | Enabled: true 95 | 96 | ClassVars: 97 | Description: 'Avoid the use of class variables.' 98 | Enabled: true 99 | 100 | CollectionMethods: 101 | Description: 'Preferred collection methods.' 102 | Enabled: true 103 | 104 | ColonMethodCall: 105 | Description: 'Do not use :: for method call.' 106 | Enabled: true 107 | 108 | CommentAnnotation: 109 | Description: >- 110 | Checks formatting of special comments 111 | (TODO, FIXME, OPTIMIZE, HACK, REVIEW). 112 | Enabled: true 113 | 114 | ConstantName: 115 | Description: 'Constants should use SCREAMING_SNAKE_CASE.' 116 | Enabled: true 117 | 118 | CyclomaticComplexity: 119 | Description: 'Avoid complex methods.' 120 | Enabled: true 121 | 122 | DefWithParentheses: 123 | Description: 'Use def with parentheses when there are arguments.' 124 | Enabled: true 125 | 126 | Documentation: 127 | Description: 'Document classes and non-namespace modules.' 128 | Enabled: true 129 | 130 | DotPosition: 131 | Description: 'Checks the position of the dot in multi-line method calls.' 132 | Enabled: true 133 | 134 | EmptyLineBetweenDefs: 135 | Description: 'Use empty lines between defs.' 136 | Enabled: true 137 | 138 | EmptyLines: 139 | Description: "Don't use several empty lines in a row." 140 | Enabled: true 141 | 142 | EmptyLinesAroundAccessModifier: 143 | Description: "Keep blank lines around access modifiers." 144 | Enabled: true 145 | 146 | EmptyLinesAroundBody: 147 | Description: "Keeps track of empty lines around expression bodies." 148 | Enabled: true 149 | 150 | EmptyLiteral: 151 | Description: 'Prefer literals to Array.new/Hash.new/String.new.' 152 | Enabled: true 153 | 154 | EndBlock: 155 | Description: 'Avoid the use of END blocks.' 156 | Enabled: true 157 | 158 | EndOfLine: 159 | Description: 'Use Unix-style line endings.' 160 | Enabled: true 161 | 162 | EvenOdd: 163 | Description: 'Favor the use of Fixnum#even? && Fixnum#odd?' 164 | Enabled: true 165 | 166 | FavorJoin: 167 | Description: 'Use Array#join instead of Array#*.' 168 | Enabled: true 169 | 170 | FavorUnlessOverNegatedIf: 171 | Description: >- 172 | Favor unless over if for negative conditions 173 | (or control flow or). 174 | Enabled: true 175 | 176 | FavorUntilOverNegatedWhile: 177 | Description: 'Favor until over while for negative conditions.' 178 | Enabled: true 179 | 180 | FileName: 181 | Description: 'Use snake_case for source file names.' 182 | Enabled: true 183 | 184 | FinalNewline: 185 | Description: 'Checks for a final newline in a source file.' 186 | Enabled: true 187 | 188 | FlipFlop: 189 | Description: 'Checks for flip flops' 190 | Enabled: true 191 | 192 | For: 193 | Description: 'Checks use of for or each in multiline loops.' 194 | Enabled: true 195 | 196 | FormatString: 197 | Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.' 198 | Enabled: true 199 | 200 | GlobalVars: 201 | Description: 'Do not introduce global variables.' 202 | Enabled: true 203 | 204 | HashMethods: 205 | Description: 'Checks for use of deprecated Hash methods.' 206 | Enabled: true 207 | 208 | HashSyntax: 209 | Description: >- 210 | Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax 211 | { :a => 1, :b => 2 }. 212 | Enabled: true 213 | 214 | IfUnlessModifier: 215 | Description: >- 216 | Favor modifier if/unless usage when you have a 217 | single-line body. 218 | Enabled: true 219 | 220 | IfWithSemicolon: 221 | Description: 'Never use if x; .... Use the ternary operator instead.' 222 | Enabled: true 223 | 224 | IndentationConsistency: 225 | Description: 'Keep indentation straight.' 226 | Enabled: true 227 | 228 | IndentationWidth: 229 | Description: 'Use 2 spaces for indentation.' 230 | Enabled: true 231 | 232 | IndentArray: 233 | Description: >- 234 | Checks the indentation of the first element in an array 235 | literal. 236 | Enabled: true 237 | 238 | IndentHash: 239 | Description: 'Checks the indentation of the first key in a hash literal.' 240 | Enabled: true 241 | 242 | Lambda: 243 | Description: 'Use the new lambda literal syntax for single-line blocks.' 244 | Enabled: true 245 | 246 | LambdaCall: 247 | Description: 'Use lambda.call(...) instead of lambda.(...).' 248 | Enabled: true 249 | 250 | LeadingCommentSpace: 251 | Description: 'Comments should start with a space.' 252 | Enabled: true 253 | 254 | LineEndConcatenation: 255 | Description: 'Use \\ instead of + to concatenate two string literals at line end.' 256 | Enabled: true 257 | 258 | LineLength: 259 | Description: 'Limit lines to 79 characters.' 260 | Enabled: true 261 | 262 | MethodCalledOnDoEndBlock: 263 | Description: 'Avoid chaining a method call on a do...end block.' 264 | Enabled: true 265 | 266 | MethodCallParentheses: 267 | Description: 'Do not use parentheses for method calls with no arguments.' 268 | Enabled: true 269 | 270 | MethodDefParentheses: 271 | Description: >- 272 | Checks if the method definitions have or don't have 273 | parentheses. 274 | Enabled: true 275 | 276 | MethodLength: 277 | Description: 'Avoid methods longer than 10 lines of code.' 278 | Enabled: true 279 | 280 | MethodName: 281 | Description: 'Use the configured style when naming methods.' 282 | Enabled: true 283 | 284 | ModuleFunction: 285 | Description: 'Checks for usage of `extend self` in modules.' 286 | Enabled: true 287 | 288 | MultilineBlockChain: 289 | Description: 'Avoid multi-line chains of blocks.' 290 | Enabled: true 291 | 292 | MultilineIfThen: 293 | Description: 'Never use then for multi-line if/unless.' 294 | Enabled: true 295 | 296 | MultilineTernaryOperator: 297 | Description: >- 298 | Avoid multi-line ?: (the ternary operator); 299 | use if/unless instead. 300 | Enabled: true 301 | 302 | NestedTernaryOperator: 303 | Description: 'Use one expression per branch in a ternary operator.' 304 | Enabled: true 305 | 306 | NilComparison: 307 | Description: 'Prefer x.nil? to x == nil.' 308 | Enabled: true 309 | 310 | Not: 311 | Description: 'Use ! instead of not.' 312 | Enabled: true 313 | 314 | NumericLiterals: 315 | Description: >- 316 | Add underscores to large numeric literals to improve their 317 | readability. 318 | Enabled: true 319 | 320 | OneLineConditional: 321 | Description: >- 322 | Favor the ternary operator(?:) over 323 | if/then/else/end constructs. 324 | Enabled: true 325 | 326 | OpMethod: 327 | Description: 'When defining binary operators, name the argument other.' 328 | Enabled: true 329 | 330 | ParameterLists: 331 | Description: 'Avoid parameter lists longer than three or four parameters.' 332 | Enabled: true 333 | 334 | ParenthesesAroundCondition: 335 | Description: >- 336 | Don't use parentheses around the condition of an 337 | if/unless/while. 338 | Enabled: true 339 | 340 | PerlBackrefs: 341 | Description: 'Avoid Perl-style regex back references.' 342 | Enabled: true 343 | 344 | PredicateName: 345 | Description: 'Check the names of predicate methods.' 346 | Enabled: true 347 | 348 | Proc: 349 | Description: 'Use proc instead of Proc.new.' 350 | Enabled: true 351 | 352 | RaiseArgs: 353 | Description: 'Checks the arguments passed to raise/fail.' 354 | Enabled: true 355 | 356 | RedundantBegin: 357 | Description: "Don't use begin blocks when they are not needed." 358 | Enabled: true 359 | 360 | RedundantException: 361 | Description: "Checks for an obsolete RuntimeException argument in raise/fail." 362 | Enabled: true 363 | 364 | RedundantReturn: 365 | Description: "Don't use return where it's not required." 366 | Enabled: true 367 | 368 | RedundantSelf: 369 | Description: "Don't use self where it's not needed." 370 | Enabled: true 371 | 372 | RegexpLiteral: 373 | Description: >- 374 | Use %r for regular expressions matching more than 375 | `MaxSlashes` '/' characters. 376 | Use %r only for regular expressions matching more than 377 | `MaxSlashes` '/' character. 378 | Enabled: true 379 | 380 | RescueModifier: 381 | Description: 'Avoid using rescue in its modifier form.' 382 | Enabled: true 383 | 384 | Semicolon: 385 | Description: "Don't use semicolons to terminate expressions." 386 | Enabled: true 387 | 388 | SignalException: 389 | Description: 'Checks for proper usage of fail and raise.' 390 | Enabled: true 391 | 392 | SingleLineBlockParams: 393 | Description: 'Enforces the names of some block params.' 394 | Enabled: true 395 | 396 | SingleLineMethods: 397 | Description: 'Avoid single-line methods.' 398 | Enabled: true 399 | 400 | SpaceAfterColon: 401 | Description: 'Use spaces after colons.' 402 | Enabled: true 403 | 404 | SpaceAfterComma: 405 | Description: 'Use spaces after commas.' 406 | Enabled: true 407 | 408 | SpaceAfterControlKeyword: 409 | Description: 'Use spaces after if/elsif/unless/while/until/case/when.' 410 | Enabled: true 411 | 412 | SpaceAfterMethodName: 413 | Description: >- 414 | Never put a space between a method name and the opening 415 | parenthesis. 416 | Enabled: true 417 | 418 | SpaceAfterNot: 419 | Description: Tracks redundant space after the ! operator. 420 | Enabled: true 421 | 422 | SpaceAfterSemicolon: 423 | Description: 'Use spaces after semicolons.' 424 | Enabled: true 425 | 426 | SpaceAroundBlockBraces: 427 | Description: >- 428 | Checks that block braces have or don't have surrounding space. 429 | For blocks taking parameters, checks that the left brace has 430 | or doesn't have trailing space. 431 | Enabled: true 432 | 433 | SpaceAroundEqualsInParameterDefault: 434 | Description: >- 435 | Use spaces around the = operator when assigning default 436 | values in def params. 437 | Enabled: true 438 | 439 | SpaceAroundOperators: 440 | Description: 'Use spaces around operators.' 441 | Enabled: true 442 | 443 | SpaceBeforeModifierKeyword: 444 | Description: 'Put a space before the modifier keyword.' 445 | Enabled: true 446 | 447 | SpaceInsideBrackets: 448 | Description: 'No spaces after [ or before ].' 449 | Enabled: true 450 | 451 | SpaceInsideHashLiteralBraces: 452 | Description: "Use spaces inside hash literal braces - or don't." 453 | Enabled: true 454 | 455 | SpaceInsideParens: 456 | Description: 'No spaces after ( or before ).' 457 | Enabled: true 458 | 459 | SpecialGlobalVars: 460 | Description: 'Avoid Perl-style global variables.' 461 | Enabled: true 462 | 463 | StringLiterals: 464 | Description: 'Checks if uses of quotes match the configured preference.' 465 | Enabled: true 466 | 467 | Tab: 468 | Description: 'No hard tabs.' 469 | Enabled: true 470 | 471 | TrailingBlankLines: 472 | Description: 'Checks for superfluous trailing blank lines.' 473 | Enabled: true 474 | 475 | TrailingComma: 476 | Description: 'Checks for trailing comma in parameter lists and literals.' 477 | Enabled: true 478 | 479 | TrailingWhitespace: 480 | Description: 'Avoid trailing whitespace.' 481 | Enabled: true 482 | 483 | TrivialAccessors: 484 | Description: 'Prefer attr_* methods to trivial readers/writers.' 485 | Enabled: true 486 | 487 | UnlessElse: 488 | Description: >- 489 | Never use unless with else. Rewrite these with the positive 490 | case first. 491 | Enabled: true 492 | 493 | VariableInterpolation: 494 | Description: >- 495 | Don't interpolate global, instance and class variables 496 | directly in strings. 497 | Enabled: true 498 | 499 | VariableName: 500 | Description: 'Use the configured style when naming variables.' 501 | Enabled: true 502 | 503 | WhenThen: 504 | Description: 'Use when x then ... for one-line cases.' 505 | Enabled: true 506 | 507 | WhileUntilDo: 508 | Description: 'Checks for redundant do after while or until.' 509 | Enabled: true 510 | 511 | WhileUntilModifier: 512 | Description: >- 513 | Favor modifier while/until usage when you have a 514 | single-line body. 515 | Enabled: true 516 | 517 | WordArray: 518 | Description: 'Use %w or %W for arrays of words.' 519 | Enabled: true 520 | 521 | #################### Lint ################################ 522 | ### Warnings 523 | 524 | AmbiguousOperator: 525 | Description: >- 526 | Checks for ambiguous operators in the first argument of a 527 | method invocation without parentheses. 528 | Enabled: true 529 | 530 | AmbiguousRegexpLiteral: 531 | Description: >- 532 | Checks for ambiguous regexp literals in the first argument of 533 | a method invocation without parenthesis. 534 | Enabled: true 535 | 536 | AssignmentInCondition: 537 | Description: "Don't use assignment in conditions." 538 | Enabled: true 539 | 540 | BlockAlignment: 541 | Description: 'Align block ends correctly.' 542 | Enabled: true 543 | 544 | ConditionPosition: 545 | Description: 'Checks for condition placed in a confusing position relative to the keyword.' 546 | Enabled: true 547 | 548 | Debugger: 549 | Description: 'Check for debugger calls.' 550 | Enabled: true 551 | 552 | DeprecatedClassMethods: 553 | Description: 'Check for deprecated class method calls.' 554 | Enabled: true 555 | 556 | ElseLayout: 557 | Description: 'Check for odd code arrangement in an else block.' 558 | Enabled: true 559 | 560 | EmptyEnsure: 561 | Description: 'Checks for empty ensure block.' 562 | Enabled: true 563 | 564 | EndAlignment: 565 | Description: 'Align ends correctly.' 566 | Enabled: true 567 | 568 | EndInMethod: 569 | Description: 'END blocks should not be placed inside method definitions.' 570 | Enabled: true 571 | 572 | EnsureReturn: 573 | Description: 'Never use return in an ensure block.' 574 | Enabled: true 575 | 576 | Eval: 577 | Description: 'The use of eval represents a serious security risk.' 578 | Enabled: true 579 | 580 | HandleExceptions: 581 | Description: "Don't suppress exception." 582 | Enabled: true 583 | 584 | InvalidCharacterLiteral: 585 | Description: >- 586 | Checks for invalid character literals with a non-escaped 587 | whitespace character. 588 | Enabled: true 589 | 590 | LiteralInCondition: 591 | Description: 'Checks of literals used in conditions.' 592 | Enabled: true 593 | 594 | LiteralInInterpolation: 595 | Description: 'Checks for literals used in interpolation.' 596 | Enabled: true 597 | 598 | Loop: 599 | Description: >- 600 | Use Kernel#loop with break rather than begin/end/until or 601 | begin/end/while for post-loop tests. 602 | Enabled: true 603 | 604 | ParenthesesAsGroupedExpression: 605 | Description: >- 606 | Checks for method calls with a space before the opening 607 | parenthesis. 608 | Enabled: true 609 | 610 | RequireParentheses: 611 | Description: >- 612 | Use parentheses in the method call to avoid confusion 613 | about precedence. 614 | Enabled: true 615 | 616 | RescueException: 617 | Description: 'Avoid rescuing the Exception class.' 618 | Enabled: true 619 | 620 | ShadowingOuterLocalVariable: 621 | Description: >- 622 | Do not use the same name as outer local variable 623 | for block arguments or block local variables. 624 | Enabled: true 625 | 626 | StringConversionInInterpolation: 627 | Description: 'Checks for Object#to_s usage in string interpolation.' 628 | Enabled: true 629 | 630 | UnreachableCode: 631 | Description: 'Unreachable code.' 632 | Enabled: true 633 | 634 | UselessAssignment: 635 | Description: 'Checks for useless assignment to a local variable.' 636 | Enabled: true 637 | 638 | UselessComparison: 639 | Description: 'Checks for comparison of something with itself.' 640 | Enabled: true 641 | 642 | UselessElseWithoutRescue: 643 | Description: 'Checks for useless `else` in `begin..end` without `rescue`.' 644 | Enabled: true 645 | 646 | UselessSetterCall: 647 | Description: 'Checks for useless setter call to a local variable.' 648 | Enabled: true 649 | 650 | Void: 651 | Description: 'Possible use of operator/literal/variable in void context.' 652 | Enabled: true 653 | --------------------------------------------------------------------------------