Debian Codegraph @

check_email_delivery/src/docs/check_smtp_send.pod

raw
1
2
3 =pod
4
5 =head1 NAME
6
7 check_smtp_send - connects to an SMTP server and sends a message
8
9 =head1 SYNOPSIS
10
11 check_smtp_send -vV
12 check_smtp_send -?
13 check_smtp_send --help
14
15 =head1 OPTIONS
16
17 =over
18
19 =item --warning <seconds>
20
21 Warn if it takes longer than <seconds> to connect to the SMTP server. Default is 15 seconds.
22 Also known as: -w <seconds>
23
24 =item --critical <seconds>
25
26 Return a critical status if it takes longer than <seconds> to connect to the SMTP server. Default is 30 seconds.
27 Also known as: -c <seconds>
28
29 =item --timeout <seconds>
30
31 Abort with critical status if it takes longer than <seconds> to connect to the SMTP server. Default is 60 seconds.
32 The difference between timeout and critical is that, with the default settings, if it takes 45 seconds to
33 connect to the server then the connection will succeed but the plugin will return CRITICAL because it took longer
34 than 30 seconds.
35 Also known as: -t <seconds>
36
37 =item --hostname <server>
38
39 Address or name of the SMTP server. Examples: mail.server.com, localhost, 192.168.1.100
40
41 If not provided, and if there is only one --mailto address, the script will automatically look up the MX record
42 for the --mailto address and use that as the hostname. You can use this to check that your MX records are correct.
43 When omitting the --hostname option, it doesn't really make sense to specify --port, --username, or --password
44 but you can still do so and they will have their normal effect. To look up the MX records you need to have the
45 module Net::DNS and Email::Address installed.
46
47 Also known as: -H <server>
48
49 =item --port <number>
50
51 Service port on the SMTP server. Default is 25 for regular SMTP, 465 for SSL, and 587 for TLS.
52 Also known as: -p <number>
53
54 =item --tls
55
56 =item --notls
57
58 Enable TLS/AUTH protocol. Requires Net::SMTP::TLS, availble on CPAN.
59
60 When using this option, the default port is 587.
61 You can specify a port from the command line using the --port option.
62
63 Use the notls option to turn off the tls option.
64
65 Also, you may need to fix your copy of Net::SMTP::TLS. Here is the diff against version 0.12:
66
67 254c254
68 < $me->_command(sprintf("AUTH PLAIN %S",
69 ---
70 > $me->_command(sprintf("AUTH PLAIN %s",
71
72
73 =item --ssl
74
75 =item --nossl
76
77 Enable SSL protocol. Requires Net::SMTP::SSL and Authen::SASL, availble on CPAN.
78
79 When using this option, the default port is 465. You can override with the --port option.
80
81 Use the nossl option to turn off the ssl option.
82
83 =item --auth <method>
84
85 Enable authentication with Net::SMTP_auth (sold separately).
86 For example, try using --auth PLAIN or --auth CRAM-MD5.
87
88 =item --username <username>
89
90 =item --password <password>
91
92 Username and password to use when connecting to SMTP server.
93 Also known as: -U <username> -P <password>
94
95 =item --body <message>
96
97 Use this option to specify the body of the email message. If you need newlines in your message,
98 you might need to use the --stdin option instead.
99
100 =item --header <header>
101
102 Use this option to set an arbitrary header in the message. You can use it multiple times.
103
104 =item --stdin
105
106 Grab the body of the email message from stdin.
107
108 =item --mailto [email protected]
109
110 You can send a message to multiple recipients by repeating this option or by separating
111 the email addresses with commas (no whitespace allowed):
112
113 $ check_smtp_send -H mail.server.net --mailto [email protected],[email protected] --mailfrom [email protected]
114
115 SMTP SEND OK - 1 seconds
116
117 =item --mailfrom [email protected]
118
119 Use this option to set the "from" address in the email.
120
121 =item --template
122
123 =item --notemplate
124
125 Enable (or disable) processing of message body and headers. Requires Text::Template.
126
127 Use this option to apply special processing to your message body and headers that allows you to use the
128 results of arbitrary computations in the text. For example, you can use this feature to send a message
129 containing the hostname of the machine that sent the message without customizing the plugin configuration
130 on each machine.
131
132 When you enable the --template option, the message body and headers are parsed by
133 Text::Template. Even a message body provided using the --stdin option will be parsed.
134 See the Text::Template manual for more information, but in general any expression
135 written in Perl will work.
136
137 There is one convenience function provided to you, trim, which will remove leading and trailing whitespace
138 from its parameter. Here's an example:
139
140 check_smtp_send -H mail.server.net --mailto [email protected] --mailfrom [email protected]
141 --template --body 'hello, this message is from {use Sys::Hostname; hostname}'
142 --header 'Subject: test message from {trim(`whoami`)}'
143
144
145 =item --expect-response <code>
146
147 Use this option to specify which SMTP response code should be expected from the server
148 after the SMTP dialog is complete. The default is 250 (message accepted).
149
150 Also known as: -E <code>
151
152 =item --hires
153
154 Use the Time::HiRes module to measure time, if available.
155
156 =item --verbose
157
158 Display additional information. Useful for troubleshooting.
159
160 One --verbose will show extra information for OK, WARNING, and CRITICAL status.
161
162 Use one --verbose together with --version to see the default warning and critical timeout values.
163
164 Three --verbose (or -vvv) will show debug information, unless you're using --tls because Net::SMTP::TLS
165 does not have a Debug feature.
166
167 Also known as: -v
168
169 =item --version
170
171 Display plugin version and exit.
172 Also known as: -V
173
174 =item --help
175
176 Display this documentation and exit. Does not work in the ePN version.
177 Also known as: -h
178
179 =item --usage
180
181 Display a short usage instruction and exit.
182
183 =back
184
185 =head1 EXAMPLES
186
187 =head2 Send a message with custom headers
188
189 $ check_smtp_send -H mail.server.net --mailto [email protected] --mailfrom [email protected]
190 --body 'Homeruns 5' --header 'Subject: Hello, world!' --header 'X-Your-Header: Yes'
191
192 SMTP SEND OK - 1 seconds
193
194 =head1 EXIT CODES
195
196 Complies with the Nagios plug-in specification:
197 0 OK The plugin was able to check the service and it appeared to be functioning properly
198 1 Warning The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly
199 2 Critical The plugin detected that either the service was not running or it was above some "critical" threshold
200 3 Unknown Invalid command line arguments were supplied to the plugin or the plugin was unable to check the status of the given hosts/service
201
202 =head1 NAGIOS PLUGIN NOTES
203
204 Nagios plugin reference: http://nagiosplug.sourceforge.net/developer-guidelines.html
205
206 This plugin does NOT use Nagios DEFAULT_SOCKET_TIMEOUT (provided by utils.pm as $TIMEOUT) because
207 the path to utils.pm must be specified completely in this program and forces users to edit the source
208 code if their install location is different (if they realize this is the problem). You can view
209 the default timeout for this module by using the --verbose and --version options together. The
210 short form is -vV.
211
212 Other than that, it attempts to follow published guidelines for Nagios plugins.
213
214 =head1 CHANGES
215
216 Wed Oct 29 14:05:00 PST 2005
217 + version 0.1
218
219 Wed Nov 9 15:01:48 PST 2005
220 + now using an inline PluginReport package to generate the report
221 + added stdin option
222 + copyright notice and GNU GPL
223 + version 0.2
224
225 Thu Apr 20 16:00:00 PST 2006 (by Geoff Crompton <[email protected]>)
226 + added bailing if the $smtp->to() call fails
227 + added support for mailto recipients separated by commas
228 + version 0.2.1
229
230 Tue Apr 24 21:17:53 PDT 2007
231 + moved POD text to separate file in order to accomodate the new embedded-perl Nagios feature
232 + version 0.2.3
233
234 Fri Apr 27 20:26:42 PDT 2007
235 + documentation now mentions every command-line option accepted by the plugin, including abbreviations
236 + version 0.3
237
238 Sun Oct 21 10:34:14 PDT 2007
239 + added support for TLS and authentication via the Net::SMTP::TLS module. see --tls option.
240 + version 0.4
241
242 Sun Oct 21 13:54:26 PDT 2007
243 + added support for SSL via the Net::SMTP::SSL module. see --ssl option.
244 + port is no longer a required option. defaults to 25 for regular smtp, 465 for ssl, and 587 for tls.
245 + added port info to the "could not connect" error message
246 + version 0.4.1
247
248 Tue Dec 4 07:42:32 PST 2007
249 + added --usage option because the official nagios plugins have both --help and --usage
250 + added --timeout option to match the official nagios plugins
251 + fixed some minor pod formatting issues for perldoc
252 + version 0.4.2
253
254 Mon Feb 11 19:09:37 PST 2008
255 + fixed a bug for embedded perl version, variable "%status" will not stay shared in load_modules
256 + version 0.4.3
257
258 Mon May 26 09:12:14 PDT 2008
259 + fixed warning and critical messages to use "more than" or "less than" instead of the angle brackets, to make them more web friendly
260 + version 0.4.4
261
262 Wed Jul 2 07:12:35 PDT 2008
263 + added --expect-response option submitted by Christian Kauhaus <[email protected]>
264 + added support for authentication via Net::SMTP_auth. see --auth option.
265 + version 0.4.5
266
267 Sun Oct 5 15:18:23 PDT 2008
268 + added error handling for smtp server disconnects ungracefully during QUIT (gmail.com does)
269 + version 0.4.6
270
271 Thu Oct 1 12:09:35 PDT 2009
272 + added --template option to allow arbitrary substitutions for body and headers, and provided one convenience function for trimming strings
273 + added performance data for use with PNP4Nagios!
274 + version 0.5.0
275
276 Thu Oct 8 11:17:04 PDT 2009
277 + added more detailed error messages when using --verbose
278 + version 0.5.1
279
280 Tue Feb 9 12:14:49 PST 2010
281 + added support for combining --auth with --tls using a subclass of Net::SMTP::TLS submitted by Brad Guillory; please note that to use the "PLAIN" authentication type you need to patch your Net::SMTP:TLS because it has a bug in sub auth_PLAIN (sprintf %S instead of %s)
282 + version 0.5.2
283
284 Mon Jan 3 10:39:42 PST 2011
285 + added default Date and Message-ID headers; Date header uses POSIX strftime and Message-ID header uses hostname command to get localhost name
286 + version 0.7.0
287
288 Fri May 6 08:35:09 AST 2011
289 + added --hires option to enable use of Time::Hires if available
290 + version 0.7.1
291
292 Wed Jul 6 19:18:26 AST 2011
293 + the --hostname is now optional; if not provided the plugin will lookup the MX record for the --mailto address (requires Net::DNS)
294 + version 0.7.2
295
296 Tue Dec 13 09:24:04 PST 2011
297 + separated authentication errors from connection errors
298 + version 0.7.3
299
300 =head1 AUTHOR
301
302 Jonathan Buhacoff <[email protected]>
303
304 =head1 COPYRIGHT AND LICENSE
305
306 Copyright (C) 2005-2011 Jonathan Buhacoff
307
308 This program is free software; you can redistribute it and/or modify
309 it under the terms of the GNU General Public License as published by
310 the Free Software Foundation; either version 3 of the License, or
311 (at your option) any later version.
312
313 This program is distributed in the hope that it will be useful,
314 but WITHOUT ANY WARRANTY; without even the implied warranty of
315 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
316 GNU General Public License for more details.
317
318 You should have received a copy of the GNU General Public License
319 along with this program. If not, see <http://www.gnu.org/licenses/>.
320
321 http://www.gnu.org/licenses/gpl.txt
322
323 =cut
324