andyh-deprec 1.99.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/CHANGELOG +187 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +138 -0
  5. data/THANKS +5 -0
  6. data/bin/depify +133 -0
  7. data/docs/ANNOUNCE.deprec2 +47 -0
  8. data/docs/README.install +88 -0
  9. data/docs/README.nagios +22 -0
  10. data/docs/README.rails +20 -0
  11. data/docs/README.svn +31 -0
  12. data/docs/ROADMAP.txt +74 -0
  13. data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
  14. data/docs/deprec-1.x/notes.txt +12 -0
  15. data/docs/deprec_banner.gif +0 -0
  16. data/docs/windows_linux.txt +350 -0
  17. data/docs/xen/plan.txt +5 -0
  18. data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
  19. data/docs/xen/xen-tools-notes.txt +31 -0
  20. data/docs/xen/xen_on_hardy.txt +39 -0
  21. data/lib/deprec/capistrano_extensions.rb +391 -0
  22. data/lib/deprec/recipes/aoe.rb +80 -0
  23. data/lib/deprec/recipes/apache.rb +179 -0
  24. data/lib/deprec/recipes/ar_sendmail.rb +65 -0
  25. data/lib/deprec/recipes/canonical.rb +57 -0
  26. data/lib/deprec/recipes/deprec.rb +188 -0
  27. data/lib/deprec/recipes/deprecated.rb +71 -0
  28. data/lib/deprec/recipes/example.rb +115 -0
  29. data/lib/deprec/recipes/git.rb +97 -0
  30. data/lib/deprec/recipes/gitosis.rb +48 -0
  31. data/lib/deprec/recipes/heartbeat.rb +138 -0
  32. data/lib/deprec/recipes/logrotate.rb +54 -0
  33. data/lib/deprec/recipes/lvm.rb +20 -0
  34. data/lib/deprec/recipes/memcache.rb +49 -0
  35. data/lib/deprec/recipes/mongrel.rb +219 -0
  36. data/lib/deprec/recipes/monit.rb +135 -0
  37. data/lib/deprec/recipes/mysql.rb +115 -0
  38. data/lib/deprec/recipes/nagios.rb +305 -0
  39. data/lib/deprec/recipes/network.rb +81 -0
  40. data/lib/deprec/recipes/nginx.rb +144 -0
  41. data/lib/deprec/recipes/ntp.rb +103 -0
  42. data/lib/deprec/recipes/php.rb +99 -0
  43. data/lib/deprec/recipes/postfix.rb +105 -0
  44. data/lib/deprec/recipes/rails.rb +288 -0
  45. data/lib/deprec/recipes/ruby.rb +66 -0
  46. data/lib/deprec/recipes/sphinx.rb +83 -0
  47. data/lib/deprec/recipes/ssh.rb +93 -0
  48. data/lib/deprec/recipes/svn.rb +171 -0
  49. data/lib/deprec/recipes/trac.rb +277 -0
  50. data/lib/deprec/recipes/ubuntu.rb +20 -0
  51. data/lib/deprec/recipes/users.rb +90 -0
  52. data/lib/deprec/recipes/utils.rb +39 -0
  53. data/lib/deprec/recipes/vnstat.rb +85 -0
  54. data/lib/deprec/recipes/xen.rb +262 -0
  55. data/lib/deprec/recipes.rb +37 -0
  56. data/lib/deprec/templates/aoe/aoe-init +55 -0
  57. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  58. data/lib/deprec/templates/apache/httpd-vhost-app.conf.erb +144 -0
  59. data/lib/deprec/templates/apache/httpd.conf +465 -0
  60. data/lib/deprec/templates/apache/index.html.erb +37 -0
  61. data/lib/deprec/templates/apache/master.css +72 -0
  62. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  63. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  64. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  65. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  66. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  67. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  68. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  69. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  70. data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
  71. data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +14 -0
  72. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  73. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  74. data/lib/deprec/templates/monit/monit-init-script +104 -0
  75. data/lib/deprec/templates/monit/monitrc.erb +227 -0
  76. data/lib/deprec/templates/monit/nothing +0 -0
  77. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  78. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  79. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  80. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  81. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  82. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  83. data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
  84. data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
  85. data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
  86. data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
  87. data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
  88. data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
  89. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  90. data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
  91. data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
  92. data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
  93. data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
  94. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  95. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  96. data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
  97. data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
  98. data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
  99. data/lib/deprec/templates/network/hostname.erb +1 -0
  100. data/lib/deprec/templates/network/hosts.erb +2 -0
  101. data/lib/deprec/templates/network/interfaces.erb +18 -0
  102. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  103. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  104. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  105. data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
  106. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  107. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  108. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  109. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  110. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  111. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  112. data/lib/deprec/templates/postfix/main.cf.erb +41 -0
  113. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  114. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  115. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  116. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  117. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  118. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  119. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  120. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  121. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  122. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  123. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  124. data/lib/deprec/templates/vnstat/config.php +57 -0
  125. data/lib/deprec/templates/xen/15-disable-hwclock +40 -0
  126. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  127. data/lib/deprec/templates/xen/xen-tools.conf.erb +220 -0
  128. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  129. data/lib/deprec/templates/xen/xend-init.erb +69 -0
  130. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  131. data/lib/deprec/templates/xen/xm.tmpl.erb +85 -0
  132. data/lib/deprec.rb +8 -0
  133. data/lib/deprec_cmd_completion.sh +26 -0
  134. data/lib/vmbuilder_plugins/all.rb +20 -0
  135. data/lib/vmbuilder_plugins/apt.rb +93 -0
  136. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  137. data/lib/vmbuilder_plugins/gem.rb +90 -0
  138. data/lib/vmbuilder_plugins/std.rb +203 -0
  139. metadata +224 -0
