Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

Commit

Permalink
update to more modern conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
phlipper committed Dec 27, 2012
1 parent 2802d12 commit 27876c8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
36 changes: 18 additions & 18 deletions attributes/default.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
# Cookbook Name:: monit # Cookbook Name:: monit
# Attributes:: default # Attributes:: default
# #
# Copyright 2011, Phil Cohen # Author:: Phil Cohen <github@phlippers.net>
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Copyright 2011-2012, Phil Cohen
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# #


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

# 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" default["monit"]["logfile"] = "/var/log/monit.log"

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


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


# Email settings that will be used for notification of events.
default["monit"]["mail"] = { default["monit"]["mail"] = {
:hostname => "localhost", :hostname => "localhost",
:port => 25, :port => 25,
Expand All @@ -41,11 +41,11 @@
:timeout => 30 :timeout => 30
} }


case platform case node["platform"]
when "redhat","centos","fedora" when platform_family?("rhel"), platform_family?("fedora"), platform_family?("suse")
default["monit"]["main_config_path"] = "/etc/monit.conf" default["monit"]["main_config_path"] = "/etc/monit.conf"
default["monit"]["includes_dir"] = "/etc/monit.d" default["monit"]["includes_dir"] = "/etc/monit.d"
else else
default["monit"]["main_config_path"] = "/etc/monit/monitrc" default["monit"]["main_config_path"] = "/etc/monit/monitrc"
default["monit"]["includes_dir"] = "/etc/monit/conf.d" default["monit"]["includes_dir"] = "/etc/monit/conf.d"
end end
23 changes: 15 additions & 8 deletions recipes/default.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,13 @@
#
# Cookbook Name:: monit
# Recipe:: default
#

package "monit" do package "monit" do
action :install action :install
end end


template "#{node["monit"]["main_config_path"]}" do template node["monit"]["main_config_path"] do
owner "root" owner "root"
group "root" group "root"
mode "0700" mode "0700"
Expand All @@ -17,14 +22,16 @@


service "monit" do service "monit" do
service_name "monit" service_name "monit"
case node['platform']
when "redhat","centos","scientific","fedora","suse","amazon" case node["platform"]
when platform_family?("rhel"), platform_family?("fedora"), platform_family?("suse")
start_command "/sbin/service monit start" start_command "/sbin/service monit start"
restart_command "/sbin/service monit restart" restart_command "/sbin/service monit restart"
when "debian","ubuntu" when platform_family?("debian")
start_command "/usr/sbin/invoke-rc.d monit start" start_command "/usr/sbin/invoke-rc.d monit start"
restart_command "/usr/sbin/invoke-rc.d monit restart" restart_command "/usr/sbin/invoke-rc.d monit restart"
end end

supports value_for_platform( supports value_for_platform(
"debian" => { "4.0" => [ :restart, :start ], "default" => [ :restart, :start ] }, "debian" => { "4.0" => [ :restart, :start ], "default" => [ :restart, :start ] },
"ubuntu" => { "default" => [ :restart, :start ] }, "ubuntu" => { "default" => [ :restart, :start ] },
Expand All @@ -36,17 +43,17 @@
action :enable action :enable
end end


case node['platform'] if platform_family?("debian")
when "debian", "ubuntu"
# enable startup # enable startup
execute "enable-monit-startup" do execute "enable-monit-startup" do
command "/bin/sed s/startup=0/startup=1/ -i /etc/default/monit" command "/bin/sed s/startup=0/startup=1/ -i /etc/default/monit"
not_if "grep 'startup=1' /etc/default/monit" not_if "grep 'startup=1' /etc/default/monit"
end end
else
end end


# build monitrc files # build monitrc files
%w[load ssh].each do |conf| %w[load ssh].each do |conf|
monitrc conf, :category => "system" monit_monitrc conf do
variables({ category: "system" })
end
end end

0 comments on commit 27876c8

Please sign in to comment.