deprec 2.1.19 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/CHANGELOG +11 -1
  2. data/{README → README.md} +33 -68
  3. data/bin/hosts.rb +44 -0
  4. data/docs/nagios.txt +28 -0
  5. data/lib/deprec/capistrano_extensions.rb +21 -32
  6. data/lib/deprec/recipes/apache.rb +54 -73
  7. data/lib/deprec/recipes/deprec.rb +30 -48
  8. data/lib/deprec/recipes/git.rb +2 -85
  9. data/lib/deprec/recipes/haproxy.rb +3 -11
  10. data/lib/deprec/recipes/mri.rb +23 -40
  11. data/lib/deprec/recipes/mysql.rb +6 -23
  12. data/lib/deprec/recipes/nagios.rb +2 -17
  13. data/lib/deprec/recipes/nagios3.rb +180 -0
  14. data/lib/deprec/recipes/network.rb +60 -28
  15. data/lib/deprec/recipes/nrpe.rb +82 -0
  16. data/lib/deprec/recipes/passenger.rb +15 -12
  17. data/lib/deprec/recipes/postgresql.rb +2 -2
  18. data/lib/deprec/recipes/rack.rb +44 -0
  19. data/lib/deprec/recipes/rails.rb +10 -32
  20. data/lib/deprec/recipes/ree.rb +27 -18
  21. data/lib/deprec/recipes/rubygems.rb +29 -0
  22. data/lib/deprec/recipes/sqlite.rb +1 -1
  23. data/lib/deprec/recipes/ssh.rb +1 -0
  24. data/lib/deprec/recipes/svn.rb +1 -160
  25. data/lib/deprec/recipes/users.rb +19 -16
  26. data/lib/deprec/recipes_minus_rails.rb +39 -36
  27. data/lib/deprec/templates/apache/CHANGES.txt +11 -0
  28. data/lib/deprec/templates/mysql/my.cnf.erb +21 -31
  29. data/lib/deprec/templates/{nagios → nagios.old}/README +0 -0
  30. data/lib/deprec/templates/nagios.old/apache_vhost.erb +25 -0
  31. data/lib/deprec/templates/{nagios → nagios.old}/cgi.cfg.erb +0 -0
  32. data/lib/deprec/templates/nagios.old/check_linux_free_memory.pl +118 -0
  33. data/lib/deprec/templates/{nagios → nagios.old}/check_mongrel_cluster.rb +0 -0
  34. data/lib/deprec/templates/nagios.old/htpasswd.users +1 -0
  35. data/lib/deprec/templates/{nagios → nagios.old}/mrtg.cfg +0 -0
  36. data/lib/deprec/templates/{nagios → nagios.old}/nagios.cfg.erb +0 -0
  37. data/lib/deprec/templates/{nagios → nagios.old}/nrpe.cfg.erb +0 -0
  38. data/lib/deprec/templates/{nagios → nagios.old}/nrpe.xinetd.erb +0 -0
  39. data/lib/deprec/templates/{nagios → nagios.old}/objects/commands.cfg.erb +0 -0
  40. data/lib/deprec/templates/{nagios → nagios.old}/objects/contacts.cfg.erb +0 -0
  41. data/lib/deprec/templates/{nagios → nagios.old}/objects/hosts.cfg.erb +0 -0
  42. data/lib/deprec/templates/{nagios → nagios.old}/objects/localhost.cfg.erb +0 -0
  43. data/lib/deprec/templates/{nagios → nagios.old}/objects/services.cfg.erb +0 -0
  44. data/lib/deprec/templates/{nagios → nagios.old}/objects/timeperiods.cfg.erb +0 -0
  45. data/lib/deprec/templates/{nagios → nagios.old}/resource.cfg.erb +0 -0
  46. data/lib/deprec/templates/nagios/apache2.conf +55 -0
  47. data/lib/deprec/templates/nagios/cgi.cfg +25 -0
  48. data/lib/deprec/templates/nagios/commands.cfg +52 -0
  49. data/lib/deprec/templates/nagios/conf.d/contacts_nagios2.cfg +23 -0
  50. data/lib/deprec/templates/nagios/conf.d/extinfo_nagios2.cfg +13 -0
  51. data/lib/deprec/templates/nagios/conf.d/generic-host_nagios2.cfg +19 -0
  52. data/lib/deprec/templates/nagios/conf.d/generic-service_nagios2.cfg +26 -0
  53. data/lib/deprec/templates/nagios/conf.d/hostgroups_nagios2.cfg +48 -0
  54. data/lib/deprec/templates/nagios/conf.d/hosts/localhost_nagios2.cfg +59 -0
  55. data/lib/deprec/templates/nagios/conf.d/services_nagios2.cfg +45 -0
  56. data/lib/deprec/templates/nagios/conf.d/timeperiods_nagios2.cfg +50 -0
  57. data/lib/deprec/templates/nagios/host_template.erb +6 -0
  58. data/lib/deprec/templates/nagios/htpasswd.users +1 -1
  59. data/lib/deprec/templates/nagios/nagios.cfg +1326 -0
  60. data/lib/deprec/templates/nagios/nrpe.cfg +28 -0
  61. data/lib/deprec/templates/nagios/resource.cfg +31 -0
  62. data/lib/deprec/templates/passenger/apache_vhost.erb +2 -2
  63. data/lib/deprec/templates/passenger/logrotate.conf.erb +1 -1
  64. data/lib/deprec/templates/passenger/passenger.conf.erb +12 -11
  65. data/lib/deprec/templates/passenger/passenger.load.erb +1 -1
  66. metadata +43 -42
  67. data/lib/deprec/recipes/wordpress.rb +0 -96