@@ -0,0 +1,321 @@
1
+ #################################################################
2
+ #
3
+ # CGI.CFG - Sample CGI Configuration File for Nagios 3.0b7
4
+ #
5
+ # Last Modified: 10-07-2007
6
+ #
7
+ #################################################################
8
+
9
+
10
+ # MAIN CONFIGURATION FILE
11
+ # This tells the CGIs where to find your main configuration file.
12
+ # The CGIs will read the main and host config files for any other
13
+ # data they might need.
14
+
15
+ main_config_file=/usr/local/nagios/etc/nagios.cfg
16
+
17
+
18
+
19
+ # PHYSICAL HTML PATH
20
+ # This is the path where the HTML files for Nagios reside. This
21
+ # value is used to locate the logo images needed by the statusmap
22
+ # and statuswrl CGIs.
23
+
24
+ physical_html_path=/usr/local/nagios/share
25
+
26
+
27
+
28
+ # URL HTML PATH
29
+ # This is the path portion of the URL that corresponds to the
30
+ # physical location of the Nagios HTML files (as defined above).
31
+ # This value is used by the CGIs to locate the online documentation
32
+ # and graphics. If you access the Nagios pages with an URL like
33
+ # http://www.myhost.com/nagios, this value should be '/nagios'
34
+ # (without the quotes).
35
+
36
+ url_html_path=/nagios
37
+
38
+
39
+
40
+ # CONTEXT-SENSITIVE HELP
41
+ # This option determines whether or not a context-sensitive
42
+ # help icon will be displayed for most of the CGIs.
43
+ # Values: 0 = disables context-sensitive help
44
+ # 1 = enables context-sensitive help
45
+
46
+ show_context_help=0
47
+
48
+
49
+
50
+ # PENDING STATES OPTION
51
+ # This option determines what states should be displayed in the web
52
+ # interface for hosts/services that have not yet been checked.
53
+ # Values: 0 = leave hosts/services that have not been check yet in their original state
54
+ # 1 = mark hosts/services that have not been checked yet as PENDING
55
+
56
+ use_pending_states=1
57
+
58
+
59
+
60
+
61
+ # AUTHENTICATION USAGE
62
+ # This option controls whether or not the CGIs will use any
63
+ # authentication when displaying host and service information, as
64
+ # well as committing commands to Nagios for processing.
65
+ #
66
+ # Read the HTML documentation to learn how the authorization works!
67
+ #
68
+ # NOTE: It is a really *bad* idea to disable authorization, unless
69
+ # you plan on removing the command CGI (cmd.cgi)! Failure to do
70
+ # so will leave you wide open to kiddies messing with Nagios and
71
+ # possibly hitting you with a denial of service attack by filling up
72
+ # your drive by continuously writing to your command file!
73
+ #
74
+ # Setting this value to 0 will cause the CGIs to *not* use
75
+ # authentication (bad idea), while any other value will make them
76
+ # use the authentication functions (the default).
77
+
78
+ use_authentication=1
79
+
80
+
81
+
82
+ # DEFAULT USER
83
+ # Setting this variable will define a default user name that can
84
+ # access pages without authentication. This allows people within a
85
+ # secure domain (i.e., behind a firewall) to see the current status
86
+ # without authenticating. You may want to use this to avoid basic
87
+ # authentication if you are not using a secure server since basic
88
+ # authentication transmits passwords in the clear.
89
+ #
90
+ # Important: Do not define a default username unless you are
91
+ # running a secure web server and are sure that everyone who has
92
+ # access to the CGIs has been authenticated in some manner! If you
93
+ # define this variable, anyone who has not authenticated to the web
94
+ # server will inherit all rights you assign to this user!
95
+
96
+ #default_user_name=guest
97
+
98
+
99
+
100
+ # SYSTEM/PROCESS INFORMATION ACCESS
101
+ # This option is a comma-delimited list of all usernames that
102
+ # have access to viewing the Nagios process information as
103
+ # provided by the Extended Information CGI (extinfo.cgi). By
104
+ # default, *no one* has access to this unless you choose to
105
+ # not use authorization. You may use an asterisk (*) to
106
+ # authorize any user who has authenticated to the web server.
107
+
108
+ authorized_for_system_information=nagiosadmin
109
+
110
+
111
+
112
+ # CONFIGURATION INFORMATION ACCESS
113
+ # This option is a comma-delimited list of all usernames that
114
+ # can view ALL configuration information (hosts, commands, etc).
115
+ # By default, users can only view configuration information
116
+ # for the hosts and services they are contacts for. You may use
117
+ # an asterisk (*) to authorize any user who has authenticated
118
+ # to the web server.
119
+
120
+ authorized_for_configuration_information=nagiosadmin
121
+
122
+
123
+
124
+ # SYSTEM/PROCESS COMMAND ACCESS
125
+ # This option is a comma-delimited list of all usernames that
126
+ # can issue shutdown and restart commands to Nagios via the
127
+ # command CGI (cmd.cgi). Users in this list can also change
128
+ # the program mode to active or standby. By default, *no one*
129
+ # has access to this unless you choose to not use authorization.
130
+ # You may use an asterisk (*) to authorize any user who has
131
+ # authenticated to the web server.
132
+
133
+ authorized_for_system_commands=nagiosadmin
134
+
135
+
136
+
137
+ # GLOBAL HOST/SERVICE VIEW ACCESS
138
+ # These two options are comma-delimited lists of all usernames that
139
+ # can view information for all hosts and services that are being
140
+ # monitored. By default, users can only view information
141
+ # for hosts or services that they are contacts for (unless you
142
+ # you choose to not use authorization). You may use an asterisk (*)
143
+ # to authorize any user who has authenticated to the web server.
144
+
145
+
146
+ authorized_for_all_services=nagiosadmin
147
+ authorized_for_all_hosts=nagiosadmin
148
+
149
+
150
+
151
+ # GLOBAL HOST/SERVICE COMMAND ACCESS
152
+ # These two options are comma-delimited lists of all usernames that
153
+ # can issue host or service related commands via the command
154
+ # CGI (cmd.cgi) for all hosts and services that are being monitored.
155
+ # By default, users can only issue commands for hosts or services
156
+ # that they are contacts for (unless you you choose to not use
157
+ # authorization). You may use an asterisk (*) to authorize any
158
+ # user who has authenticated to the web server.
159
+
160
+ authorized_for_all_service_commands=nagiosadmin
161
+ authorized_for_all_host_commands=nagiosadmin
162
+
163
+
164
+
165
+
166
+ # STATUSMAP BACKGROUND IMAGE
167
+ # This option allows you to specify an image to be used as a
168
+ # background in the statusmap CGI. It is assumed that the image
169
+ # resides in the HTML images path (i.e. /usr/local/nagios/share/images).
170
+ # This path is automatically determined by appending "/images"
171
+ # to the path specified by the 'physical_html_path' directive.
172
+ # Note: The image file may be in GIF, PNG, JPEG, or GD2 format.
173
+ # However, I recommend that you convert your image to GD2 format
174
+ # (uncompressed), as this will cause less CPU load when the CGI
175
+ # generates the image.
176
+
177
+ #statusmap_background_image=smbackground.gd2
178
+
179
+
180
+
181
+ # DEFAULT STATUSMAP LAYOUT METHOD
182
+ # This option allows you to specify the default layout method
183
+ # the statusmap CGI should use for drawing hosts. If you do
184
+ # not use this option, the default is to use user-defined
185
+ # coordinates. Valid options are as follows:
186
+ # 0 = User-defined coordinates
187
+ # 1 = Depth layers
188
+ # 2 = Collapsed tree
189
+ # 3 = Balanced tree
190
+ # 4 = Circular
191
+ # 5 = Circular (Marked Up)
192
+
193
+ default_statusmap_layout=5
194
+
195
+
196
+
197
+ # DEFAULT STATUSWRL LAYOUT METHOD
198
+ # This option allows you to specify the default layout method
199
+ # the statuswrl (VRML) CGI should use for drawing hosts. If you
200
+ # do not use this option, the default is to use user-defined
201
+ # coordinates. Valid options are as follows:
202
+ # 0 = User-defined coordinates
203
+ # 2 = Collapsed tree
204
+ # 3 = Balanced tree
205
+ # 4 = Circular
206
+
207
+ default_statuswrl_layout=4
208
+
209
+
210
+
211
+ # STATUSWRL INCLUDE
212
+ # This option allows you to include your own objects in the
213
+ # generated VRML world. It is assumed that the file
214
+ # resides in the HTML path (i.e. /usr/local/nagios/share).
215
+
216
+ #statuswrl_include=myworld.wrl
217
+
218
+
219
+
220
+ # PING SYNTAX
221
+ # This option determines what syntax should be used when
222
+ # attempting to ping a host from the WAP interface (using
223
+ # the statuswml CGI. You must include the full path to
224
+ # the ping binary, along with all required options. The
225
+ # $HOSTADDRESS$ macro is substituted with the address of
226
+ # the host before the command is executed.
227
+ # Please note that the syntax for the ping binary is
228
+ # notorious for being different on virtually ever *NIX
229
+ # OS and distribution, so you may have to tweak this to
230
+ # work on your system.
231
+
232
+ ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
233
+
234
+
235
+
236
+ # REFRESH RATE
237
+ # This option allows you to specify the refresh rate in seconds
238
+ # of various CGIs (status, statusmap, extinfo, and outages).
239
+
240
+ refresh_rate=90
241
+
242
+
243
+
244
+ # ESCAPE HTML TAGS
245
+ # This option determines whether HTML tags in host and service
246
+ # status output is escaped in the web interface. If enabled,
247
+ # your plugin output will not be able to contain clickable links.
248
+
249
+ escape_html_tags=1
250
+
251
+
252
+
253
+
254
+ # SOUND OPTIONS
255
+ # These options allow you to specify an optional audio file
256
+ # that should be played in your browser window when there are
257
+ # problems on the network. The audio files are used only in
258
+ # the status CGI. Only the sound for the most critical problem
259
+ # will be played. Order of importance (higher to lower) is as
260
+ # follows: unreachable hosts, down hosts, critical services,
261
+ # warning services, and unknown services. If there are no
262
+ # visible problems, the sound file optionally specified by
263
+ # 'normal_sound' variable will be played.
264
+ #
265
+ #
266
+ # <varname>=<sound_file>
267
+ #
268
+ # Note: All audio files must be placed in the /media subdirectory
269
+ # under the HTML path (i.e. /usr/local/nagios/share/media/).
270
+
271
+ #host_unreachable_sound=hostdown.wav
272
+ #host_down_sound=hostdown.wav
273
+ #service_critical_sound=critical.wav
274
+ #service_warning_sound=warning.wav
275
+ #service_unknown_sound=warning.wav
276
+ #normal_sound=noproblem.wav
277
+
278
+
279
+
280
+ # URL TARGET FRAMES
281
+ # These options determine the target frames in which notes and
282
+ # action URLs will open.
283
+
284
+ action_url_target=_blank
285
+ notes_url_target=_blank
286
+
287
+
288
+
289
+
290
+ # LOCK AUTHOR NAMES OPTION
291
+ # This option determines whether users can change the author name
292
+ # when submitting comments, scheduling downtime. If disabled, the
293
+ # author names will be locked into their contact name, as defined in Nagios.
294
+ # Values: 0 = allow editing author names
295
+ # 1 = lock author names (disallow editing)
296
+
297
+ lock_author_names=1
298
+
299
+
300
+
301
+
302
+ # SPLUNK INTEGRATION OPTIONS
303
+ # These options allow you to enable integration with Splunk
304
+ # in the web interface. If enabled, you'll be presented with
305
+ # "Splunk It" links in various places in the CGIs (log file,
306
+ # alert history, host/service detail, etc). Useful if you're
307
+ # trying to research why a particular problem occurred.
308
+ # For more information on Splunk, visit http://www.splunk.com/
309
+
310
+ # This option determines whether the Splunk integration is enabled
311
+ # Values: 0 = disable Splunk integration
312
+ # 1 = enable Splunk integration
313
+
314
+ #enable_splunk_integration=1
315
+
316
+
317
+ # This option should be the URL used to access your instance of Splunk
318
+
319
+ #splunk_url=http://127.0.0.1:8000/
320
+
321
+
@@ -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,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+
5
+ # Exit status
6
+ OK = 0
7
+ WARNING = 1
8
+ CRITICAL = 2
9
+
10
+ # use options instead
11
+ application = ARGV[0]
12
+ cluster_config_file = "/etc/mongrel_cluster/#{application}.yml"
13
+
14
+ def running?(pid)
15
+ # check if pid is running
16
+ ps_output = `ps -p #{pid}`
17
+ ps_output =~ /mongrel_rails/
18
+ end
19
+
20
+ def chdir_cwd
21
+ pwd = Dir.pwd
22
+ Dir.chdir(@options["cwd"]) if @options["cwd"]
23
+ yield
24
+ Dir.chdir(pwd) if @options["cwd"]
25
+ end
26
+
27
+ def read_pid(port)
28
+ pid_file = port_pid_file(port)
29
+ pid = 0
30
+ chdir_cwd do
31
+ pid = File.read(pid_file)
32
+ end
33
+ pid
34
+ end
35
+
36
+
37
+ # Load cluster config from YAML file
38
+ begin
39
+ cluster_config = YAML.load_file(cluster_config_file)
40
+ port = cluster_config['port'].to_i
41
+ servers = cluster_config['servers']
42
+ ports = (port..port+servers-1).collect
43
+ if cluster_config['pid_file'].match(/^\//)
44
+ pid_file_base = cluster_config['pid_file']
45
+ else
46
+ pid_file_base = File.join(cluster_config['cwd'], cluster_config['pid_file'])
47
+ end
48
+ rescue
49
+ print 'CRITICAL'
50
+ puts " Could not load mongrel cluster file (#{cluster_config_file})"
51
+ exit CRITICAL
52
+ end
53
+
54
+ # Check each mongrel
55
+ running = []
56
+ not_running = []
57
+
58
+ ports.each {|port|
59
+ pidfile = pid_file_base.sub('.pid',".#{port}.pid")
60
+ if File.readable?(pidfile)
61
+ pid = File.read(pidfile)
62
+ if running?(pid)
63
+ running << port
64
+ else
65
+ not_running << port
66
+ end
67
+ else
68
+ not_running << port
69
+ end
70
+ }
71
+
72
+ # Print response and exit
73
+
74
+ if not_running.empty?
75
+ print 'OK '
76
+ puts "mongrel running on ports #{running.join(', ')}"
77
+ exit OK
78
+ else
79
+ print 'CRITICAL '
80
+ puts "mongrel not running on #{not_running.join(', ')}. #{'Running on ' + running.join(', ') unless running.empty?}"
81
+ exit CRITICAL
82
+ end