le1t0-deprec 2.1.6.001
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +444 -0
- data/COPYING +19 -0
- data/LICENSE +339 -0
- data/README +154 -0
- data/THANKS +17 -0
- data/bin/depify +139 -0
- data/docs/EXAMPLE-installing_tracks.txt +41 -0
- data/docs/README.nagios +22 -0
- data/docs/README.rails +17 -0
- data/docs/config_gen_explained.txt +39 -0
- data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
- data/docs/deprec-1.x/notes.txt +12 -0
- data/docs/old/deprec_banner.gif +0 -0
- data/docs/windows_linux.txt +350 -0
- data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
- data/docs/xen/xen-tools-notes.txt +31 -0
- data/docs/xen/xen_on_hardy.txt +39 -0
- data/lib/deprec.rb +42 -0
- data/lib/deprec/capistrano_extensions.rb +446 -0
- data/lib/deprec/recipes.rb +7 -0
- data/lib/deprec/recipes/aoe.rb +79 -0
- data/lib/deprec/recipes/app/mongrel.rb +213 -0
- data/lib/deprec/recipes/app/passenger.rb +190 -0
- data/lib/deprec/recipes/ar_sendmail.rb +67 -0
- data/lib/deprec/recipes/aspell.rb +22 -0
- data/lib/deprec/recipes/canonical.rb +68 -0
- data/lib/deprec/recipes/cap.rb +39 -0
- data/lib/deprec/recipes/chef.rb +68 -0
- data/lib/deprec/recipes/collectd.rb +112 -0
- data/lib/deprec/recipes/db/couchdb.rb +107 -0
- data/lib/deprec/recipes/db/mysql.rb +194 -0
- data/lib/deprec/recipes/db/postgresql.rb +104 -0
- data/lib/deprec/recipes/db/sqlite.rb +37 -0
- data/lib/deprec/recipes/ddclient.rb +51 -0
- data/lib/deprec/recipes/deprec.rb +167 -0
- data/lib/deprec/recipes/deprecated.rb +71 -0
- data/lib/deprec/recipes/drbd.rb +137 -0
- data/lib/deprec/recipes/dummy.rb +22 -0
- data/lib/deprec/recipes/example.rb +115 -0
- data/lib/deprec/recipes/git.rb +97 -0
- data/lib/deprec/recipes/gitosis.rb.disabled +55 -0
- data/lib/deprec/recipes/glusterfs.rb +176 -0
- data/lib/deprec/recipes/god.rb +70 -0
- data/lib/deprec/recipes/haproxy.rb +115 -0
- data/lib/deprec/recipes/heartbeat.rb +138 -0
- data/lib/deprec/recipes/imagemagick/imagemagick_bin.rb +24 -0
- data/lib/deprec/recipes/imagemagick/imagemagick_src.rb +39 -0
- data/lib/deprec/recipes/integrity.rb +108 -0
- data/lib/deprec/recipes/iptables.rb +94 -0
- data/lib/deprec/recipes/java.rb +23 -0
- data/lib/deprec/recipes/keepalived.rb +78 -0
- data/lib/deprec/recipes/ldap.rb +52 -0
- data/lib/deprec/recipes/logrotate.rb +56 -0
- data/lib/deprec/recipes/lvm.rb +20 -0
- data/lib/deprec/recipes/memcache.rb +49 -0
- data/lib/deprec/recipes/mongodb.rb +94 -0
- data/lib/deprec/recipes/monit.rb +135 -0
- data/lib/deprec/recipes/mysql_proxy.rb +67 -0
- data/lib/deprec/recipes/nagios.rb +361 -0
- data/lib/deprec/recipes/network.rb +116 -0
- data/lib/deprec/recipes/ntp.rb +103 -0
- data/lib/deprec/recipes/php.rb +58 -0
- data/lib/deprec/recipes/postfix.rb +115 -0
- data/lib/deprec/recipes/profiles.rb +125 -0
- data/lib/deprec/recipes/raid/amcc_3ware.rb +21 -0
- data/lib/deprec/recipes/rails.rb +330 -0
- data/lib/deprec/recipes/redhat_cluster.rb +228 -0
- data/lib/deprec/recipes/redis.rb +90 -0
- data/lib/deprec/recipes/ruby/mri.rb +55 -0
- data/lib/deprec/recipes/ruby/ree.rb +40 -0
- data/lib/deprec/recipes/rvm.rb +32 -0
- data/lib/deprec/recipes/s3utils.rb +63 -0
- data/lib/deprec/recipes/sphinx/thinking_sphinx.rb +105 -0
- data/lib/deprec/recipes/sphinx/ultrasphinx.rb +86 -0
- data/lib/deprec/recipes/ssh.rb +147 -0
- data/lib/deprec/recipes/ssl.rb +56 -0
- data/lib/deprec/recipes/starling.rb +119 -0
- data/lib/deprec/recipes/svn.rb +171 -0
- data/lib/deprec/recipes/syslog.rb +63 -0
- data/lib/deprec/recipes/trac.rb.disabled +277 -0
- data/lib/deprec/recipes/tsung.rb +74 -0
- data/lib/deprec/recipes/ubuntu.rb +90 -0
- data/lib/deprec/recipes/users.rb +90 -0
- data/lib/deprec/recipes/utils.rb +58 -0
- data/lib/deprec/recipes/vnstat.rb +85 -0
- data/lib/deprec/recipes/web/apache.rb +143 -0
- data/lib/deprec/recipes/web/nginx.rb +172 -0
- data/lib/deprec/recipes/wordpress.rb.notworking +96 -0
- data/lib/deprec/recipes/wpmu.rb +103 -0
- data/lib/deprec/recipes/xen.rb +364 -0
- data/lib/deprec/recipes/xentools.rb +101 -0
- data/lib/deprec/recipes_minus_rails.rb +125 -0
- data/lib/deprec/templates/aoe/aoe-init +55 -0
- data/lib/deprec/templates/aoe/fence_aoemask +351 -0
- data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
- data/lib/deprec/templates/apache/ports.conf.erb +5 -0
- data/lib/deprec/templates/apache/status.conf.erb +17 -0
- data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
- data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
- data/lib/deprec/templates/chef/chef.json.erb +1 -0
- data/lib/deprec/templates/chef/solo.rb +2 -0
- data/lib/deprec/templates/collectd/collectd-init.d +153 -0
- data/lib/deprec/templates/collectd/collectd.conf.erb +686 -0
- data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
- data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
- data/lib/deprec/templates/deprec/caprc.erb +14 -0
- data/lib/deprec/templates/drbd/drbd.conf.erb +531 -0
- data/lib/deprec/templates/glusterfs/glusterfsd-init.erb +95 -0
- data/lib/deprec/templates/gnbd_client/cluster.conf.erb +21 -0
- data/lib/deprec/templates/gnbd_client/clvm-default.erb +3 -0
- data/lib/deprec/templates/gnbd_client/cman-default.erb +6 -0
- data/lib/deprec/templates/gnbd_client/gnbdimports.conf.erb +1 -0
- data/lib/deprec/templates/gnbd_server/cluster.conf.erb +20 -0
- data/lib/deprec/templates/gnbd_server/clvm-default.erb +3 -0
- data/lib/deprec/templates/gnbd_server/cman-default.erb +6 -0
- data/lib/deprec/templates/gnbd_server/gnbd-server-default.erb +1 -0
- data/lib/deprec/templates/gnbd_server/gnbdexports.conf.erb +1 -0
- data/lib/deprec/templates/god/god-conf.erb +2 -0
- data/lib/deprec/templates/god/god-init.erb +47 -0
- data/lib/deprec/templates/haproxy/haproxy-init.d +120 -0
- data/lib/deprec/templates/haproxy/haproxy.cfg.erb +31 -0
- data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
- data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
- data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
- data/lib/deprec/templates/integrity/apache_vhost.erb +4 -0
- data/lib/deprec/templates/integrity/config.ru.erb +21 -0
- data/lib/deprec/templates/integrity/config.yml.erb +43 -0
- data/lib/deprec/templates/iptables/firewall-default.erb +13 -0
- data/lib/deprec/templates/iptables/firewall-init.erb +171 -0
- data/lib/deprec/templates/keepalived/keepalived.conf.erb +18 -0
- data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
- data/lib/deprec/templates/mongodb/mongodb-init.d +88 -0
- data/lib/deprec/templates/mongrel/apache_vhost.conf.erb +148 -0
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
- data/lib/deprec/templates/mongrel/nginx_vhost.conf.erb +41 -0
- data/lib/deprec/templates/monit/monit-init-script +104 -0
- data/lib/deprec/templates/monit/monitrc.erb +250 -0
- data/lib/deprec/templates/monit/nothing.monitrc +0 -0
- data/lib/deprec/templates/mysql/create_databases.sql +20 -0
- data/lib/deprec/templates/mysql/database.yml.prod +6 -0
- data/lib/deprec/templates/mysql/database.yml.stage +6 -0
- data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
- data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
- data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
- data/lib/deprec/templates/mysql_proxy/mysql-proxy-default.erb +4 -0
- data/lib/deprec/templates/nagios/README +32 -0
- data/lib/deprec/templates/nagios/cgi.cfg.erb +357 -0
- data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
- data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
- data/lib/deprec/templates/nagios/htpasswd.users +1 -0
- data/lib/deprec/templates/nagios/mrtg.cfg +180 -0
- data/lib/deprec/templates/nagios/nagios.cfg.erb +1325 -0
- data/lib/deprec/templates/nagios/nrpe.cfg.erb +222 -0
- data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
- data/lib/deprec/templates/nagios/objects/commands.cfg.erb +265 -0
- data/lib/deprec/templates/nagios/objects/contacts.cfg.erb +89 -0
- data/lib/deprec/templates/nagios/objects/hosts.cfg.erb +114 -0
- data/lib/deprec/templates/nagios/objects/localhost.cfg.erb +116 -0
- data/lib/deprec/templates/nagios/objects/services.cfg.erb +165 -0
- data/lib/deprec/templates/nagios/objects/timeperiods.cfg.erb +94 -0
- data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
- data/lib/deprec/templates/network/hostname.erb +1 -0
- data/lib/deprec/templates/network/hosts.erb +2 -0
- data/lib/deprec/templates/network/interfaces.erb +18 -0
- data/lib/deprec/templates/network/resolv.conf.erb +6 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
- data/lib/deprec/templates/nginx/mime.types.erb +70 -0
- data/lib/deprec/templates/nginx/nginx-init-script +62 -0
- data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
- data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
- data/lib/deprec/templates/nginx/nothing.conf +1 -0
- data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
- data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
- data/lib/deprec/templates/passenger/apache_vhost.erb +29 -0
- data/lib/deprec/templates/passenger/logrotate.conf.erb +12 -0
- data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
- data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
- data/lib/deprec/templates/postfix/aliases.erb +3 -0
- data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
- data/lib/deprec/templates/postfix/main.cf.erb +36 -0
- data/lib/deprec/templates/postfix/master.cf.erb +77 -0
- data/lib/deprec/templates/redis/redis-conf.erb +132 -0
- data/lib/deprec/templates/redis/redis-init.erb +50 -0
- data/lib/deprec/templates/s3utils/s3cfg +35 -0
- data/lib/deprec/templates/s3utils/s3config.yml +3 -0
- data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
- data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
- data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
- data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
- data/lib/deprec/templates/starling/monit.conf.erb +14 -0
- data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
- data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
- data/lib/deprec/templates/syslog/syslog.conf.erb +71 -0
- data/lib/deprec/templates/syslog/syslogd.erb +13 -0
- data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
- data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
- data/lib/deprec/templates/trac/trac.ini.erb +169 -0
- data/lib/deprec/templates/trac/trac_deprec.png +0 -0
- data/lib/deprec/templates/trac/tracd-init.erb +43 -0
- data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
- data/lib/deprec/templates/tsung/tsung.xml.erb +47 -0
- data/lib/deprec/templates/vnstat/config.php +57 -0
- data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
- data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
- data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
- data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
- data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
- data/lib/deprec/templates/xen/xend-init.erb +57 -0
- data/lib/deprec/templates/xen/xendomains.erb +137 -0
- data/lib/deprec/templates/xentools/100-ubuntu-setup +26 -0
- data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
- data/lib/deprec/templates/xentools/30-disable-gettys +57 -0
- data/lib/deprec/templates/xentools/31-ubuntu-setup +32 -0
- data/lib/deprec/templates/xentools/40-setup-networking +145 -0
- data/lib/deprec/templates/xentools/98-custom +17 -0
- data/lib/deprec/templates/xentools/xen-tools.conf.erb +278 -0
- data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
- data/lib/deprec_cmd_completion.sh +26 -0
- data/lib/deprec_minus_rails.rb +12 -0
- data/lib/vmbuilder_plugins/all.rb +20 -0
- data/lib/vmbuilder_plugins/apt.rb +93 -0
- data/lib/vmbuilder_plugins/emerge.rb +76 -0
- data/lib/vmbuilder_plugins/gem.rb +100 -0
- data/lib/vmbuilder_plugins/std.rb +203 -0
- metadata +304 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
|
4
|
+
#
|
5
|
+
# mongrel_cluster Startup script for Mongrel clusters.
|
6
|
+
#
|
7
|
+
# chkconfig: - 85 15
|
8
|
+
# description: mongrel_cluster manages multiple Mongrel processes for use \
|
9
|
+
# behind a load balancer.
|
10
|
+
#
|
11
|
+
|
12
|
+
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin
|
13
|
+
CONF_DIR=/etc/mongrel_cluster
|
14
|
+
PID_DIR=/var/run/mongrel_cluster
|
15
|
+
# USER=mongrel
|
16
|
+
|
17
|
+
EVENT=1
|
18
|
+
|
19
|
+
RETVAL=0
|
20
|
+
|
21
|
+
# Gracefully exit if the controller is missing.
|
22
|
+
which mongrel_cluster_ctl >/dev/null || exit 0
|
23
|
+
|
24
|
+
# Go no further if config directory is missing.
|
25
|
+
[ -d "$CONF_DIR" ] || exit 0
|
26
|
+
|
27
|
+
case "$1" in
|
28
|
+
start)
|
29
|
+
# Create pid directory
|
30
|
+
mkdir -p $PID_DIR
|
31
|
+
# chown $USER:$USER $PID_DIR
|
32
|
+
|
33
|
+
mongrel_cluster_ctl start --clean -c $CONF_DIR
|
34
|
+
RETVAL=$?
|
35
|
+
;;
|
36
|
+
stop)
|
37
|
+
mongrel_cluster_ctl stop -c $CONF_DIR
|
38
|
+
RETVAL=$?
|
39
|
+
;;
|
40
|
+
restart)
|
41
|
+
mongrel_cluster_ctl restart --clean -c $CONF_DIR
|
42
|
+
RETVAL=$?
|
43
|
+
;;
|
44
|
+
status)
|
45
|
+
mongrel_cluster_ctl status -c $CONF_DIR
|
46
|
+
RETVAL=$?
|
47
|
+
;;
|
48
|
+
*)
|
49
|
+
echo "Usage: mongrel_cluster {start|stop|restart|status}"
|
50
|
+
exit 1
|
51
|
+
;;
|
52
|
+
esac
|
53
|
+
|
54
|
+
exit $RETVAL
|
@@ -0,0 +1,10 @@
|
|
1
|
+
---
|
2
|
+
user: <%= app_user %>
|
3
|
+
group: <%= app_group %>
|
4
|
+
cwd: <%= current_path %>
|
5
|
+
log_file: <%= mongrel_log_dir %>/mongrel.log
|
6
|
+
port: "<%= mongrel_port.to_s %>"
|
7
|
+
environment: <%= mongrel_environment %>
|
8
|
+
address: <%= mongrel_address %>
|
9
|
+
pid_file: <%= mongrel_pid_dir %>/mongrel.pid
|
10
|
+
servers: <%= mongrel_servers.to_s %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% mongrel_servers.times do |counter| -%>
|
2
|
+
check process mongrel-<%=mongrel_port+counter%> with pidfile <%= mongrel_pid_dir %>/mongrel.<%=mongrel_port+counter%>.pid
|
3
|
+
group mongrel_<%= application %>
|
4
|
+
start program = "/usr/local/bin/ruby /usr/local/bin/mongrel_rails cluster::start --clean -C <%= mongrel_conf %> --only <%=mongrel_port+counter%>"
|
5
|
+
stop program = "/usr/local/bin/ruby /usr/local/bin/mongrel_rails cluster::stop -C <%= mongrel_conf %> --only <%=mongrel_port+counter%>"
|
6
|
+
|
7
|
+
if failed host 127.0.0.1 port <%=mongrel_port+counter%> protocol http
|
8
|
+
with timeout 10 seconds
|
9
|
+
then alert
|
10
|
+
|
11
|
+
if totalmem > 100 Mb then restart
|
12
|
+
if cpu > 60% for 2 cycles then alert
|
13
|
+
if cpu > 80% for 5 cycles then restart
|
14
|
+
if loadavg(5min) > 10 for 8 cycles then restart
|
15
|
+
if 3 restarts within 5 cycles then timeout
|
16
|
+
|
17
|
+
<% end -%>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
upstream <%= application %> {
|
2
|
+
<% mongrel_servers.times do |counter| -%>
|
3
|
+
<%= "server 127.0.0.1:#{mongrel_port+counter};" %>
|
4
|
+
<% end -%>
|
5
|
+
}
|
6
|
+
|
7
|
+
server {
|
8
|
+
listen 80;
|
9
|
+
server_name <%= application %> <%= domain %> <% 4.times do |counter| %> <%= domain.sub(/.*?\./, "assets#{counter}.") %><% end %>;
|
10
|
+
root <%= deploy_to %>/current/public;
|
11
|
+
access_log <%= deploy_to %>/shared/log/<%= domain %>-access.log;
|
12
|
+
error_log <%= deploy_to %>/shared/log/<%= domain %>-error.log;
|
13
|
+
client_max_body_size <%= nginx_client_max_body_size %>;
|
14
|
+
|
15
|
+
if (-f $document_root/system/maintenance.html){
|
16
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
17
|
+
break;
|
18
|
+
}
|
19
|
+
location / {
|
20
|
+
proxy_set_header X-Real-IP $remote_addr;
|
21
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
22
|
+
proxy_set_header Host $http_host;
|
23
|
+
proxy_redirect false;
|
24
|
+
|
25
|
+
if (-f $request_filename/index.html) {
|
26
|
+
rewrite (.*) $1/index.html break;
|
27
|
+
}
|
28
|
+
if (-f $request_filename.html) {
|
29
|
+
rewrite (.*) $1.html break;
|
30
|
+
}
|
31
|
+
if (!-f $request_filename) {
|
32
|
+
proxy_pass http://<%= application %>;
|
33
|
+
break;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
error_page 500 502 503 504 /50x.html;
|
38
|
+
location = /50x.html {
|
39
|
+
root html;
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# /etc/init.d/monit start and stop monit daemon monitor process.
|
3
|
+
# Fredrik Steen, stone@debian.org
|
4
|
+
:
|
5
|
+
PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
6
|
+
DAEMON=/usr/local/bin/monit
|
7
|
+
CONFIG="/etc/monitrc"
|
8
|
+
NAME=monit
|
9
|
+
DESC="daemon monitor"
|
10
|
+
|
11
|
+
set -e
|
12
|
+
|
13
|
+
# Check if DAEMON binary exist
|
14
|
+
test -f $DAEMON || exit 0
|
15
|
+
|
16
|
+
ARGS="-c $CONFIG"
|
17
|
+
|
18
|
+
monit_not_configured () {
|
19
|
+
echo -e "monit won't be started/stopped\n\tunless it it's configured"
|
20
|
+
if [ "$1" != "stop" ]
|
21
|
+
then
|
22
|
+
echo -e "\tplease configure monit and then edit /etc/default/monit"
|
23
|
+
echo -e "\tand set the \"startup\" variable to 1 in order to allow "
|
24
|
+
echo -e "\tmonit to start"
|
25
|
+
fi
|
26
|
+
exit 0
|
27
|
+
}
|
28
|
+
|
29
|
+
monit_check_config () {
|
30
|
+
# Check for emtpy config, probably default configfile.
|
31
|
+
if [ "`grep -s -v \"^#\" $CONFIG`" = "" ]; then
|
32
|
+
echo "empty config, please edit $CONFIG."
|
33
|
+
exit 0
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
monit_check_perms () {
|
38
|
+
# Check the permission on configfile.
|
39
|
+
# The permission must not have more than -rwx------ (0700) permissions.
|
40
|
+
|
41
|
+
# Skip checking, fix perms instead.
|
42
|
+
/bin/chmod go-rwx $CONFIG
|
43
|
+
|
44
|
+
}
|
45
|
+
|
46
|
+
monit_delayed_monitoring () {
|
47
|
+
if [ -x $DELAY ]; then
|
48
|
+
$DELAY &
|
49
|
+
elif [ -f $DELAY ]; then
|
50
|
+
echo
|
51
|
+
echo "[WARNING] A delayed start file exists ($DELAY) but it is not executable."
|
52
|
+
fi
|
53
|
+
}
|
54
|
+
|
55
|
+
monit_check_syntax () {
|
56
|
+
$DAEMON -t;
|
57
|
+
# if [ $? ] ; then
|
58
|
+
# echo "syntax good"
|
59
|
+
# else
|
60
|
+
# echo "syntax bad"
|
61
|
+
# fi
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
monit_checks () {
|
66
|
+
# Check for emtpy configfile
|
67
|
+
monit_check_config
|
68
|
+
# Check permissions of configfile
|
69
|
+
monit_check_perms
|
70
|
+
}
|
71
|
+
|
72
|
+
case "$1" in
|
73
|
+
start)
|
74
|
+
echo -n "Starting $DESC: "
|
75
|
+
monit_checks $1
|
76
|
+
echo -n "$NAME"
|
77
|
+
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
|
78
|
+
--exec $DAEMON > /dev/null 2>&1 -- $ARGS
|
79
|
+
monit_delayed_monitoring
|
80
|
+
echo "."
|
81
|
+
;;
|
82
|
+
stop)
|
83
|
+
echo -n "Stopping $DESC: "
|
84
|
+
#monit_checks $1
|
85
|
+
echo -n "$NAME"
|
86
|
+
start-stop-daemon --retry 5 --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
|
87
|
+
--exec $DAEMON > /dev/null 2>&1
|
88
|
+
echo "."
|
89
|
+
;;
|
90
|
+
restart|force-reload)
|
91
|
+
$0 stop
|
92
|
+
$0 start
|
93
|
+
;;
|
94
|
+
syntax)
|
95
|
+
monit_check_syntax
|
96
|
+
;;
|
97
|
+
*)
|
98
|
+
N=/etc/init.d/$NAME
|
99
|
+
echo "Usage: $N {start|stop|restart|force-reload|syntax}" >&2
|
100
|
+
exit 1
|
101
|
+
;;
|
102
|
+
esac
|
103
|
+
|
104
|
+
exit 0
|
@@ -0,0 +1,250 @@
|
|
1
|
+
###############################################################################
|
2
|
+
## Monit control file
|
3
|
+
###############################################################################
|
4
|
+
##
|
5
|
+
## Comments begin with a '#' and extend through the end of the line. Keywords
|
6
|
+
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
|
7
|
+
##
|
8
|
+
## Below you will find examples of some frequently used statements. For
|
9
|
+
## information about the control file and a complete list of statements and
|
10
|
+
## options, please have a look in the Monit manual.
|
11
|
+
##
|
12
|
+
##
|
13
|
+
###############################################################################
|
14
|
+
## Global section
|
15
|
+
###############################################################################
|
16
|
+
##
|
17
|
+
## Start Monit in the background (run as a daemon):
|
18
|
+
#
|
19
|
+
set daemon <%= monit_check_interval %> # check services at 2-minute intervals
|
20
|
+
# with start delay 240 # optional: delay the first check by 4-minutes (by
|
21
|
+
# # default Monit check immediately after Monit start)
|
22
|
+
#
|
23
|
+
#
|
24
|
+
## Set syslog logging with the 'daemon' facility. If the FACILITY option is
|
25
|
+
## omitted, Monit will use 'user' facility by default. If you want to log to
|
26
|
+
## a standalone log file instead, specify the full path to the log file
|
27
|
+
#
|
28
|
+
set logfile <%= monit_log %>
|
29
|
+
#
|
30
|
+
#
|
31
|
+
### Set the location of the Monit id file which stores the unique id for the
|
32
|
+
### Monit instance. The id is generated and stored on first Monit start. By
|
33
|
+
### default the file is placed in $HOME/.monit.id.
|
34
|
+
#
|
35
|
+
# set idfile /var/.monit.id
|
36
|
+
#
|
37
|
+
### Set the location of the Monit state file which saves monitoring states
|
38
|
+
### on each cycle. By default the file is placed in $HOME/.monit.state. If
|
39
|
+
### the state file is stored on a persistent filesystem, Monit will recover
|
40
|
+
### the monitoring state across reboots. If it is on temporary filesystem, the
|
41
|
+
### state will be lost on reboot which may be convenient in some situations.
|
42
|
+
#
|
43
|
+
# set statefile /var/.monit.state
|
44
|
+
#
|
45
|
+
## Set the list of mail servers for alert delivery. Multiple servers may be
|
46
|
+
## specified using a comma separator. By default Monit uses port 25 - it is
|
47
|
+
## possible to override this with the PORT option.
|
48
|
+
#
|
49
|
+
<%= '# ' unless monit_mailserver %>set mailserver <%= monit_mailserver || 'mail.bar.baz' %> # primary mailserver
|
50
|
+
# backup.bar.baz port 10025, # backup mailserver on port 10025
|
51
|
+
# localhost # fallback relay
|
52
|
+
#
|
53
|
+
#
|
54
|
+
## By default Monit will drop alert events if no mail servers are available.
|
55
|
+
## If you want to keep the alerts for later delivery retry, you can use the
|
56
|
+
## EVENTQUEUE statement. The base directory where undelivered alerts will be
|
57
|
+
## stored is specified by the BASEDIR option. You can limit the maximal queue
|
58
|
+
## size using the SLOTS option (if omitted, the queue is limited by space
|
59
|
+
## available in the back end filesystem).
|
60
|
+
#
|
61
|
+
# set eventqueue
|
62
|
+
# basedir /var/monit # set the base directory where events will be stored
|
63
|
+
# slots 100 # optionally limit the queue size
|
64
|
+
#
|
65
|
+
#
|
66
|
+
## Send status and events to M/Monit (for more informations about M/Monit
|
67
|
+
## see http://mmonit.com/).
|
68
|
+
#
|
69
|
+
# set mmonit http://monit:monit@192.168.1.10:8080/collector
|
70
|
+
#
|
71
|
+
#
|
72
|
+
## Monit by default uses the following alert mail format:
|
73
|
+
##
|
74
|
+
## --8<--
|
75
|
+
## From: monit@$HOST # sender
|
76
|
+
## Subject: monit alert -- $EVENT $SERVICE # subject
|
77
|
+
##
|
78
|
+
## $EVENT Service $SERVICE #
|
79
|
+
## #
|
80
|
+
## Date: $DATE #
|
81
|
+
## Action: $ACTION #
|
82
|
+
## Host: $HOST # body
|
83
|
+
## Description: $DESCRIPTION #
|
84
|
+
## #
|
85
|
+
## Your faithful employee, #
|
86
|
+
## Monit #
|
87
|
+
## --8<--
|
88
|
+
##
|
89
|
+
## You can override this message format or parts of it, such as subject
|
90
|
+
## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
|
91
|
+
## are expanded at runtime. For example, to override the sender, use:
|
92
|
+
#
|
93
|
+
<%= '# ' unless monit_mailserver %>set mail-format { from: <%= monit_mail_from %> }
|
94
|
+
#
|
95
|
+
#
|
96
|
+
## You can set alert recipients whom will receive alerts if/when a
|
97
|
+
## service defined in this file has errors. Alerts may be restricted on
|
98
|
+
## events by using a filter as in the second example below.
|
99
|
+
<% monit_alert_recipients.each do |recipient| %>
|
100
|
+
<%= '# ' unless monit_mailserver %>set alert <%= recipient %> # receive all alerts
|
101
|
+
<% end %>
|
102
|
+
<% monit_timeout_recipients.each do |recipient| %>
|
103
|
+
<%= '# ' unless monit_mailserver %>set alert <%= recipient %> only on { timeout } # receive just service-
|
104
|
+
# timeout alert
|
105
|
+
<% end %>
|
106
|
+
|
107
|
+
#
|
108
|
+
#
|
109
|
+
#
|
110
|
+
## Monit has an embedded web server which can be used to view status of
|
111
|
+
## services monitored and manage services from a web interface. See the
|
112
|
+
## Monit Wiki if you want to enable SSL for the web server.
|
113
|
+
#
|
114
|
+
<% if monit_webserver_enabled %>
|
115
|
+
set httpd port <%= monit_webserver_port %> and
|
116
|
+
use address <%= monit_webserver_address %> # listen on <%= monit_webserver_address %>
|
117
|
+
<% monit_webserver_allowed_hosts_and_networks.each do |host| %>
|
118
|
+
allow <%= host %> # allow <%= host %> to connect to the server
|
119
|
+
<% end %>
|
120
|
+
allow <%= monit_webserver_auth_user %>:<%= monit_webserver_auth_pass %> # require user <%= monit_webserver_auth_user %> with password <%= monit_webserver_auth_pass %>
|
121
|
+
# allow @monit # allow users of group 'monit' to connect (rw)
|
122
|
+
# allow @users readonly # allow users of group 'users' to connect readonly
|
123
|
+
<% end %>
|
124
|
+
|
125
|
+
#
|
126
|
+
#
|
127
|
+
###############################################################################
|
128
|
+
## Services
|
129
|
+
###############################################################################
|
130
|
+
##
|
131
|
+
## Check general system resources such as load average, cpu and memory
|
132
|
+
## usage. Each test specifies a resource, conditions and the action to be
|
133
|
+
## performed should a test fail.
|
134
|
+
#
|
135
|
+
# check system myhost.mydomain.tld
|
136
|
+
# if loadavg (1min) > 4 then alert
|
137
|
+
# if loadavg (5min) > 2 then alert
|
138
|
+
# if memory usage > 75% then alert
|
139
|
+
# if cpu usage (user) > 70% then alert
|
140
|
+
# if cpu usage (system) > 30% then alert
|
141
|
+
# if cpu usage (wait) > 20% then alert
|
142
|
+
#
|
143
|
+
#
|
144
|
+
## Check a file for existence, checksum, permissions, uid and gid. In addition
|
145
|
+
## to alert recipients in the global section, customized alert can be sent to
|
146
|
+
## additional recipients by specifying a local alert handler. The service may
|
147
|
+
## be grouped using the GROUP option. More than one group can be specified by
|
148
|
+
## repeating the 'group name' statement.
|
149
|
+
#
|
150
|
+
# check file apache_bin with path /usr/local/apache/bin/httpd
|
151
|
+
# if failed checksum and
|
152
|
+
# expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
|
153
|
+
# if failed permission 755 then unmonitor
|
154
|
+
# if failed uid root then unmonitor
|
155
|
+
# if failed gid root then unmonitor
|
156
|
+
# alert security@foo.bar on {
|
157
|
+
# checksum, permission, uid, gid, unmonitor
|
158
|
+
# } with the mail-format { subject: Alarm! }
|
159
|
+
# group server
|
160
|
+
#
|
161
|
+
#
|
162
|
+
## Check that a process is running, in this case Apache, and that it respond
|
163
|
+
## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
|
164
|
+
## and number of children. If the process is not running, Monit will restart
|
165
|
+
## it by default. In case the service is restarted very often and the
|
166
|
+
## problem remains, it is possible to disable monitoring using the TIMEOUT
|
167
|
+
## statement. This service depends on another service (apache_bin) which
|
168
|
+
## is defined above.
|
169
|
+
#
|
170
|
+
# check process apache with pidfile /usr/local/apache/logs/httpd.pid
|
171
|
+
# start program = "/etc/init.d/httpd start" with timeout 60 seconds
|
172
|
+
# stop program = "/etc/init.d/httpd stop"
|
173
|
+
# if cpu > 60% for 2 cycles then alert
|
174
|
+
# if cpu > 80% for 5 cycles then restart
|
175
|
+
# if totalmem > 200.0 MB for 5 cycles then restart
|
176
|
+
# if children > 250 then restart
|
177
|
+
# if loadavg(5min) greater than 10 for 8 cycles then stop
|
178
|
+
# if failed host www.tildeslash.com port 80 protocol http
|
179
|
+
# and request "/somefile.html"
|
180
|
+
# then restart
|
181
|
+
# if failed port 443 type tcpssl protocol http
|
182
|
+
# with timeout 15 seconds
|
183
|
+
# then restart
|
184
|
+
# if 3 restarts within 5 cycles then timeout
|
185
|
+
# depends on apache_bin
|
186
|
+
# group server
|
187
|
+
#
|
188
|
+
#
|
189
|
+
## Check filesystem permissions, uid, gid, space and inode usage. Other services,
|
190
|
+
## such as databases, may depend on this resource and an automatically graceful
|
191
|
+
## stop may be cascaded to them before the filesystem will become full and data
|
192
|
+
## lost.
|
193
|
+
#
|
194
|
+
# check filesystem datafs with path /dev/sdb1
|
195
|
+
# start program = "/bin/mount /data"
|
196
|
+
# stop program = "/bin/umount /data"
|
197
|
+
# if failed permission 660 then unmonitor
|
198
|
+
# if failed uid root then unmonitor
|
199
|
+
# if failed gid disk then unmonitor
|
200
|
+
# if space usage > 80% for 5 times within 15 cycles then alert
|
201
|
+
# if space usage > 99% then stop
|
202
|
+
# if inode usage > 30000 then alert
|
203
|
+
# if inode usage > 99% then stop
|
204
|
+
# group server
|
205
|
+
#
|
206
|
+
#
|
207
|
+
## Check a file's timestamp. In this example, we test if a file is older
|
208
|
+
## than 15 minutes and assume something is wrong if its not updated. Also,
|
209
|
+
## if the file size exceed a given limit, execute a script
|
210
|
+
#
|
211
|
+
# check file database with path /data/mydatabase.db
|
212
|
+
# if failed permission 700 then alert
|
213
|
+
# if failed uid data then alert
|
214
|
+
# if failed gid data then alert
|
215
|
+
# if timestamp > 15 minutes then alert
|
216
|
+
# if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
|
217
|
+
#
|
218
|
+
#
|
219
|
+
## Check directory permission, uid and gid. An event is triggered if the
|
220
|
+
## directory does not belong to the user with uid 0 and gid 0. In addition,
|
221
|
+
## the permissions have to match the octal description of 755 (see chmod(1)).
|
222
|
+
#
|
223
|
+
# check directory bin with path /bin
|
224
|
+
# if failed permission 755 then unmonitor
|
225
|
+
# if failed uid 0 then unmonitor
|
226
|
+
# if failed gid 0 then unmonitor
|
227
|
+
#
|
228
|
+
#
|
229
|
+
## Check a remote host availability by issuing a ping test and check the
|
230
|
+
## content of a response from a web server. Up to three pings are sent and
|
231
|
+
## connection to a port and an application level network check is performed.
|
232
|
+
#
|
233
|
+
# check host myserver with address 192.168.1.1
|
234
|
+
# if failed icmp type echo count 3 with timeout 3 seconds then alert
|
235
|
+
# if failed port 3306 protocol mysql with timeout 15 seconds then alert
|
236
|
+
# if failed url http://user:password@www.foo.bar:8080/?querystring
|
237
|
+
# and content == 'action="j_security_check"'
|
238
|
+
# then alert
|
239
|
+
#
|
240
|
+
#
|
241
|
+
###############################################################################
|
242
|
+
## Includes
|
243
|
+
###############################################################################
|
244
|
+
##
|
245
|
+
## It is possible to include additional configuration parts from other files or
|
246
|
+
## directories.
|
247
|
+
#
|
248
|
+
include /etc/monit.d/*.monitrc
|
249
|
+
#
|
250
|
+
#
|