check_ups: additional alarm conditions (#1961)
[monitoring-plugins.git] / doc / developer-guidelines.sgml
blob37c963ed6943099194e778fe9341e0481cbb040c
1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN" >
2 <book>
3 <title>Monitoring Plugins Development Guidelines</title>
5 <bookinfo>
6 <authorgroup>
7 <author>
8 <affiliation>
9 <orgname>Monitoring Plugins Development Team</orgname>
10 </affiliation>
11 </author>
12 </authorgroup>
14 <pubdate>2013</pubdate>
15 <title>Monitoring Plugins Development Guidelines</title>
17 <revhistory>
18 <revision>
19 <revnumber>1796</revnumber>
20 <date>2007-09-24 14:51:07 -0400 (Mon, 24 Sep 2007)</date>
21 </revision>
22 </revhistory>
24 <copyright>
25 <year>2000 - 2013</year>
26 <holder>Monitoring Plugins Development Team</holder>
27 </copyright>
29 </bookinfo>
32 <preface id="preface"><title>Preface</title>
33 <para>The purpose of this guidelines is to provide a reference for
34 the plugin developers and encourage the standardization of the
35 different kind of plugins: C, shell, perl, python, etc.</para>
37 <para>Monitoring Plugins Development Guidelines Copyright (C) 2000-2013
38 (Monitoring Plugins Team)</para>
40 <para>Permission is granted to make and distribute verbatim
41 copies of this manual provided the copyright notice and this
42 permission notice are preserved on all copies.</para>
44 <para>The plugins themselves are copyrighted by their respective
45 authors.</para>
46 </preface>
48 <article>
49 <section id="DevRequirements"><title>Development platform requirements</title>
50 <para>
51 Monitoring Plugins are developed to the GNU standard, so any OS which is supported by GNU
52 should run the plugins. While the requirements for compiling the Monitoring Plugins release
53 are very basic, developing from the Git repository requires additional software to be
54 installed. These are the minimum levels of software required:
56 <literallayout>
57 GNU make 3.79
58 GNU automake 1.9.2
59 GNU autoconf 2.59
60 GNU m4 1.4.2
61 GNU libtool 1.5
62 </literallayout>
64 To compile from Git, after you have cloned the repository, run:
65 <literallayout>
66 tools/setup
67 ./configure
68 make
69 make install
70 </literallayout>
71 </para>
72 </section>
74 <section id="PlugOutput"><title>Plugin Output for Nagios</title>
76 <para>You should always print something to STDOUT that tells if the
77 service is working or why it is failing. Try to keep the output short -
78 probably less that 80 characters. Remember that you ideally would like
79 the entire output to appear in a pager message, which will get chopped
80 off after a certain length.</para>
82 <para>As Nagios does not capture stderr output, you should only output to
83 STDOUT and not print to STDERR.</para>
85 <section><title>Print only one line of text</title>
86 <para>Starting with version 3, Nagios will process plugins' multiline
87 output, which should be formatted as:</para>
88 <literallayout>
89 SERVICE STATUS: First line of output | First part of performance data
90 Any number of subsequent lines of output, but note that buffers
91 may have a limited size | Second part of performance data, which
92 may have continuation lines, too
93 </literallayout>
94 <para>Note, however, that the default configs still do not include
95 the output's continuation lines into the notifications sent when
96 Nagios notifies contacts about potential problems.
97 Thus, keep your output short and to the point.</para>
99 <para>Output should be in the format:</para>
100 <literallayout>
101 SERVICE STATUS: Information text
102 </literallayout>
103 <para>However, note that this is not a requirement of the API, so you cannot depend on this
104 being an accurate reflection of the status of the service - the status should always
105 be determined by the return code.</para>
106 </section>
108 <section><title>Verbose output</title>
109 <para>Use the -v flag for verbose output. You should allow multiple
110 -v options for additional verbosity, up to a maximum of 3. The standard
111 type of output should be:</para>
113 <table id="verboselevels"><title>Verbose output levels</title>
114 <tgroup cols="2">
115 <thead>
116 <row>
117 <entry><para>Verbosity level</para></entry>
118 <entry><para>Type of output</para></entry>
119 </row>
120 </thead>
121 <tbody>
122 <row>
123 <entry align="center"><para>0</para></entry>
124 <entry><para>Single line, minimal output. Summary</para></entry>
125 </row>
126 <row>
127 <entry align="center"><para>1</para></entry>
128 <entry><para>Single line, additional information (eg list processes that fail)</para></entry>
129 </row>
130 <row>
131 <entry align="center"><para>2</para></entry>
132 <entry><para>Multi line, configuration debug output (eg ps command used)</para></entry>
133 </row>
134 <row>
135 <entry align="center"><para>3</para></entry>
136 <entry><para>Lots of detail for plugin problem diagnosis</para></entry>
137 </row>
138 </tbody>
139 </tgroup>
140 </table>
141 </section>
143 <section><title>Screen Output</title>
144 <para>The plugin should print the diagnostic and just the
145 usage part of the help message. A well written plugin would
146 then have --help as a way to get the verbose help.</para>
148 <para>Code and output should try to respect the 80x25 size of a
149 crt (remember when fixing stuff in the server room!)</para>
150 </section>
152 <section><title>Plugin Return Codes</title>
153 <para>The return codes below are based on the POSIX spec of returning
154 a positive value. Netsaint prior to v0.0.7 supported non-POSIX
155 compliant return code of "-1" for unknown. Nagios supports POSIX return
156 codes by default.</para>
158 <para>Note: Some plugins will on occasion print on STDOUT that an error
159 occurred and error code is 138 or 255 or some such number. These
160 are usually caused by plugins using system commands and having not
161 enough checks to catch unexpected output. Developers should include a
162 default catch-all for system command output that returns an UNKNOWN
163 return code.</para>
165 <table id="ReturnCodes"><title>Plugin Return Codes</title>
166 <tgroup cols="3">
167 <thead>
168 <row>
169 <entry><para>Numeric Value</para></entry>
170 <entry><para>Service Status</para></entry>
171 <entry><para>Status Description</para></entry>
172 </row>
173 </thead>
174 <tbody>
175 <row>
176 <entry align="center"><para>0</para></entry>
177 <entry valign="middle"><para>OK</para></entry>
178 <entry><para>The plugin was able to check the service and it
179 appeared to be functioning properly</para></entry>
180 </row>
181 <row>
182 <entry align="center"><para>1</para></entry>
183 <entry valign="middle"><para>Warning</para></entry>
184 <entry><para>The plugin was able to check the service, but it
185 appeared to be above some "warning" threshold or did not appear
186 to be working properly</para></entry>
187 </row>
188 <row>
189 <entry align="center"><para>2</para></entry>
190 <entry valign="middle"><para>Critical</para></entry>
191 <entry><para>The plugin detected that either the service was not
192 running or it was above some "critical" threshold</para></entry>
193 </row>
194 <row>
195 <entry align="center"><para>3</para></entry>
196 <entry valign="middle"><para>Unknown</para></entry>
197 <entry><para>Invalid command line arguments were supplied to the
198 plugin or low-level failures internal to the plugin (such as unable to fork,
199 or open a tcp socket) that prevent it from performing the specified
200 operation. Higher-level errors (such as name resolution errors,
201 socket timeouts, etc) are outside of the control of plugins and should
202 generally NOT be reported as UNKNOWN states.
203 </para><para>The --help or --version output should also result in Unknown state.
204 </para></entry>
205 </row>
206 </tbody>
207 </tgroup>
208 </table>
211 </section>
213 <section id="thresholdformat"><title>Threshold and ranges</title>
214 <para>A range is defined as a start and end point (inclusive) on a numeric scale (possibly
215 negative or positive infinity).
216 </para>
217 <para>A threshold is a range with an alert level (either warning or critical). Use the
218 set_thresholds(thresholds *, char *, char *) function to set the thresholds.
219 </para>
220 <para>The theory is that the plugin will do some sort of check which returns
221 back a numerical value, or metric, which is then compared to the warning and
222 critical thresholds. Use the get_status(double, thresholds *) function to
223 compare the value against the thresholds.</para>
224 <para>This is the generalised format for ranges:</para>
226 <literallayout>
227 [@]start:end
228 </literallayout>
230 <para>Notes:</para>
231 <orderedlist>
232 <listitem><para>start &le; end</para>
233 </listitem>
234 <listitem><para>start and ":" is not required if start=0</para>
235 </listitem>
236 <listitem><para>if range is of format "start:" and end is not specified,
237 assume end is infinity</para>
238 </listitem>
239 <listitem><para>to specify negative infinity, use "~"</para>
240 </listitem>
241 <listitem><para>alert is raised if metric is outside start and end range
242 (inclusive of endpoints)</para>
243 </listitem>
244 <listitem><para>if range starts with "@", then alert if inside this range
245 (inclusive of endpoints)</para>
246 </listitem>
247 </orderedlist>
249 <para>Note: Not all plugins are coded to expect ranges in this format yet.
250 There will be some work in providing multiple metrics.</para>
252 <table id="ExampleRanges"><title>Example ranges</title>
253 <tgroup cols="2">
254 <thead>
255 <row>
256 <entry><para>Range definition</para></entry>
257 <entry><para>Generate an alert if x...</para></entry>
258 </row>
259 </thead>
260 <tbody>
261 <row>
262 <entry>10</entry>
263 <entry>&lt; 0 or &gt; 10, (outside the range of {0 .. 10})</entry>
264 </row>
265 <row>
266 <entry>10:</entry>
267 <entry>&lt; 10, (outside {10 .. &infin;})</entry>
268 </row>
269 <row>
270 <entry>~:10</entry>
271 <entry>&gt; 10, (outside the range of {-&infin; .. 10})</entry>
272 </row>
273 <row>
274 <entry>10:20</entry>
275 <entry>&lt; 10 or &gt; 20, (outside the range of {10 .. 20})</entry>
276 </row>
277 <row>
278 <entry>@10:20</entry>
279 <entry>&ge; 10 and &le; 20, (inside the range of {10 .. 20})</entry>
280 </row>
281 </tbody>
282 </tgroup>
283 </table>
284 <table id="CommandLineExamples"><title>Command line examples</title>
285 <tgroup cols="2">
286 <thead>
287 <row>
288 <entry><para>Command line</para></entry>
289 <entry><para>Meaning</para></entry>
290 </row>
291 </thead>
292 <tbody>
293 <row>
294 <entry>check_stuff -w10 -c20</entry>
295 <entry>Critical if "stuff" is over 20, else warn if over 10 (will be critical if "stuff" is less than 0)</entry>
296 </row>
297 <row>
298 <entry>check_stuff -w~:10 -c~:20</entry>
299 <entry>Same as above. Negative "stuff" is OK</entry>
300 </row>
301 <row>
302 <entry>check_stuff -w10: -c20</entry>
303 <entry>Critical if "stuff" is over 20, else warn if "stuff" is below 10 (will be critical if "stuff" is less than 0)</entry>
304 </row>
305 <row>
306 <entry>check_stuff -c1:</entry>
307 <entry>Critical if "stuff" is less than 1</entry>
308 </row>
309 <row>
310 <entry>check_stuff -w~:0 -c10</entry>
311 <entry>Critical if "stuff" is above 10; Warn if "stuff" is above zero (will be critical if "stuff" is less than 0)</entry>
312 </row>
313 <row>
314 <entry>check_stuff -c5:6</entry>
315 <entry>Critical if "stuff" is less than 5 or more than 6</entry>
316 </row>
317 <row>
318 <entry>check_stuff -c@10:20</entry>
319 <entry>OK if stuff is less than 10 or higher than 20, otherwise critical </entry>
320 </row>
321 </tbody>
322 </tgroup>
323 </table>
324 </section>
326 <section><title>Performance data</title>
327 <para>Nagios 3 and newer will concatenate the parts following a "|" in a) the first
328 line output by the plugin, and b) in the second to last line, into a string it
329 passes to whatever performance data processing it has configured. (Note that it
330 currently does not insert additional whitespace between both, so the plugin needs
331 to provide some to prevent the last pair of a) and the first of b) getting run
332 together.) Please refer to the Nagios documentation for information on how to
333 configure such processing. However, it is the responsibility of the plugin writer
334 to ensure the performance data is in a "Nagios Plugins" format.
335 This is the expected format:</para>
337 <literallayout>
338 'label'=value[UOM];[warn];[crit];[min];[max]
339 </literallayout>
341 <para>Notes:</para>
342 <orderedlist>
343 <listitem><para>space separated list of label/value pairs</para>
344 </listitem>
345 <listitem><para>label can contain any characters except the equals sign or single quote (')</para>
346 </listitem>
347 <listitem><para>the single quotes for the label are optional. Required if
348 spaces are in the label</para>
349 </listitem>
350 <listitem><para>label length is arbitrary, but ideally the first 19 characters
351 are unique (due to a limitation in RRD). Be aware of a limitation in the
352 amount of data that NRPE returns to Nagios</para>
353 </listitem>
354 <listitem><para>to specify a quote character, use two single quotes</para>
355 </listitem>
356 <listitem><para>warn, crit, min or max may be null (for example, if the threshold is
357 not defined or min and max do not apply). Trailing unfilled semicolons can be
358 dropped</para>
359 </listitem>
360 <listitem><para>min and max are not required if UOM=%</para>
361 </listitem>
362 <listitem><para>value, min and max in class [-0-9.]. Must all be the
363 same UOM. value may be a literal "U" instead, this would indicate that the
364 actual value couldn't be determined</para>
365 </listitem>
366 <listitem><para>warn and crit are in the range format (see
367 <xref linkend="thresholdformat">). Must be the same UOM</para>
368 </listitem>
369 <listitem><para>UOM (unit of measurement) is one of:</para>
370 <orderedlist>
371 <listitem><para>no unit specified - assume a number (int or float)
372 of things (eg, users, processes, load averages)</para>
373 </listitem>
374 <listitem><para>s - seconds (also us, ms)</para></listitem>
375 <listitem><para>% - percentage</para></listitem>
376 <listitem><para>B - bytes (also KB, MB, TB)</para></listitem>
377 <listitem><para>c - a continuous counter (such as bytes
378 transmitted on an interface)</para></listitem>
379 </orderedlist>
380 </listitem>
381 </orderedlist>
383 <para>It is up to third party programs to convert the Monitoring Plugins
384 performance data into graphs.</para>
385 </section>
387 <section><title>Translations</title>
388 <para>If possible, use translation tools for all output to respect the user's language
389 settings. See <xref linkend="translationsdevelopers"> for guidelines
390 for the core plugins.
391 </para>
392 </section>
393 </section>
395 <section id="SysCmdAuxFiles"><title>System Commands and Auxiliary Files</title>
397 <section><title>Don't execute system commands without specifying their
398 full path</title>
399 <para>Don't use exec(), popen(), etc. to execute external
400 commands without explicitly using the full path of the external
401 program.</para>
403 <para>Doing otherwise makes the plugin vulnerable to hijacking
404 by a trojan horse earlier in the search path. See the main
405 plugin distribution for examples on how this is done.</para>
406 </section>
408 <section><title>Use spopen() if external commands must be executed</title>
410 <para>If you have to execute external commands from within your
411 plugin and you're writing it in C, use the spopen() function
412 that Karl DeBisschop has written.</para>
414 <para>The code for spopen() and spclose() is included with the
415 core plugin distribution.</para>
416 </section>
418 <section><title>Don't make temp files unless absolutely required</title>
420 <para>If temp files are needed, make sure that the plugin will
421 fail cleanly if the file can't be written (e.g., too few file
422 handles, out of disk space, incorrect permissions, etc.) and
423 delete the temp file when processing is complete.</para>
424 </section>
426 <section><title>Don't be tricked into following symlinks</title>
428 <para>If your plugin opens any files, take steps to ensure that
429 you are not following a symlink to another location on the
430 system.</para>
431 </section>
433 <section><title>Validate all input</title>
435 <para>use routines in utils.c or utils.pm and write more as needed</para>
436 </section>
438 </section>
443 <section id="PerlPlugin"><title>Perl Plugins</title>
445 <para>Perl plugins are coded a little more defensively than other
446 plugins because of embedded Perl. When configured as such, embedded
447 Perl Nagios (ePN) requires stricter use of the some of Perl's features.
448 This section outlines some of the steps needed to use ePN
449 effectively.</para>
451 <orderedlist>
453 <listitem><para> Do not use BEGIN and END blocks since they will be called
454 only once (when Nagios starts and shuts down) with Embedded Perl (ePN). In
455 particular, do not use BEGIN blocks to initialize variables.</para>
456 </listitem>
458 <listitem><para>To use utils.pm, you need to provide a full path to the
459 module in order for it to work.</para>
461 <literallayout>
462 e.g.
463 use lib "/usr/local/nagios/libexec";
464 use utils qw(...);
465 </literallayout>
466 </listitem>
468 <listitem><para>Perl scripts should be called with "-w"</para>
469 </listitem>
471 <listitem><para>All Perl plugins must compile cleanly under "use strict" - i.e. at
472 least explicitly package names as in "$main::x" or predeclare every
473 variable. </para>
476 <para>Explicitly initialize each variable in use. Otherwise with
477 caching enabled, the plugin will not be recompiled each time, and
478 therefore Perl will not reinitialize all the variables. All old
479 variable values will still be in effect.</para>
480 </listitem>
482 <listitem><para>Do not use &gt;DATA&lt; handles (these simply do not compile under ePN).</para>
483 </listitem>
485 <listitem><para>Do not use global variables in named subroutines. This is bad practise anyway, but with ePN the
486 compiler will report an error "&lt;global_var&gt; will not stay shared ..". Values used by
487 subroutines should be passed in the argument list.</para>
488 </listitem>
490 <listitem><para>If writing to a file (perhaps recording
491 performance data) explicitly close close it. The plugin never
492 calls <emphasis role="strong">exit</emphasis>; that is caught by
493 p1.pl, so output streams are never closed.</para>
494 </listitem>
496 <listitem><para>As in <xref linkend="runtime"> all plugins need
497 to monitor their runtime, specially if they are using network
498 resources. Use of the <emphasis>alarm</emphasis> is recommended
499 noting that some Perl modules (eg LWP) manage timers, so that an alarm
500 set by a plugin using such a module is overwritten by the module.
501 (workarounds are cunning (TM) or using the module timer)
502 Plugins may import a default time out ($TIMEOUT) from utils.pm.
503 </para>
504 </listitem>
506 <listitem><para>Perl plugins should import %ERRORS from utils.pm
507 and then "exit $ERRORS{'OK'}" rather than "exit 0"
508 </para>
509 </listitem>
511 </orderedlist>
513 </section>
515 <section id="runtime"><title>Runtime Timeouts</title>
517 <para>Plugins have a very limited runtime - typically 10 sec.
518 As a result, it is very important for plugins to maintain internal
519 code to exit if runtime exceeds a threshold. </para>
521 <para>All plugins should timeout gracefully, not just networking
522 plugins. For instance, df may lock if you have automounted
523 drives and your network fails - but on first glance, who'd think
524 df could lock up like that. Plus, it should just be more error
525 resistant to be able to time out rather than consume
526 resources.</para>
528 <section><title>Use DEFAULT_SOCKET_TIMEOUT</title>
530 <para>All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout</para>
532 </section>
535 <section><title>Add alarms to network plugins</title>
537 <para>If you write a plugin which communicates with another
538 networked host, you should make sure to set an alarm() in your
539 code that prevents the plugin from hanging due to abnormal
540 socket closures, etc. Nagios takes steps to protect itself
541 against unruly plugins that timeout, but any plugins you create
542 should be well behaved on their own.</para>
544 </section>
548 </section>
550 <section id="PlugOptions"><title>Plugin Options</title>
552 <para>A well written plugin should have --help as a way to get
553 verbose help. Code and output should try to respect the 80x25 size of a
554 crt (remember when fixing stuff in the server room!)</para>
556 <section><title>Option Processing</title>
558 <para>For plugins written in C, we recommend the C standard
559 getopt library for short options. Getopt_long is always available.
560 </para>
562 <para>For plugins written in Perl, we recommend Getopt::Long module.</para>
564 <para>Positional arguments are strongly discouraged.</para>
566 <para>There are a few reserved options that should not be used
567 for other purposes:</para>
569 <literallayout>
570 -V version (--version)
571 -h help (--help)
572 -t timeout (--timeout)
573 -w warning threshold (--warning)
574 -c critical threshold (--critical)
575 -H hostname (--hostname)
576 -v verbose (--verbose)
577 </literallayout>
579 <para>In addition to the reserved options above, some other standard options are:</para>
581 <literallayout>
582 -C SNMP community (--community)
583 -a authentication password (--authentication)
584 -l login name (--logname)
585 -p port or password (--port or --passwd/--password)monitors operational
586 -u url or username (--url or --username)
587 </literallayout>
589 <para>Look at check_pgsql and check_procs to see how I currently
590 think this can work. Standard options are:</para>
593 <para>The option -V or --version should be present in all
594 plugins. For C plugins it should result in a call to print_revision, a
595 function in utils.c which takes two character arguments, the
596 command name and the plugin revision.</para>
598 <para>The -? option, or any other unparsable set of options,
599 should print out a short usage statement. Character width should
600 be 80 and less and no more that 23 lines should be printed (it
601 should display cleanly on a dumb terminal in a server
602 room).</para>
604 <para>The option -h or --help should be present in all plugins.
605 In C plugins, it should result in a call to print_help (or
606 equivalent). The function print_help should call print_revision,
607 then print_usage, then should provide detailed
608 help. Help text should fit on an 80-character width display, but
609 may run as many lines as needed.</para>
611 <para>The option -v or --verbose should be present in all plugins.
612 The user should be allowed to specify -v multiple times to increase
613 the verbosity level, as described in <xref linkend="verboselevels">.</para>
615 <para>The exit code for version information or help should be UNKNOWN
616 (3).</para>
617 </section>
619 <section>
620 <title>Plugins with more than one type of threshold, or with
621 threshold ranges</title>
623 <para>Old style was to do things like -ct for critical time and
624 -cv for critical value. That goes out the window with POSIX
625 getopt. The allowable alternatives are:</para>
627 <orderedlist>
628 <listitem>
629 <para>long options like -critical-time (or -ct and -cv, I
630 suppose).</para>
631 </listitem>
633 <listitem>
634 <para>repeated options like `check_load -w 10 -w 6 -w 4 -c
635 16 -c 10 -c 10`</para>
636 </listitem>
638 <listitem>
639 <para>for brevity, the above can be expressed as `check_load
640 -w 10,6,4 -c 16,10,10`</para>
641 </listitem>
643 <listitem>
644 <para>ranges are expressed with colons as in `check_procs -C
645 httpd -w 1:20 -c 1:30` which will warn above 20 instances,
646 and critical at 0 and above 30</para>
647 </listitem>
649 <listitem>
650 <para>lists are expressed with commas, so Jacob's check_nmap
651 uses constructs like '-p 1000,1010,1050:1060,2000'</para>
652 </listitem>
654 <listitem>
655 <para>If possible when writing lists, use tokens to make the
656 list easy to remember and non-order dependent - so
657 check_disk uses '-c 10000,10%' so that it is clear which is
658 the percentage and which is the KB values (note that due to
659 my own lack of foresight, that used to be '-c 10000:10%' but
660 such constructs should all be changed for consistency,
661 though providing reverse compatibility is fairly
662 easy).</para>
663 </listitem>
665 </orderedlist>
667 <para>As always, comments are welcome - making this consistent
668 without a host of long options was quite a hassle, and I would
669 suspect that there are flaws in this strategy.
670 </para>
671 </section>
672 </section>
674 <section id="Testcases"><title>Test cases</title>
675 <para>
676 Tests are the best way of knowing if the plugins work as expected. Please
677 create and update test cases where possible.
678 </para>
680 <para>
681 To run a test, from the top level directory, run "make test". This will run
682 all the current tests and report an overall success rate.
683 </para>
685 <section><title>Test cases for plugins</title>
686 <para>These use perl's Test::More. To do a one time test, run "cd plugins && perl t/check_disk.t".
687 </para>
689 <para>There will sometimes be failures seen in this output which are known failures that
690 need to be fixed. As long as the return code is 0, it will be reported as "test pass".
691 (If you have a fix so that the specific test passes, that will be gratefully received!)
692 </para>
694 <para>
695 If you want a summary test, run: "cd plugins && prove t/check_disk.t".
696 This runs the test in a summary format.
697 </para>
699 <para>
700 For a good and amusing tutorial on using Test::More, see this
701 <ulink url="http://search.cpan.org/dist/Test-Simple/lib/Test/Tutorial.pod">
702 link</ulink>
703 </para>
705 </section>
707 <section><title>Testing the C library functions</title>
708 <para>
709 We use <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap">the libtap library</ulink>, which gives
710 perl's TAP
711 (Test Anything Protocol) output. This is used by the FreeBSD team for their regression testing.
712 </para>
714 <para>
715 To run tests using the libtap library, download the latest tar ball and extract.
716 There is a problem with tap-1.01 where
717 <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/25">pthread support doesn't appear to work</ulink>
718 properly on non-FreeBSD systems. Install with 'CPPFLAGS="-UHAVE_LIBPTHREAD" ./configure && make && make check && make install'.
719 </para>
721 <para>
722 When you run Monitoring Plugins' configure, it will look for the tap library and will automatically
723 setup the tests. Run "make test" to run all the tests.
724 </para>
725 </section>
727 </section>
728 <section id="CodingGuidelines"><title>Coding guidelines</title>
729 <para>See <ulink url="http://www.gnu.org/prep/standards_toc.html">GNU
730 Coding standards</ulink> for general guidelines.</para>
731 <section><title>C coding</title>
733 <para>Variables should be declared at the beginning of code blocks and
734 not inline because of portability with older compilers.</para>
736 <para>You should use the type "bool" and its values
737 "true" and "false" instead of the "int" type for booleans.
738 </para>
739 </section>
741 <section><title>Crediting sources</title>
742 <para>If you have copied a routine from another source, make sure the licence
743 from your source allows this. Add a comment referencing the ACKNOWLEDGEMENTS
744 file, where you can put more detail about the source.</para>
745 <para>For contributed code, do not add any named credits in the source code
746 - contributors should be added into the THANKS.in file instead.
747 </para>
748 </section>
750 <section><title>Commit Messages</title>
751 <para>If the change is due to a contribution, please quote the contributor's name
752 and, if applicable, add the GitHub Issue Tracker number. Don't forget to
753 update the THANKS.in file.</para>
754 <para>If you have a change that is useful for noting in the next release, please
755 update the NEWS file.</para>
756 <para>All commits will be written to a ChangeLog at release time.
757 </para>
758 </section>
760 <section id="translationsdevelopers"><title>Translations for developers</title>
761 <para>To make the job easier for translators, please follow these guidelines:</para>
762 <orderedlist>
763 <listitem><para>
764 Before creating new strings, check the po/monitoring-plugins.pot file to
765 see if a similar string
766 already exists
767 </para></listitem>
768 <listitem><para>
769 For help texts, break into individual options so that these can be reused
770 between plugins
771 </para></listitem>
772 <listitem><para>Try to avoid linefeeds unless you are working on a block of text</para></listitem>
773 <listitem><para>Short help is not translated</para></listitem>
774 <listitem><para>Long help has options in English language, but text translated</para></listitem>
775 <listitem><para>"Copyright" kept in English</para></listitem>
776 <listitem><para>Copyright holder names kept in original text</para></listitem>
777 <listitem><para>Debugging output does not need to be translated</para></listitem>
778 </orderedlist>
779 </section>
781 <section><title>Translations for translators</title>
782 <para>To create an up to date list of translatable strings, run: tools/gen_locale.sh</para>
783 </section>
785 </section>
787 <section id="SubmittingChanges"><title>Submission of new plugins and patches</title>
789 <section id="Patches"><title>Patches</title>
790 <para>If you have a bug patch, please supply a unified or context diff against the
791 version you are using. For new features, please supply a diff against
792 the Git "master" branch.</para>
794 <para>Patches should be submitted via
795 <ulink url="https://github.com/monitoring-plugins/monitoring-plugins/pulls">GitHub's
796 Pull requests for Monitoring Plugins</ulink>
797 </para>
799 <para>Submission of a patch implies that the submmitter acknowledges that they
800 are the author of the code (or have permission from the author to release the code)
801 and agree that the code can be released under the GPL. The copyright for the changes will
802 then revert to the Monitoring Plugins Development Team - this is required so that any copyright
803 infringements can be investigated quickly without contacting a huge list of copyright holders.
804 Credit will always be given for any patches through a THANKS file in the distribution.</para>
805 </section>
808 <section id="Contributedplugins"><title>Contributed plugins</title>
809 <para>Plugins that have been contributed to the project and
810 distributed with the Monitoring Plugins files are held in the contrib/ directory and are not installed
811 by default. These plugins are not officially supported by the team.
812 The current policy is that these plugins should be owned and maintained by the original
813 contributor, preferably hosted on <ulink url="https://exchange.icinga.com/">Icinga Exchange</ulink>.
814 </para>
815 <para>If patches or bugs are raised to an contributed plugin, we will start communications with the
816 original contributor, but seek to remove the plugin from our distribution.
817 </para>
818 <para>The aim is to distribute only code that the Monitoring Plugins team are responsible for.
819 </para>
820 </section>
822 <section id="Newplugins"><title>New plugins</title>
823 <para>If you would like others to use your plugins, please add it to
824 the official 3rd party plugin repository,
825 <ulink url="https://exchange.icinga.com/">Icinga Exchange</ulink>.
826 </para>
828 <para>We are not accepting requests for inclusion of plugins into
829 our distribution at the moment, but when we do, these are the minimum
830 requirements:
831 </para>
833 <orderedlist>
834 <listitem>
835 <para>Include copyright and license information in all files. Copyright must be solely
836 granted to the Monitoring Plugins Development Team</para>
837 </listitem>
838 <listitem>
839 <para>The standard command options are supported (--help, --version,
840 --timeout, --warning, --critical)</para>
841 </listitem>
842 <listitem>
843 <para>It is determined to be not redundant (for instance, we would not
844 add a new version of check_disk just because someone had provide
845 a plugin that had perf checking - we would incorporate the features
846 into an existing plugin)</para>
847 </listitem>
848 <listitem>
849 <para>One of the developers has had the time to audit the code and declare
850 it ready for core</para>
851 </listitem>
852 <listitem>
853 <para>It should also follow code format guidelines, and use functions from
854 utils (perl or c or sh) rather than using its own</para>
855 </listitem>
856 <listitem>
857 <para>Includes patches to configure.in if required (via the EXTRAS list if
858 it will only work on some platforms)</para>
859 </listitem>
860 <listitem>
861 <para>If possible, please submit a test harness. Documentation on sample
862 tests coming soon</para>
863 </listitem>
864 </orderedlist>
866 </section>
868 </section>
869 </article>
871 </book>