@@ -0,0 +1,25 @@
1
+ <VirtualHost *:80>
2
+ ServerAdmin root@localhost
3
+ ServerName monitor.c3internal.com
4
+ ServerAlias nagios nagios.production.c3internal.com
5
+ DocumentRoot /usr/share/nagios3/htdocs
6
+ CustomLog /var/log/nagios3/apache_access.log combined
7
+ ErrorLog /var/log/nagios3/apache_error.log
8
+
9
+ ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
10
+ ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
11
+
12
+ Alias /nagios3/stylesheets /etc/nagios3/stylesheets
13
+ Alias /nagios3 /usr/share/nagios3/htdocs
14
+
15
+ <Location />
16
+ AuthName "Nagios Server"
17
+ AuthType Basic
18
+ AuthUserFile "/etc/nagios3/htpasswd.users"
19
+ require valid-user
20
+ </Location>
21
+
22
+ RewriteEngine On
23
+ RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
24
+ RewriteRule ^(.*)index\.html$ $1 [R=301,L]
25
+ </VirtualHost>
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/perl
2
+ use strict;
3
+ use warnings;
4
+ use Getopt::Long;
5
+ use File::Basename;
6
+
7
+ # Author: Dean Wilson ; License: GPL
8
+ # Project Home: http://www.unixdaemon.net/
9
+ # For documentation look at the bottom of this file, or run with '-h'
10
+ # Version 0.5 - Tided up arg handling. Added usage
11
+
12
+ # Changes:
13
+ # Usage information corrected, thanks to Bartlomiej Konarski
14
+
15
+ # nagios requires a 3 for unknown errors.
16
+ $SIG{__DIE__} = sub {
17
+ print @_;
18
+ exit 3;
19
+ };
20
+
21
+ my $app = basename($0);
22
+
23
+ GetOptions(
24
+ "w|warn=s" => \( my $warn_percent = 30 ),
25
+ "c|crit=s" => \( my $crit_percent = 20 ),
26
+ "h|help" => \&usage,
27
+ );
28
+
29
+ # remove any % passed in
30
+ $warn_percent =~ s/%//;
31
+ $crit_percent =~ s/%//;
32
+
33
+ die "Warning value must be larger than critical value\n"
34
+ unless $warn_percent >= $crit_percent;
35
+
36
+ my $memory_stats_ref = get_mem();
37
+ my $percentage_free = get_percentage($memory_stats_ref);
38
+
39
+ if ($percentage_free <= $crit_percent) {
40
+ print "CRIT: Only $percentage_free% ($memory_stats_ref->{free_cache}M) of memory free!\n";
41
+ exit 2;
42
+ } elsif ($percentage_free <= $warn_percent) {
43
+ print "WARN: Only $percentage_free% ($memory_stats_ref->{free_cache}M) of memory free!\n";
44
+ exit 1;
45
+ } else {
46
+ print "OK: $percentage_free% ($memory_stats_ref->{free_cache}M) free memory.\n";
47
+ exit 0;
48
+ }
49
+
50
+ #########################################
51
+
52
+ sub get_mem {
53
+ # get the two values from the free command.
54
+ # return them as a hash ref
55
+
56
+ my %memory_stats;
57
+
58
+ open(FREEPIPE, "free -m |")
59
+ || die "Failed to open 'free'\n$!\n";
60
+
61
+ while(<FREEPIPE>) {
62
+ chomp;
63
+ next unless m!buffers/cache:!;
64
+ m/[^\d]+(\d+)\s+(\d+)$/;
65
+ $memory_stats{'used_cache'} = $1;
66
+ $memory_stats{'free_cache'} = $2;
67
+ }
68
+
69
+ close FREEPIPE;
70
+
71
+ return \%memory_stats;
72
+ }
73
+
74
+ #------------------------------------------#
75
+
76
+ sub get_percentage {
77
+ my $mem_stats_ref = shift;
78
+ my $percentage_free;
79
+
80
+ my $total = $mem_stats_ref->{'used_cache'} + $mem_stats_ref->{'free_cache'};
81
+ $percentage_free = int (($mem_stats_ref->{'free_cache'} / $total) * 100);
82
+
83
+ return $percentage_free;
84
+ }
85
+
86
+ #------------------------------------------#
87
+
88
+ sub usage {
89
+ print<<EOU;
90
+
91
+ $app - Copyright (c) 2006 Dean Wilson. Licensed under the GPL
92
+
93
+ This script reports the percentage of memory that's still free along
94
+ with a warning or a critical based upon user defined threshholds.
95
+
96
+ This script was written to be used in conjunction with Nagios.
97
+
98
+ Usage Examples:
99
+ $app -w 20 -c 10
100
+ $app -warn 30 -crit 15
101
+ $app -h # shows this information
102
+
103
+ Options:
104
+ -w | -warn
105
+ Warn if less than this percentage is free.
106
+ -c | -crit
107
+ Crit if less than this percentage is free.
108
+ -h
109
+ This help and usage information
110
+
111
+ Notes:
112
+ The output format of "free" (which this script wraps) can change
113
+ between releases. Please double check the outputs before you deploy
114
+ this script.
115
+
116
+ EOU
117
+ exit 3;
118
+ }
@@ -0,0 +1 @@
1
+ nagiosadmin:wSjr.2Tk17iAU
@@ -0,0 +1,55 @@
1
+ # apache configuration for nagios 3.x
2
+ # note to users of nagios 1.x and 2.x:
3
+ # throughout this file are commented out sections which preserve
4
+ # backwards compatibility with bookmarks/config for older nagios versios.
5
+ # simply look for lines following "nagios 1.x:" and "nagios 2.x" comments.
6
+
7
+ ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
8
+ ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
9
+ # nagios 1.x:
10
+ #ScriptAlias /cgi-bin/nagios /usr/lib/cgi-bin/nagios3
11
+ #ScriptAlias /nagios/cgi-bin /usr/lib/cgi-bin/nagios3
12
+ # nagios 2.x:
13
+ #ScriptAlias /cgi-bin/nagios2 /usr/lib/cgi-bin/nagios3
14
+ #ScriptAlias /nagios2/cgi-bin /usr/lib/cgi-bin/nagios3
15
+
16
+ # Where the stylesheets (config files) reside
17
+ Alias /nagios3/stylesheets /etc/nagios3/stylesheets
18
+ # nagios 1.x:
19
+ #Alias /nagios/stylesheets /etc/nagios3/stylesheets
20
+ # nagios 2.x:
21
+ #Alias /nagios2/stylesheets /etc/nagios3/stylesheets
22
+
23
+ # Where the HTML pages live
24
+ Alias /nagios3 /usr/share/nagios3/htdocs
25
+ # nagios 2.x:
26
+ #Alias /nagios2 /usr/share/nagios3/htdocs
27
+ # nagios 1.x:
28
+ #Alias /nagios /usr/share/nagios3/htdocs
29
+
30
+ <DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
31
+ Options FollowSymLinks
32
+
33
+ DirectoryIndex index.php index.html
34
+
35
+ AllowOverride AuthConfig
36
+ Order Allow,Deny
37
+ Allow From All
38
+
39
+ AuthName "Nagios Access"
40
+ AuthType Basic
41
+ AuthUserFile /etc/nagios3/htpasswd.users
42
+ # nagios 1.x:
43
+ #AuthUserFile /etc/nagios/htpasswd.users
44
+ require valid-user
45
+ </DirectoryMatch>
46
+
47
+ # Enable this ScriptAlias if you want to enable the grouplist patch.
48
+ # See http://apan.sourceforge.net/download.html for more info
49
+ # It allows you to see a clickable list of all hostgroups in the
50
+ # left pane of the Nagios web interface
51
+ # XXX This is not tested for nagios 2.x use at your own peril
52
+ #ScriptAlias /nagios3/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi
53
+ # nagios 1.x:
54
+ #ScriptAlias /nagios/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi
55
+
@@ -0,0 +1,25 @@
1
+ # /etc/nagios3/cgi.cfg ~ Generated with deprec
2
+
3
+ main_config_file=/etc/nagios3/nagios.cfg
4
+ physical_html_path=/usr/share/nagios3/htdocs
5
+ url_html_path=/nagios3
6
+ show_context_help=1
7
+ use_pending_states=1
8
+ nagios_check_command=/usr/lib/nagios/plugins/check_nagios /var/cache/nagios3/status.dat 5 '/usr/sbin/nagios3'
9
+ use_authentication=1
10
+ use_ssl_authentication=0
11
+ authorized_for_system_information=nagiosadmin
12
+ authorized_for_configuration_information=nagiosadmin
13
+ authorized_for_system_commands=nagiosadmin
14
+ authorized_for_all_services=nagiosadmin
15
+ authorized_for_all_hosts=nagiosadmin
16
+ authorized_for_all_service_commands=nagiosadmin
17
+ authorized_for_all_host_commands=nagiosadmin
18
+ default_statusmap_layout=5
19
+ default_statuswrl_layout=4
20
+ ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
21
+ refresh_rate=90
22
+ escape_html_tags=1
23
+ action_url_target=_blank
24
+ notes_url_target=_blank
25
+ lock_author_names=1
@@ -0,0 +1,52 @@
1
+ ###############################################################################
2
+ # COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS
3
+ ###############################################################################
4
+
5
+
6
+ ################################################################################
7
+ # NOTIFICATION COMMANDS
8
+ ################################################################################
9
+
10
+
11
+ # 'notify-host-by-email' command definition
12
+ define command{
13
+ command_name notify-host-by-email
14
+ command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
15
+ }
16
+
17
+ # 'notify-service-by-email' command definition
18
+ define command{
19
+ command_name notify-service-by-email
20
+ command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
21
+ }
22
+
23
+
24
+
25
+
26
+
27
+ ################################################################################
28
+ # HOST CHECK COMMANDS
29
+ ################################################################################
30
+
31
+ # On Debian, check-host-alive is being defined from within the
32
+ # nagios-plugins-basic package
33
+
34
+ ################################################################################
35
+ # PERFORMANCE DATA COMMANDS
36
+ ################################################################################
37
+
38
+
39
+ # 'process-host-perfdata' command definition
40
+ define command{
41
+ command_name process-host-perfdata
42
+ command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /var/lib/nagios3/host-perfdata.out
43
+ }
44
+
45
+
46
+ # 'process-service-perfdata' command definition
47
+ define command{
48
+ command_name process-service-perfdata
49
+ command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /var/lib/nagios3/service-perfdata.out
50
+ }
51
+
52
+
@@ -0,0 +1,23 @@
1
+ # /etc/nagios3/conf.d/contacts_nagios2.cfg ~ Generated by deprec.org
2
+
3
+ # CONTACT GROUPS
4
+
5
+ define contactgroup{
6
+ contactgroup_name admins
7
+ alias Nagios Administrators
8
+ members root
9
+ }
10
+
11
+ # CONTACTS
12
+
13
+ define contact{
14
+ contact_name root
15
+ alias Root
16
+ service_notification_period 24x7
17
+ host_notification_period 24x7
18
+ service_notification_options w,u,c,r
19
+ host_notification_options d,r
20
+ service_notification_commands notify-service-by-email
21
+ host_notification_commands notify-host-by-email
22
+ email root@localhost
23
+ }
@@ -0,0 +1,13 @@
1
+ ##
2
+ ## Extended Host and Service Information
3
+ ##
4
+
5
+ define hostextinfo{
6
+ hostgroup_name debian-servers
7
+ notes Debian GNU/Linux servers
8
+ # notes_url http://webserver.localhost.localdomain/hostinfo.pl?host=netware1
9
+ icon_image base/debian.png
10
+ icon_image_alt Debian GNU/Linux
11
+ vrml_image debian.png
12
+ statusmap_image base/debian.gd2
13
+ }
@@ -0,0 +1,19 @@
1
+ # Generic host definition template - This is NOT a real host, just a template!
2
+
3
+ define host{
4
+ name generic-host ; The name of this host template
5
+ notifications_enabled 1 ; Host notifications are enabled
6
+ event_handler_enabled 1 ; Host event handler is enabled
7
+ flap_detection_enabled 1 ; Flap detection is enabled
8
+ failure_prediction_enabled 1 ; Failure prediction is enabled
9
+ process_perf_data 1 ; Process performance data
10
+ retain_status_information 1 ; Retain status information across program restarts
11
+ retain_nonstatus_information 1 ; Retain non-status information across program restarts
12
+ check_command check-host-alive
13
+ max_check_attempts 10
14
+ notification_interval 0
15
+ notification_period 24x7
16
+ notification_options d,u,r
17
+ contact_groups admins
18
+ register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
19
+ }
@@ -0,0 +1,26 @@
1
+ # generic service template definition
2
+ define service{
3
+ name generic-service ; The 'name' of this service template
4
+ active_checks_enabled 1 ; Active service checks are enabled
5
+ passive_checks_enabled 1 ; Passive service checks are enabled/accepted
6
+ parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
7
+ obsess_over_service 1 ; We should obsess over this service (if necessary)
8
+ check_freshness 0 ; Default is to NOT check service 'freshness'
9
+ notifications_enabled 1 ; Service notifications are enabled
10
+ event_handler_enabled 1 ; Service event handler is enabled
11
+ flap_detection_enabled 1 ; Flap detection is enabled
12
+ failure_prediction_enabled 1 ; Failure prediction is enabled
13
+ process_perf_data 1 ; Process performance data
14
+ retain_status_information 1 ; Retain status information across program restarts
15
+ retain_nonstatus_information 1 ; Retain non-status information across program restarts
16
+ notification_interval 0 ; Only send notifications on status change by default.
17
+ is_volatile 0
18
+ check_period 24x7
19
+ normal_check_interval 5
20
+ retry_check_interval 1
21
+ max_check_attempts 4
22
+ notification_period 24x7
23
+ notification_options w,u,c,r
24
+ contact_groups admins
25
+ register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
26
+ }
@@ -0,0 +1,48 @@
1
+ # Some generic hostgroup definitions
2
+
3
+ # A simple wildcard hostgroup
4
+ define hostgroup {
5
+ hostgroup_name all
6
+ alias All Servers
7
+ members *
8
+ }
9
+
10
+ # A list of your Debian GNU/Linux servers
11
+ define hostgroup {
12
+ hostgroup_name debian-servers
13
+ alias Debian GNU/Linux Servers
14
+ members localhost
15
+ }
16
+
17
+ # A list of your Micro$oft Windows servers
18
+ define hostgroup {
19
+ hostgroup_name linux-servers
20
+ alias Linux Servers
21
+ members localhost
22
+ }
23
+
24
+ # A list of your Micro$oft Windows servers
25
+ define hostgroup {
26
+ hostgroup_name windows-servers
27
+ alias Micro$oft Windows Server
28
+ }
29
+
30
+ # A list of your VMware Hosts
31
+ define hostgroup {
32
+ hostgroup_name vmware-hosts
33
+ alias VMware Hosts
34
+ }
35
+
36
+ # A list of your web servers
37
+ define hostgroup {
38
+ hostgroup_name http-servers
39
+ alias HTTP servers
40
+ members localhost
41
+ }
42
+
43
+ # A list of your ssh-accessible servers
44
+ define hostgroup {
45
+ hostgroup_name ssh-servers
46
+ alias SSH servers
47
+ members localhost
48
+ }