deprec 2.0.15 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -1
- data/lib/deprec/capistrano_extensions.rb +1 -1
- data/lib/deprec/recipes/collectd.rb +60 -79
- data/lib/deprec/recipes/haproxy.rb +105 -0
- data/lib/deprec/recipes/nagios.rb +90 -72
- data/lib/deprec/recipes/postfix.rb +1 -1
- data/lib/deprec/recipes/ssh.rb +1 -1
- data/lib/deprec/recipes/syslog.rb +63 -0
- data/lib/deprec/recipes/utils.rb +1 -1
- data/lib/deprec/recipes_minus_rails.rb +2 -0
- data/lib/deprec/templates/collectd/collectd.conf.erb +686 -0
- data/lib/deprec/templates/nagios/{cgi.cfg → cgi.cfg.erb} +27 -2
- data/lib/deprec/templates/nagios/htpasswd.users +1 -0
- data/lib/deprec/templates/nagios/{nagios.cfg → nagios.cfg.erb} +35 -7
- data/lib/deprec/templates/nagios/nrpe.cfg.erb +15 -3
- data/lib/deprec/templates/nagios/nrpe.xinetd.erb +1 -1
- data/lib/deprec/templates/nagios/objects/{commands.cfg → commands.cfg.erb} +27 -2
- data/lib/deprec/templates/nagios/objects/{contacts.cfg → contacts.cfg.erb} +23 -0
- data/lib/deprec/templates/nagios/{hosts.cfg.erb → objects/hosts.cfg.erb} +30 -54
- data/lib/deprec/templates/{old → nagios/objects}/localhost.cfg.erb +0 -41
- data/lib/deprec/templates/nagios/{services.cfg.erb → objects/services.cfg.erb} +88 -2
- data/lib/deprec/templates/{old → nagios/objects}/timeperiods.cfg.erb +0 -0
- data/lib/deprec/templates/{old → nagios}/resource.cfg.erb +1 -1
- data/lib/deprec/templates/syslog/syslog.conf.erb +71 -0
- data/lib/deprec/templates/syslog/syslogd.erb +13 -0
- metadata +16 -22
- data/lib/deprec/templates/nagios/objects/localhost.cfg +0 -157
- data/lib/deprec/templates/nagios/objects/templates.cfg +0 -190
- data/lib/deprec/templates/nagios/objects/timeperiods.cfg +0 -94
- data/lib/deprec/templates/nagios/resource.cfg +0 -34
- data/lib/deprec/templates/nagios_config.tgz +0 -0
- data/lib/deprec/templates/old/apache_vhost.erb +0 -45
- data/lib/deprec/templates/old/cgi.cfg.erb +0 -321
- data/lib/deprec/templates/old/commands.cfg.erb +0 -240
- data/lib/deprec/templates/old/contacts.cfg.erb +0 -57
- data/lib/deprec/templates/old/htpasswd.users +0 -1
- data/lib/deprec/templates/old/templates.cfg.erb +0 -9
data/CHANGELOG
CHANGED
@@ -314,10 +314,10 @@ module Deprec2
|
|
314
314
|
|
315
315
|
# install package from source
|
316
316
|
def install_from_src(src_package, src_dir)
|
317
|
+
set_package_defaults(src_package)
|
317
318
|
package_dir = File.join(src_dir, src_package[:dir])
|
318
319
|
unpack_src(src_package, src_dir)
|
319
320
|
apt.install( {:base => %w(build-essential)}, :stable )
|
320
|
-
# XXX replace with invoke_command
|
321
321
|
sudo <<-SUDO
|
322
322
|
sh -c '
|
323
323
|
cd #{package_dir};
|
@@ -3,31 +3,18 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
3
3
|
namespace :deprec do
|
4
4
|
namespace :collectd do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# ./configure --prefix=/usr/local
|
12
|
-
# make
|
13
|
-
# sudo make install
|
6
|
+
set(:collectd_server) { Capistrano::CLI.ui.ask 'Enter Collectd server hostname' }
|
7
|
+
|
8
|
+
# XXX master only
|
9
|
+
# Update libdir for libcollectdclient.so.0
|
10
|
+
# collectd-nagios is not finding it in /usr/local/lib
|
14
11
|
#
|
15
|
-
#
|
16
|
-
# tar zxf ruby-rrd-1.1.tar.gz
|
17
|
-
# cd ruby-rrd-1.1
|
18
|
-
# ruby extconf.rb
|
19
|
-
# make
|
20
|
-
# make install
|
21
|
-
|
22
|
-
# Ruby bindings
|
23
|
-
# RRD.so
|
24
|
-
|
25
|
-
|
12
|
+
# Copy collection-php to /var/www/collectd
|
26
13
|
|
27
14
|
SRC_PACKAGES[:collectd] = {
|
28
|
-
:url => "http://collectd.org/files/collectd-4.7.
|
29
|
-
:md5sum => "
|
30
|
-
:configure => "./configure --prefix=/usr/local"
|
15
|
+
:url => "http://collectd.org/files/collectd-4.7.2.tar.gz",
|
16
|
+
:md5sum => "893c7a861b7a4a591188d9468622d89d collectd-4.7.2.tar.gz",
|
17
|
+
:configure => "./configure --prefix=/usr/local;"
|
31
18
|
}
|
32
19
|
|
33
20
|
desc "Install collectd"
|
@@ -37,76 +24,70 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
37
24
|
deprec2.install_from_src(SRC_PACKAGES[:collectd], src_dir)
|
38
25
|
end
|
39
26
|
|
40
|
-
# install dependencies for
|
27
|
+
# install dependencies for sysklogd
|
41
28
|
task :install_deps do
|
42
29
|
apt.install( {:base => %w(liboping-dev libperl-dev libdbi0-dev libesmtp-dev libganglia1-dev libmemcache-dev libnet1-dev libnotify-dev libopenipmi-dev liboping-dev libpcap-dev libperl-dev librrd2-dev libsensors-dev libstatgrab-dev nut-dev libvirt-dev)}, :stable )
|
43
30
|
apt.install( {:base => %w(rrdtool librrd2-dev librrds-perl libconfig-general-perl libhtml-parser-perl libregexp-common-perl)}, :stable )
|
44
31
|
end
|
45
32
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
33
|
+
SYSTEM_CONFIG_FILES[:collectd] = [
|
34
|
+
|
35
|
+
{:template => "collectd.conf.erb",
|
36
|
+
:path => '/usr/local/etc/collectd.conf',
|
37
|
+
:mode => 0640,
|
38
|
+
:owner => 'root:root'},
|
39
|
+
|
40
|
+
]
|
41
|
+
|
42
|
+
desc "Generate Collectd configs"
|
43
|
+
task :config_gen do
|
44
|
+
SYSTEM_CONFIG_FILES[:collectd].each do |file|
|
45
|
+
deprec2.render_template(:collectd, file)
|
46
|
+
end
|
59
47
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
48
|
+
|
49
|
+
desc "Push Chef config files (system & project level) to server"
|
50
|
+
task :config, :roles => :all_hosts, :except => {:collectd_master => true} do
|
51
|
+
deprec2.push_configs(:collectd, SYSTEM_CONFIG_FILES[:collectd])
|
52
|
+
restart
|
65
53
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
}
|
54
|
+
|
55
|
+
desc "Start collectd"
|
56
|
+
task :start, :roles => :all_hosts, :except => { :collectd_master => true } do
|
57
|
+
run "#{sudo} collectd"
|
71
58
|
end
|
72
59
|
|
73
|
-
desc "
|
74
|
-
task :
|
75
|
-
|
76
|
-
|
77
|
-
# Push to remote git repo
|
78
|
-
hostname = capture "echo $CAPISTRANO:HOST$"
|
79
|
-
system "git remote add origin git@#{hostname.chomp}:#{application}"
|
80
|
-
system "git push origin master:refs/heads/master"
|
81
|
-
|
82
|
-
puts
|
83
|
-
puts "New remote Git repo: #{git_user}@#{hostname.chomp}:#{application}"
|
84
|
-
puts
|
85
|
-
|
86
|
-
# File.open('.git/config', 'w') do |c|
|
87
|
-
# c.write 'Add the following to .git/config'
|
88
|
-
# c.write '[branch "master"]'
|
89
|
-
# c.write ' remote = origin'
|
90
|
-
# c.write ' merge = refs/heads/master'
|
91
|
-
# end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
# Create root dir for git repositories
|
96
|
-
task :create_git_root do
|
97
|
-
deprec2.mkdir(git_root, :mode => 02775, :owner => git_user, :group => git_group, :via => :sudo)
|
98
|
-
sudo "chmod -R g+w #{git_root}"
|
60
|
+
desc "Stop collectd"
|
61
|
+
task :stop, :roles => :all_hosts, :except => { :collectd_master => true } do
|
62
|
+
run "#{sudo} killall collectd; exit 0;"
|
99
63
|
end
|
100
64
|
|
101
|
-
|
102
|
-
task :
|
103
|
-
|
104
|
-
|
105
|
-
sudo "chown #{git_user}.#{git_group} #{git_keys_file}"
|
106
|
-
sudo "chmod 0600 #{git_keys_file}"
|
65
|
+
desc "Restart collectd"
|
66
|
+
task :restart, :roles => :all_hosts, :except => { :collectd_master => true } do
|
67
|
+
stop
|
68
|
+
start
|
107
69
|
end
|
108
70
|
|
109
|
-
|
110
71
|
end
|
72
|
+
|
111
73
|
end
|
112
74
|
end
|
75
|
+
|
76
|
+
# latest rrdtool
|
77
|
+
# apt-get install intltool
|
78
|
+
# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz
|
79
|
+
# tar zxf rrdtool.tar.gz
|
80
|
+
# cd rrdtool
|
81
|
+
# ./configure --prefix=/usr/local
|
82
|
+
# make
|
83
|
+
# sudo make install
|
84
|
+
#
|
85
|
+
# wget http://oss.oetiker.ch/rrdtool/pub/contrib/ruby-rrd-1.1.tar.gz
|
86
|
+
# tar zxf ruby-rrd-1.1.tar.gz
|
87
|
+
# cd ruby-rrd-1.1
|
88
|
+
# ruby extconf.rb
|
89
|
+
# make
|
90
|
+
# make install
|
91
|
+
|
92
|
+
# Ruby bindings
|
93
|
+
# RRD.so
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# # Copyright 2006-2009 by Mike Bailey. All rights reserved.
|
2
|
+
# Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
# namespace :deprec do
|
4
|
+
# namespace :haproxy do
|
5
|
+
#
|
6
|
+
# SRC_PACKAGES[:haproxy] = {
|
7
|
+
# :md5sum => "e37046e0cb2f407d92c41d7731d1dd10 haproxy-1.3.20.tar.gz",
|
8
|
+
# :url => "http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz"
|
9
|
+
# }
|
10
|
+
#
|
11
|
+
# desc "Install haproxy"
|
12
|
+
# task :install do
|
13
|
+
# install_deps
|
14
|
+
# deprec2.download_src(SRC_PACKAGES[:haproxy], src_dir)
|
15
|
+
# deprec2.install_from_src(SRC_PACKAGES[:haproxy], src_dir)
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# task :install_deps do
|
19
|
+
# apt.install( {:base => %w(build-essential)}, :stable )
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# SYSTEM_CONFIG_FILES[:haproxy] = [
|
23
|
+
#
|
24
|
+
# # {:template => "example.conf.erb",
|
25
|
+
# # :path => '/etc/example/example.conf',
|
26
|
+
# # :mode => 0755,
|
27
|
+
# # :owner => 'root:root'}
|
28
|
+
#
|
29
|
+
# ]
|
30
|
+
#
|
31
|
+
# PROJECT_CONFIG_FILES[:haproxy] = [
|
32
|
+
#
|
33
|
+
# # {:template => "example.conf.erb",
|
34
|
+
# # :path => 'conf/example.conf',
|
35
|
+
# # :mode => 0755,
|
36
|
+
# # :owner => 'root:root'}
|
37
|
+
# ]
|
38
|
+
#
|
39
|
+
#
|
40
|
+
# desc "Generate configuration file(s) for XXX from template(s)"
|
41
|
+
# task :config_gen do
|
42
|
+
# config_gen_system
|
43
|
+
# config_gen_project
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# task :config_gen_system do
|
47
|
+
# SYSTEM_CONFIG_FILES[:haproxy].each do |file|
|
48
|
+
# deprec2.render_template(:haproxy, file)
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# task :config_gen_project do
|
53
|
+
# PROJECT_CONFIG_FILES[:haproxy].each do |file|
|
54
|
+
# deprec2.render_template(:haproxy, file)
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# desc 'Deploy configuration files(s) for XXX'
|
59
|
+
# task :config, :roles => :web do
|
60
|
+
# config_system
|
61
|
+
# config_project
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# task :config_system, :roles => :web do
|
65
|
+
# deprec2.push_configs(:haproxy, SYSTEM_CONFIG_FILES[:haproxy])
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# task :config_project, :roles => :web do
|
69
|
+
# deprec2.push_configs(:haproxy, PROJECT_CONFIG_FILES[:haproxy])
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
#
|
73
|
+
# task :start, :roles => :web do
|
74
|
+
# run "#{sudo} /etc/init.d/haproxy start"
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# task :stop, :roles => :web do
|
78
|
+
# run "#{sudo} /etc/init.d/haproxy stop"
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# task :restart, :roles => :web do
|
82
|
+
# run "#{sudo} /etc/init.d/haproxy restart"
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# task :reload, :roles => :web do
|
86
|
+
# run "#{sudo} /etc/init.d/haproxy reload"
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# task :activate, :roles => :web do
|
90
|
+
# run "#{sudo} update-rc.d haproxy defaults"
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# task :deactivate, :roles => :web do
|
94
|
+
# run "#{sudo} update-rc.d -f haproxy remove"
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# task :backup, :roles => :web do
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# task :restore, :roles => :web do
|
101
|
+
# end
|
102
|
+
#
|
103
|
+
# end
|
104
|
+
# end
|
105
|
+
# end
|
@@ -6,47 +6,50 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
6
6
|
set :nagios_user, 'nagios'
|
7
7
|
set :nagios_group, 'nagios'
|
8
8
|
set(:nagios_host) { Capistrano::CLI.ui.ask "Enter hostname of nagios server" }
|
9
|
+
set(:nagios_ip) { Capistrano::CLI.ui.ask "Enter ip address of nagios server" }
|
9
10
|
set(:nagios_admin_pass) { Capistrano::CLI.ui.ask "Enter password for nagiosadmin user" }
|
10
11
|
set :nagios_cmd_group, 'nagcmd' # Submit external commands through the web interface
|
11
12
|
set :nagios_htpasswd_file, '/usr/local/nagios/etc/htpasswd.users'
|
12
13
|
# default :application, 'nagios'
|
13
14
|
|
14
15
|
SRC_PACKAGES[:nagios] = {
|
15
|
-
:url => "http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.0.
|
16
|
-
:md5sum => "
|
17
|
-
:configure =>
|
18
|
-
./configure
|
19
|
-
--with-command-group=nagcmd
|
20
|
-
;
|
21
|
-
).reject{|arg| arg.match '#'}.join(' '),
|
16
|
+
:url => "http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz",
|
17
|
+
:md5sum => "3566167cc60ddeaad34e7d2e26ed4a58 nagios-3.2.0.tar.gz",
|
18
|
+
:configure => "./configure --with-command-group=nagcmd;",
|
22
19
|
:make => 'make all;',
|
23
|
-
:install => 'make
|
20
|
+
:install => 'make install install-init install-commandmode install-webconf;'
|
24
21
|
}
|
25
22
|
|
26
|
-
|
23
|
+
desc "Install and configure Nagios server"
|
24
|
+
task :setup_server, :roles => :nagios do
|
27
25
|
install
|
26
|
+
top.deprec.nagios_plugins.install
|
27
|
+
top.deprec.nrpe.install
|
28
28
|
config_gen
|
29
|
-
htpass
|
30
29
|
config
|
31
30
|
end
|
32
31
|
|
32
|
+
desc "Setup client"
|
33
|
+
task :setup_client do
|
34
|
+
top.deprec.nagios_plugins.install
|
35
|
+
top.deprec.nrpe.install
|
36
|
+
top.deprec.nrpe.config
|
37
|
+
end
|
38
|
+
|
33
39
|
desc "Install nagios"
|
34
|
-
task :install do
|
40
|
+
task :install, :roles => :nagios do
|
35
41
|
install_deps
|
36
42
|
create_nagios_user
|
37
|
-
# deprec2.mkdir('/usr/local/nagios/etc', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
|
38
|
-
# deprec2.mkdir('/usr/local/nagios/objects', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
|
39
43
|
deprec2.download_src(SRC_PACKAGES[:nagios], src_dir)
|
40
44
|
deprec2.install_from_src(SRC_PACKAGES[:nagios], src_dir)
|
41
|
-
activate
|
42
45
|
end
|
43
46
|
|
44
47
|
# Install dependencies for nagios
|
45
|
-
task :install_deps do
|
46
|
-
apt.install( {:base => %w(mailx)}, :stable )
|
48
|
+
task :install_deps, :roles => :nagios do
|
49
|
+
apt.install( {:base => %w(apache2 mailx postfix libapache2-mod-php5 libgd2-xpm-dev)}, :stable )
|
47
50
|
end
|
48
51
|
|
49
|
-
task :create_nagios_user do
|
52
|
+
task :create_nagios_user, :roles => :nagios do
|
50
53
|
deprec2.groupadd(nagios_group)
|
51
54
|
deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
|
52
55
|
# deprec2.add_user_to_group(nagios_user, apache_user)
|
@@ -76,6 +79,16 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
76
79
|
|
77
80
|
SYSTEM_CONFIG_FILES[:nagios] = [
|
78
81
|
|
82
|
+
{:template => 'cgi.cfg.erb',
|
83
|
+
:path => '/usr/local/nagios/etc/cgi.cfg',
|
84
|
+
:mode => 0664,
|
85
|
+
:owner => 'nagios:nagios'},
|
86
|
+
|
87
|
+
{:template => 'htpasswd.users',
|
88
|
+
:path => '/usr/local/nagios/etc/htpasswd.users',
|
89
|
+
:mode => 0660,
|
90
|
+
:owner => 'nagios:www-data'},
|
91
|
+
|
79
92
|
{:template => 'nagios.cfg.erb',
|
80
93
|
:path => '/usr/local/nagios/etc/nagios.cfg',
|
81
94
|
:mode => 0664,
|
@@ -86,50 +99,35 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
86
99
|
:mode => 0660,
|
87
100
|
:owner => 'nagios:nagios'},
|
88
101
|
|
89
|
-
{:template => '
|
90
|
-
:path => '/usr/local/nagios/etc/
|
102
|
+
{:template => 'objects/commands.cfg.erb',
|
103
|
+
:path => '/usr/local/nagios/etc/objects/commands.cfg',
|
91
104
|
:mode => 0664,
|
92
105
|
:owner => 'nagios:nagios'},
|
93
106
|
|
94
|
-
{:template => '
|
95
|
-
:path => '/usr/local/nagios/etc/
|
96
|
-
:mode =>
|
107
|
+
{:template => 'objects/contacts.cfg.erb',
|
108
|
+
:path => '/usr/local/nagios/etc/objects/contacts.cfg',
|
109
|
+
:mode => 0664,
|
97
110
|
:owner => 'nagios:nagios'},
|
98
111
|
|
99
|
-
{:template => 'objects/
|
100
|
-
:path => '/usr/local/nagios/etc/objects/
|
112
|
+
{:template => 'objects/hosts.cfg.erb',
|
113
|
+
:path => '/usr/local/nagios/etc/objects/hosts.cfg',
|
101
114
|
:mode => 0664,
|
102
|
-
:owner => 'nagios:nagios'}
|
115
|
+
:owner => 'nagios:nagios'},
|
116
|
+
|
117
|
+
{:template => 'objects/localhost.cfg.erb',
|
118
|
+
:path => '/usr/local/nagios/etc/objects/localhost.cfg',
|
119
|
+
:mode => 0664,
|
120
|
+
:owner => 'nagios:nagios'},
|
121
|
+
|
122
|
+
{:template => 'objects/services.cfg.erb',
|
123
|
+
:path => '/usr/local/nagios/etc/objects/services.cfg',
|
124
|
+
:mode => 0664,
|
125
|
+
:owner => 'nagios:nagios'},
|
103
126
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
#
|
109
|
-
# {:template => 'localhost.cfg.erb',
|
110
|
-
# :path => '/usr/local/nagios/etc/objects/localhost.cfg',
|
111
|
-
# :mode => 0664,
|
112
|
-
# :owner => 'nagios:nagios'},
|
113
|
-
#
|
114
|
-
# {:template => 'hosts.cfg.erb',
|
115
|
-
# :path => '/usr/local/nagios/etc/objects/hosts.cfg',
|
116
|
-
# :mode => 0664,
|
117
|
-
# :owner => 'nagios:nagios'},
|
118
|
-
#
|
119
|
-
# {:template => 'services.cfg.erb',
|
120
|
-
# :path => '/usr/local/nagios/etc/objects/services.cfg',
|
121
|
-
# :mode => 0664,
|
122
|
-
# :owner => 'nagios:nagios'},
|
123
|
-
#
|
124
|
-
# {:template => 'templates.cfg.erb',
|
125
|
-
# :path => '/usr/local/nagios/etc/objects/templates.cfg',
|
126
|
-
# :mode => 0664,
|
127
|
-
# :owner => 'nagios:nagios'},
|
128
|
-
#
|
129
|
-
# {:template => 'timeperiods.cfg.erb',
|
130
|
-
# :path => '/usr/local/nagios/etc/objects/timeperiods.cfg',
|
131
|
-
# :mode => 0664,
|
132
|
-
# :owner => 'nagios:nagios'}
|
127
|
+
{:template => 'objects/timeperiods.cfg.erb',
|
128
|
+
:path => '/usr/local/nagios/etc/objects/timeperiods.cfg',
|
129
|
+
:mode => 0664,
|
130
|
+
:owner => 'nagios:nagios'}
|
133
131
|
|
134
132
|
]
|
135
133
|
|
@@ -153,19 +151,19 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
153
151
|
send(run_method, "/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg")
|
154
152
|
end
|
155
153
|
|
156
|
-
desc "Set Nagios to start on boot"
|
157
|
-
task :activate, :roles => :nagios do
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
desc "Set Nagios to not start on boot"
|
164
|
-
task :deactivate, :roles => :nagios do
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
end
|
154
|
+
# desc "Set Nagios to start on boot"
|
155
|
+
# task :activate, :roles => :nagios do
|
156
|
+
# send(run_method, "update-rc.d nagios defaults")
|
157
|
+
# sudo "a2ensite nagios"
|
158
|
+
# top.deprec.apache.reload
|
159
|
+
# end
|
160
|
+
#
|
161
|
+
# desc "Set Nagios to not start on boot"
|
162
|
+
# task :deactivate, :roles => :nagios do
|
163
|
+
# send(run_method, "update-rc.d -f nagios remove")
|
164
|
+
# sudo "a2dissite nagios"
|
165
|
+
# top.deprec.apache.reload
|
166
|
+
# end
|
169
167
|
|
170
168
|
# Control
|
171
169
|
|
@@ -200,8 +198,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
200
198
|
end
|
201
199
|
|
202
200
|
SRC_PACKAGES[:nagios_plugins] = {
|
203
|
-
:url => "http://
|
204
|
-
:md5sum => "
|
201
|
+
:url => "http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz",
|
202
|
+
:md5sum => "be6cc7699fff3ee29d1fd4d562377386 nagios-plugins-1.4.13.tar.gz",
|
205
203
|
:configure => "./configure --with-nagios-user=#{nagios_user} --with-nagios-group=#{nagios_group};",
|
206
204
|
}
|
207
205
|
|
@@ -210,7 +208,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
210
208
|
desc "Install nagios plugins"
|
211
209
|
task :install do
|
212
210
|
install_deps
|
213
|
-
|
211
|
+
create_nagios_user
|
214
212
|
deprec2.download_src(SRC_PACKAGES[:nagios_plugins], src_dir)
|
215
213
|
deprec2.install_from_src(SRC_PACKAGES[:nagios_plugins], src_dir)
|
216
214
|
end
|
@@ -220,6 +218,15 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
220
218
|
apt.install( {:base => %w(libmysqlclient15-dev)}, :stable )
|
221
219
|
end
|
222
220
|
|
221
|
+
task :create_nagios_user do
|
222
|
+
deprec2.groupadd(nagios_group)
|
223
|
+
deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
|
224
|
+
# deprec2.add_user_to_group(nagios_user, apache_user)
|
225
|
+
deprec2.groupadd(nagios_cmd_group)
|
226
|
+
deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
|
227
|
+
deprec2.add_user_to_group(apache_user, nagios_cmd_group)
|
228
|
+
end
|
229
|
+
|
223
230
|
|
224
231
|
end
|
225
232
|
|
@@ -240,7 +247,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
240
247
|
desc 'Install NRPE'
|
241
248
|
task :install do
|
242
249
|
install_deps
|
243
|
-
|
250
|
+
create_nagios_user
|
244
251
|
deprec2.download_src(SRC_PACKAGES[:nrpe], src_dir)
|
245
252
|
deprec2.install_from_src(SRC_PACKAGES[:nrpe], src_dir)
|
246
253
|
# XXX this should only be run on the nrpe clients
|
@@ -253,6 +260,15 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
253
260
|
apt.install( {:base => %w(xinetd libssl-dev openssl)}, :stable )
|
254
261
|
end
|
255
262
|
|
263
|
+
task :create_nagios_user do
|
264
|
+
deprec2.groupadd(nagios_group)
|
265
|
+
deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
|
266
|
+
# deprec2.add_user_to_group(nagios_user, apache_user)
|
267
|
+
deprec2.groupadd(nagios_cmd_group)
|
268
|
+
deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
|
269
|
+
deprec2.add_user_to_group(apache_user, nagios_cmd_group)
|
270
|
+
end
|
271
|
+
|
256
272
|
SYSTEM_CONFIG_FILES[:nrpe] = [
|
257
273
|
|
258
274
|
{:template => 'nrpe.xinetd.erb',
|
@@ -293,10 +309,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
293
309
|
sudo "/etc/init.d/xinetd start"
|
294
310
|
end
|
295
311
|
|
312
|
+
desc "Test whether NRPE is listening on client"
|
296
313
|
task :test_local do
|
297
314
|
run "/usr/local/nagios/libexec/check_nrpe -H localhost"
|
298
315
|
end
|
299
316
|
|
317
|
+
desc "Test whether nagios server can query client via NRPE"
|
300
318
|
task :test_remote, :roles => :nagios do
|
301
319
|
target_host = Capistrano::CLI.ui.ask "target hostname"
|
302
320
|
run "/usr/local/nagios/libexec/check_nrpe -H #{target_host}"
|
@@ -304,7 +322,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
304
322
|
|
305
323
|
end
|
306
324
|
|
307
|
-
#
|
325
|
+
# PNP4nagios
|
308
326
|
# http://downloads.sourceforge.net/sourceforge/pnp4nagios/pnp-0.4.14.tar.gz?use_mirror=internode
|
309
327
|
|
310
328
|
|